Sha256: d11ff8d4db188fd6065776c588f6c53e5113d3df13b8aadb7c214a128553bb4f

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 Bytes

Contents

require 'spec_helper'

describe Conjur::Command::Elevate do
  describe_command "elevate user show alice" do
    include_context "with mock authn"
    
    let(:token) { {login: 'dknuth'} }
    before{
      expect(Conjur::Authn).to receive(:connect).and_return(api)
    }
    it "invokes the sub-command with X-Conjur-Privilege header" do
      allow_any_instance_of(Conjur::API).to receive(:token).and_return(token)
      expect(Conjur::Command).to receive(:api=) do |api|
        expect(api.api_key).to eq("sekrit")
        expect(api.privilege).to eq("elevate")
      end.and_call_original
      
      expect(RestClient::Request).to receive(:execute).with({
        method: :get,
        url: "https://core.example.com/users/alice",
        username: "dknuth",
        headers: {:authorization=>"Token token=\"eyJsb2dpbiI6ImRrbnV0aCJ9\"", x_conjur_privilege: "elevate"}
      }).and_return(double(:response, body: "[]"))
      
      invoke
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
conjur-cli-4.28.2 spec/command/elevate_spec.rb
conjur-cli-4.28.1 spec/command/elevate_spec.rb
conjur-cli-4.28.0 spec/command/elevate_spec.rb