Sha256: e8956de00090a66177faf12032a1bf01defad1fb820fe50d073bca99835bc2d1

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe Conjur::Command::Users, logged_in: true do
  let (:rotate_api_key_url) { [Conjur.configuration.authn_url, account, 'api_key'].join('/') }
  let (:update_password_url) { [Conjur.configuration.authn_url, account, 'password'].join('/') }

  context "updating password" do
    before do
     expect(RestClient::Request).to receive(:execute).with({
        method: :put,
        url: update_password_url,
        user: username, 
        password: api_key,
        headers: { },
        payload: "new-password"
       })
    end
    
    describe_command "user:update_password -p new-password" do
      it "PUTs the new password" do
        invoke
      end
    end
  
    describe_command "user:update_password" do
      it "PUTs the new password" do
        expect(Conjur::Command::Users).to receive(:prompt_for_password).and_return "new-password"

        invoke
      end
    end
  end

  context 'rotating api key' do
    describe_command 'user rotate_api_key' do
      before do
        expect(RestClient::Request).to receive(:execute).with({
                    method: :put,
                    url: rotate_api_key_url,
                    user: username,
                    password: api_key,
                    headers: {},
                    payload: ''
                }).and_return double(:response, body: 'new api key')
        expect(Conjur::Authn).to receive(:save_credentials).with({
                    username: username,
                    password: 'new api key'
                })
      end

      it 'puts with basic auth' do
        invoke
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
conjur-cli-6.2.2 spec/command/users_spec.rb
conjur-cli-6.2.1 spec/command/users_spec.rb
conjur-cli-6.2.0 spec/command/users_spec.rb
conjur-cli-6.1.0 spec/command/users_spec.rb
conjur-cli-6.0.1 spec/command/users_spec.rb
conjur-cli-6.0.0 spec/command/users_spec.rb
conjur-cli-6.0.0.rc1 spec/command/users_spec.rb