Sha256: 81872ac4069b254f6c01475b1fe157fded4e08e611b5189b7de2bf00ab639af5

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Conjur::Command::Roles, logged_in: true do
  let(:all_roles) { %w(foo:user:joerandom foo:something:cool foo:something:else foo:group:admins) }
  let(:role) do
    double "the role", all: all_roles.map{|r| double r, roleid: r }
  end

  before do
    api.stub(:role).with(rolename).and_return role
  end

  context "when logged in as a user" do
    let(:username) { "joerandom" }
    let(:rolename) { "user:joerandom" }

    describe_command "role:memberships" do
      it "lists all roles" do
        JSON::parse(expect { invoke }.to write).should == all_roles
      end
    end

    describe_command "role:memberships foo:bar" do
      let(:rolename) { 'foo:bar' }
      it "lists all roles of foo:bar" do
        JSON::parse(expect { invoke }.to write).should == all_roles
      end
    end
  end

  context "when logged in as a host" do
    let(:username) { "host/foobar" }
    let(:rolename) { "host:foobar" }

    describe_command "role:memberships" do
      it "lists all roles" do
        JSON::parse(expect { invoke }.to write).should == all_roles
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
conjur-cli-2.4.0 spec/command/roles_spec.rb
conjur-cli-2.3.0 spec/command/roles_spec.rb
conjur-cli-2.2.1 spec/command/roles_spec.rb