Sha256: 70546a34e2b9811c161ac961837f4ef2ebbb418a656e48f40fbcdacd6d78e6ea

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'
require 'conjur/dsl/runner'

describe Conjur::Command::Policy do
  context logged_in: true do
    let(:role) do
      double("role", exists?: true, api_key: "the-api-key", roleid: "the-role")
    end
    let(:resource) do
      double("resource", exists?: true).as_null_object
    end
    let(:name) { nil }
    before {
      File.stub(:read).with("policy-body").and_return "{}"
      Conjur::DSL::Runner.any_instance.stub(:api).and_return api
    }
    before {
      api.stub(:role).with("the-account:policy:#{collection}/the-policy-1.0.0").and_return role
      api.stub(:resource).with("the-account:policy:#{collection}/the-policy-1.0.0").and_return resource
      if name
        resource.should_receive(:[]).with(:name, name)
      end
    }
    
    describe_command 'policy:load --collection the-collection policy-body' do
      let(:collection) { "the-collection" }
      it "creates the policy" do
        invoke.should == 0
      end
    end
    context "default collection" do
      let(:collection) { "alice@localhost" }
      before {
        stub_const("ENV", "USER" => "alice", "HOSTNAME" => "localhost")
      }
      describe_command 'policy:load policy-body' do
        it "creates the policy with default collection" do
          invoke.should == 0
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
conjur-cli-4.8.0 spec/command/policy_spec.rb
conjur-cli-4.7.5 spec/command/policy_spec.rb
conjur-cli-4.7.4 spec/command/policy_spec.rb
conjur-cli-4.7.3 spec/command/policy_spec.rb
conjur-cli-4.7.2 spec/command/policy_spec.rb
conjur-cli-4.7.1 spec/command/policy_spec.rb
conjur-cli-4.7.0 spec/command/policy_spec.rb