conjur-api 2.2.3 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/conjur/api.rb +1 -0
- data/lib/conjur/role.rb +20 -7
- data/lib/conjur-api/version.rb +2 -1
- data/spec/lib/role_spec.rb +46 -16
- metadata +4 -4
data/lib/conjur/api.rb
CHANGED
data/lib/conjur/role.rb
CHANGED
@@ -32,17 +32,30 @@ module Conjur
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def grant_to(member,
|
35
|
+
def grant_to(member, *args)
|
36
|
+
if Conjur::API::VERSION < "3.0.0"
|
37
|
+
options = args[-1]
|
38
|
+
if args.length > 1
|
39
|
+
warning = "WARNING: Deprecated arguments to grant_to. Please put admin_option in the options hash."
|
40
|
+
options[:admin_option] = args[0]
|
41
|
+
end
|
42
|
+
|
43
|
+
unless options.nil? || options.is_a?(Hash)
|
44
|
+
warning = "WARNING: Deprecated arguments to grant_to. Please put admin_option in the options hash."
|
45
|
+
options = { admin_option: options }
|
46
|
+
end
|
47
|
+
else
|
48
|
+
raise "Please remove the deprecated API in 3.0 and change the method signature to grant_to(member, options)"
|
49
|
+
end
|
50
|
+
|
36
51
|
log do |logger|
|
52
|
+
logger << warning if warning
|
37
53
|
logger << "Granting role #{identifier} to #{member}"
|
38
|
-
|
39
|
-
logger << " with
|
40
|
-
end
|
41
|
-
unless options.empty?
|
42
|
-
logger << " and extended options #{options.to_json}"
|
54
|
+
unless options.blank?
|
55
|
+
logger << " with options #{options.to_json}"
|
43
56
|
end
|
44
57
|
end
|
45
|
-
self["?members&member=#{query_escape member}
|
58
|
+
self["?members&member=#{query_escape member}"].put(options)
|
46
59
|
end
|
47
60
|
|
48
61
|
def revoke_from(member, options = {})
|
data/lib/conjur-api/version.rb
CHANGED
data/spec/lib/role_spec.rb
CHANGED
@@ -1,27 +1,57 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
shared_examples_for "properties" do
|
4
|
-
subject { role }
|
5
|
-
its(:kind) { should == kind }
|
6
|
-
its(:id) { should == id }
|
7
|
-
end
|
8
|
-
|
9
3
|
describe Conjur::Role do
|
10
4
|
let(:account) { "the-account" }
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
let(:kind) { "test" }
|
6
|
+
let(:role) { Conjur::API.new_from_token({ 'data' => 'the-login' }).role([ account, kind, id ].join(":")) }
|
7
|
+
subject { role }
|
8
|
+
|
9
|
+
describe ".new" do
|
14
10
|
context "with plain id" do
|
15
11
|
let(:id) { "foo" }
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
it_should_behave_like "properties"
|
12
|
+
its(:options) { should == {:headers=>{:authorization=>"Token token=\"eyJkYXRhIjoidGhlLWxvZ2luIn0=\""}, :username=>'the-login'} }
|
13
|
+
its(:kind) { should == kind }
|
14
|
+
its(:id) { should == id }
|
21
15
|
end
|
16
|
+
|
22
17
|
context "with more complex id" do
|
23
18
|
let(:id) { "foo/bar" }
|
24
|
-
|
19
|
+
its(:kind) { should == kind }
|
20
|
+
its(:id) { should == id }
|
25
21
|
end
|
26
22
|
end
|
27
|
-
|
23
|
+
|
24
|
+
let(:id) { "role/id" }
|
25
|
+
|
26
|
+
describe "#grant_to" do
|
27
|
+
it "should take hash as the second argument and put it" do
|
28
|
+
members = double "members request"
|
29
|
+
subject.should_receive(:[]).with('?members&member=other').and_return(members)
|
30
|
+
members.should_receive(:put).with admin_option: true
|
31
|
+
subject.grant_to "other", admin_option: true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "works without arguments" do
|
35
|
+
members = double "members request"
|
36
|
+
subject.should_receive(:[]).with('?members&member=other').and_return(members)
|
37
|
+
members.should_receive(:put).with nil
|
38
|
+
subject.grant_to "other"
|
39
|
+
end
|
40
|
+
|
41
|
+
context deprecated: 'v3' do # remove in 3.0
|
42
|
+
it "should also accept the deprecated argument format with extra options" do
|
43
|
+
members = double "members request"
|
44
|
+
subject.should_receive(:[]).with('?members&member=other').and_return(members)
|
45
|
+
members.should_receive(:put).with admin_option: true, foo: 'bar'
|
46
|
+
subject.grant_to "other", true, foo: 'bar'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should also accept the deprecated argument format without extra options" do
|
50
|
+
members = double "members request"
|
51
|
+
subject.should_receive(:[]).with('?members&member=other').and_return(members)
|
52
|
+
members.should_receive(:put).with admin_option: true, foo: 'bar'
|
53
|
+
subject.grant_to "other", true, foo: 'bar'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjur-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-06-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -208,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
208
|
version: '0'
|
209
209
|
segments:
|
210
210
|
- 0
|
211
|
-
hash: -
|
211
|
+
hash: -1659157987203846410
|
212
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
213
|
none: false
|
214
214
|
requirements:
|
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
segments:
|
219
219
|
- 0
|
220
|
-
hash: -
|
220
|
+
hash: -1659157987203846410
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project:
|
223
223
|
rubygems_version: 1.8.24
|