conjur-cli 2.4.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/conjur.gemspec +2 -1
- data/lib/conjur/command/hosts.rb +1 -1
- data/lib/conjur/command/resources.rb +20 -8
- data/lib/conjur/command/variables.rb +12 -1
- data/lib/conjur/version.rb +1 -1
- data/spec/command/hosts_spec.rb +30 -0
- data/spec/command/resources_spec.rb +23 -0
- data/spec/command/roles_spec.rb +1 -1
- data/spec/command/variables_spec.rb +32 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/write_expectation.rb +1 -0
- metadata +13 -6
data/LICENSE
CHANGED
data/conjur.gemspec
CHANGED
@@ -3,9 +3,10 @@ require File.expand_path('../lib/conjur/version', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Rafa\305\202 Rzepecki", "Kevin Gilpin"]
|
6
|
-
gem.email = ["divided.mind@gmail.com", "
|
6
|
+
gem.email = ["divided.mind@gmail.com", "kgilpin@conjur.net",]
|
7
7
|
gem.summary = %q{Conjur command line interface}
|
8
8
|
gem.homepage = "https://github.com/inscitiv/cli-ruby"
|
9
|
+
gem.license = 'MIT'
|
9
10
|
|
10
11
|
gem.files = `git ls-files`.split($\) + Dir['build_number']
|
11
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/lib/conjur/command/hosts.rb
CHANGED
@@ -70,17 +70,29 @@ class Conjur::Command::Resources < Conjur::Command
|
|
70
70
|
puts "Permission revoked"
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
74
|
-
desc "Check
|
75
|
-
|
73
|
+
|
74
|
+
desc "Check for a privilege on a resource"
|
75
|
+
long_desc """
|
76
|
+
By default, the privilege is checked for the logged-in user.
|
77
|
+
Permission checks may be performed for other roles using the optional role argument.
|
78
|
+
When the role argument is used, either the logged-in user must either own the specified
|
79
|
+
resource or be an admin of the specified role (i.e. be granted the specified role with grant option).
|
80
|
+
"""
|
81
|
+
arg_name "kind resource-id privilege"
|
76
82
|
command :check do |c|
|
83
|
+
c.desc "Role to check. By default, the current logged-in role is used"
|
84
|
+
c.flag [:r,:role]
|
85
|
+
|
77
86
|
c.action do |global_options,options,args|
|
78
87
|
kind = args.shift or raise "Missing parameter: resource-kind"
|
79
88
|
resource_id = args.shift or raise "Missing parameter: resource-id"
|
80
|
-
role = args.shift or raise "Missing parameter: role"
|
81
89
|
privilege = args.shift or raise "Missing parameter: privilege"
|
82
|
-
role =
|
83
|
-
|
90
|
+
if role = options[:role]
|
91
|
+
role = api.role(role)
|
92
|
+
puts role.permitted? kind, resource_id, privilege
|
93
|
+
else
|
94
|
+
puts api.resource([ conjur_account, kind, resource_id ].join(':')).permitted? privilege
|
95
|
+
end
|
84
96
|
end
|
85
97
|
end
|
86
98
|
|
@@ -92,11 +104,11 @@ class Conjur::Command::Resources < Conjur::Command
|
|
92
104
|
id = require_arg(args, "resource-id")
|
93
105
|
owner = require_arg(args, "owner")
|
94
106
|
api.resource([ conjur_account, kind, id ].join(':')).give_to owner
|
95
|
-
puts "
|
107
|
+
puts "Ownership granted"
|
96
108
|
end
|
97
109
|
end
|
98
110
|
|
99
|
-
desc "List roles with a specified permission on
|
111
|
+
desc "List roles with a specified permission on a resource"
|
100
112
|
arg_name "kind resource-id permission"
|
101
113
|
command :permitted_roles do |c|
|
102
114
|
c.action do |global_options,options,args|
|
@@ -5,6 +5,7 @@ class Conjur::Command::Variables < Conjur::Command
|
|
5
5
|
self.prefix = :variable
|
6
6
|
|
7
7
|
desc "Create and store a variable"
|
8
|
+
arg_name "id?"
|
8
9
|
command :create do |c|
|
9
10
|
c.arg_name "mime_type"
|
10
11
|
c.flag [:m, :"mime-type"]
|
@@ -15,7 +16,16 @@ class Conjur::Command::Variables < Conjur::Command
|
|
15
16
|
acting_as_option(c)
|
16
17
|
|
17
18
|
c.action do |global_options,options,args|
|
18
|
-
|
19
|
+
id = args.shift
|
20
|
+
options[:id] = id if id
|
21
|
+
|
22
|
+
mime_type = options.delete(:m)
|
23
|
+
kind = options.delete(:k)
|
24
|
+
|
25
|
+
options.delete(:"mime-type")
|
26
|
+
options.delete(:"kind")
|
27
|
+
|
28
|
+
var = api.create_variable(mime_type, kind, options)
|
19
29
|
display(var, options)
|
20
30
|
end
|
21
31
|
end
|
@@ -37,6 +47,7 @@ class Conjur::Command::Variables < Conjur::Command
|
|
37
47
|
value = args.shift || STDIN.read
|
38
48
|
|
39
49
|
api.variable(id).add_value(value)
|
50
|
+
puts "Value added"
|
40
51
|
end
|
41
52
|
end
|
42
53
|
|
data/lib/conjur/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Conjur::Command::Hosts, logged_in: true do
|
4
|
+
let(:collection_url) { "https://core.example.com/hosts" }
|
5
|
+
|
6
|
+
describe_command "host:create" do
|
7
|
+
it "lets the server assign the id" do
|
8
|
+
RestClient::Request.should_receive(:execute).with(
|
9
|
+
method: :post,
|
10
|
+
url: collection_url,
|
11
|
+
headers: {},
|
12
|
+
payload: {}
|
13
|
+
).and_return(post_response('assigned-id'))
|
14
|
+
|
15
|
+
expect { invoke }.to write({ id: 'assigned-id' }).to(:stdout)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
describe_command "host:create the-id" do
|
19
|
+
it "propagates the user-assigned id" do
|
20
|
+
RestClient::Request.should_receive(:execute).with(
|
21
|
+
method: :post,
|
22
|
+
url: collection_url,
|
23
|
+
headers: {},
|
24
|
+
payload: { id: 'the-id' }
|
25
|
+
).and_return(post_response('the-id'))
|
26
|
+
|
27
|
+
expect { invoke }.to write({ id: 'the-id' }).to(:stdout)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Conjur::Command::Resources, logged_in: true do
|
4
|
+
|
5
|
+
describe_command "resource:check food bacon fry" do
|
6
|
+
it "performs a permission check for the logged-in user" do
|
7
|
+
api.should_receive(:resource).with("the-account:food:bacon").and_return bacon = double("the-account:food:bacon")
|
8
|
+
bacon.should_receive(:permitted?).with("fry")
|
9
|
+
|
10
|
+
invoke
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe_command "resource:check -r test:the-role food bacon fry" do
|
15
|
+
it "performs a permission check for a specified role" do
|
16
|
+
api.should_receive(:role).with("test:the-role").and_return role = double("the-account:test:the-role")
|
17
|
+
|
18
|
+
role.should_receive(:permitted?).with("food", "bacon", "fry")
|
19
|
+
|
20
|
+
invoke
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/command/roles_spec.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Conjur::Command::Variables, logged_in: true do
|
4
|
+
let(:collection_url) { "https://core.example.com/variables" }
|
5
|
+
|
6
|
+
let(:base_payload) { { mime_type: 'text/plain', kind: 'password' } }
|
7
|
+
|
8
|
+
describe_command "variable:create -m text/plain -k password" do
|
9
|
+
it "lets the server assign the id" do
|
10
|
+
RestClient::Request.should_receive(:execute).with(
|
11
|
+
method: :post,
|
12
|
+
url: collection_url,
|
13
|
+
headers: {},
|
14
|
+
payload: base_payload
|
15
|
+
).and_return(post_response('assigned-id'))
|
16
|
+
|
17
|
+
expect { invoke }.to write({ id: 'assigned-id' }).to(:stdout)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
describe_command "variable:create -m text/plain -k password the-id" do
|
21
|
+
it "propagates the user-assigned id" do
|
22
|
+
RestClient::Request.should_receive(:execute).with(
|
23
|
+
method: :post,
|
24
|
+
url: collection_url,
|
25
|
+
headers: {},
|
26
|
+
payload: base_payload.merge({ id: 'the-id' })
|
27
|
+
).and_return(post_response('the-id'))
|
28
|
+
|
29
|
+
expect { invoke }.to write({ id: 'the-id' }).to(:stdout)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "bundler/setup"
|
3
3
|
require 'tempfile'
|
4
|
+
require 'ostruct'
|
4
5
|
|
5
6
|
require "simplecov"
|
6
7
|
SimpleCov.start
|
@@ -59,6 +60,16 @@ shared_context "when not logged in", logged_in: false do
|
|
59
60
|
include_context "with mock authn"
|
60
61
|
end
|
61
62
|
|
63
|
+
|
64
|
+
def post_response(id, attributes = {})
|
65
|
+
attributes[:id] = id
|
66
|
+
|
67
|
+
OpenStruct.new({
|
68
|
+
headers: { location: [ collection_url, id ].join('/') },
|
69
|
+
body: attributes.to_json
|
70
|
+
})
|
71
|
+
end
|
72
|
+
|
62
73
|
require 'write_expectation'
|
63
74
|
|
64
75
|
require 'conjur/cli'
|
data/spec/write_expectation.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjur-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
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-08-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: conjur-api
|
@@ -191,7 +191,7 @@ dependencies:
|
|
191
191
|
description:
|
192
192
|
email:
|
193
193
|
- divided.mind@gmail.com
|
194
|
-
-
|
194
|
+
- kgilpin@conjur.net
|
195
195
|
executables:
|
196
196
|
- conjur
|
197
197
|
- jsonfield
|
@@ -229,11 +229,15 @@ files:
|
|
229
229
|
- lib/conjur/version.rb
|
230
230
|
- spec/command/authn_spec.rb
|
231
231
|
- spec/command/groups_spec.rb
|
232
|
+
- spec/command/hosts_spec.rb
|
233
|
+
- spec/command/resources_spec.rb
|
232
234
|
- spec/command/roles_spec.rb
|
235
|
+
- spec/command/variables_spec.rb
|
233
236
|
- spec/spec_helper.rb
|
234
237
|
- spec/write_expectation.rb
|
235
238
|
homepage: https://github.com/inscitiv/cli-ruby
|
236
|
-
licenses:
|
239
|
+
licenses:
|
240
|
+
- MIT
|
237
241
|
post_install_message:
|
238
242
|
rdoc_options: []
|
239
243
|
require_paths:
|
@@ -246,7 +250,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
246
250
|
version: '0'
|
247
251
|
segments:
|
248
252
|
- 0
|
249
|
-
hash: -
|
253
|
+
hash: -4082547880357174583
|
250
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
251
255
|
none: false
|
252
256
|
requirements:
|
@@ -255,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
259
|
version: '0'
|
256
260
|
segments:
|
257
261
|
- 0
|
258
|
-
hash: -
|
262
|
+
hash: -4082547880357174583
|
259
263
|
requirements: []
|
260
264
|
rubyforge_project:
|
261
265
|
rubygems_version: 1.8.25
|
@@ -267,6 +271,9 @@ test_files:
|
|
267
271
|
- features/support/env.rb
|
268
272
|
- spec/command/authn_spec.rb
|
269
273
|
- spec/command/groups_spec.rb
|
274
|
+
- spec/command/hosts_spec.rb
|
275
|
+
- spec/command/resources_spec.rb
|
270
276
|
- spec/command/roles_spec.rb
|
277
|
+
- spec/command/variables_spec.rb
|
271
278
|
- spec/spec_helper.rb
|
272
279
|
- spec/write_expectation.rb
|