Sha256: 80cd9108c43b3972cb4c043e49fe47f70c6025ec0c9cf16c857a9f3e0c68d857

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

shared_context "with fake endpoints and test config" do
  let(:authn_host) { 'https://authn.example.com' }
  let(:authz_host) { 'https://authz.example.com' }
  let(:core_host) { 'https://core.example.com' }
  before do
    allow(Conjur::Authn::API).to receive(:host) { authn_host }
    allow(Conjur::Authz::API).to receive(:host) { authz_host }
    allow(Conjur::Core::API).to receive(:host) { core_host }

    ENV['GLI_DEBUG'] = 'true'
  end
end

shared_context "with mock authn" do
  include_context "with fake endpoints and test config"
  let(:netrcfile) { Tempfile.new 'authtest' }
  let(:netrc) { Netrc.read(netrcfile.path) }
  let(:account) { 'the-account' }
  let(:username) { 'dknuth' }
  let(:api_key) { 'sekrit' }
  let(:api) { Conjur::API.new_from_key(username, api_key) }
  before do
    allow(Conjur::Core::API).to receive(:conjur_account) { account }
    allow(Conjur::Authn).to receive_messages(netrc: netrc, host: authn_host)
    Conjur::Config.merge 'account' => account
  end
end

shared_context "when logged in", logged_in: true do
  include_context "with mock authn"
  before do
    allow(api).to receive(:credentials) { {} }
    netrc[authn_host] = [username, api_key]
    allow(Conjur::Command).to receive_messages api: api
  end
end

shared_context "when not logged in", logged_in: false do
  include_context "with mock authn"
  before do
    Conjur::Authn.instance_variable_set :@credentials, nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
conjur-cli-4.28.2 lib/conjur/command/rspec/mock_services.rb
conjur-cli-4.28.1 lib/conjur/command/rspec/mock_services.rb
conjur-cli-4.28.0 lib/conjur/command/rspec/mock_services.rb
conjur-cli-4.27.0 lib/conjur/command/rspec/mock_services.rb