Sha256: 58f50e8e390aaa6c4cbdead1c7ce720aa431ed76aeb2f34091b30828786416c4

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

require "rubygems"
require "bundler/setup"
require 'tempfile'

require "simplecov"
SimpleCov.start

module RSpec::Core::DSL
  def describe_command *argv, &block
    describe *argv do
      let(:invoke) do
        Conjur::CLI.error_device = $stderr
        Conjur::CLI.run argv.first.split(' ')
      end
      instance_eval &block
    end
  end
end

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
    Conjur::Authn::API.stub host: authn_host
    Conjur::Authz::API.stub host: authz_host
    Conjur::Core::API.stub 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' }
  before do
    Conjur::Core::API.stub conjur_account: account
    Conjur::Authn.stub 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"
  let(:username) { 'dknuth' }
  let(:api_key) { 'sekrit' }
  let(:api) { Conjur::API.new_from_key(username, api_key) }
  before do
    api.stub credentials: {}
    netrc[authn_host] = [username, api_key]
    Conjur::Command.stub api: api
  end
end

shared_context "when not logged in", logged_in: false do
  include_context "with mock authn"
end

require 'write_expectation'

require 'conjur/cli'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
conjur-cli-2.4.1 spec/spec_helper.rb
conjur-cli-2.4.0 spec/spec_helper.rb
conjur-cli-2.3.0 spec/spec_helper.rb