conjur-api 4.19.1 → 4.20.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Dockerfile +4 -0
- data/Gemfile +1 -0
- data/conjur-api.gemspec +3 -0
- data/jenkins.sh +11 -0
- data/lib/conjur-api/version.rb +2 -2
- data/lib/conjur/acts_as_user.rb +28 -1
- data/lib/conjur/api.rb +3 -0
- data/lib/conjur/api/audit.rb +14 -1
- data/lib/conjur/api/authn.rb +29 -0
- data/lib/conjur/api/host_factories.rb +93 -0
- data/lib/conjur/api/hosts.rb +4 -2
- data/lib/conjur/api/info.rb +126 -0
- data/lib/conjur/api/users.rb +6 -1
- data/lib/conjur/api/variables.rb +24 -0
- data/lib/conjur/cidr.rb +71 -0
- data/lib/conjur/exceptions.rb +4 -0
- data/lib/conjur/host-factory-api.rb +38 -0
- data/lib/conjur/host.rb +21 -2
- data/lib/conjur/host_factory.rb +75 -0
- data/lib/conjur/host_factory_token.rb +63 -0
- data/lib/conjur/resource.rb +1 -1
- data/lib/conjur/user.rb +19 -11
- data/lib/conjur/variable.rb +25 -2
- data/spec/api/authn_spec.rb +13 -0
- data/spec/api/hosts_spec.rb +10 -2
- data/spec/api/info_spec.rb +89 -0
- data/spec/api/users_spec.rb +21 -0
- data/spec/api/variables_spec.rb +47 -16
- data/spec/cidr_helper.rb +24 -0
- data/spec/lib/acts_as_user_spec.rb +27 -0
- data/spec/lib/api_spec.rb +4 -4
- data/spec/lib/audit_spec.rb +49 -0
- data/spec/lib/cidr_spec.rb +34 -0
- data/spec/lib/configuration_spec.rb +6 -4
- data/spec/lib/host_spec.rb +11 -1
- data/spec/lib/user_spec.rb +18 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/standard_methods_helper.rb +13 -4
- data/spec/variable_spec.rb +32 -0
- metadata +68 -3
data/spec/lib/user_spec.rb
CHANGED
@@ -34,9 +34,13 @@ describe Conjur::User do
|
|
34
34
|
subject { super().options }
|
35
35
|
it { is_expected.to match(hash_including credentials) }
|
36
36
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
|
38
|
+
describe '#roleid' do
|
39
|
+
it "gets account name from server info" do
|
40
|
+
allow(Conjur::Core::API).to receive_messages conjur_account: 'test-account'
|
41
|
+
expect(subject.roleid).to eq "test-account:user:#{login}"
|
42
|
+
end
|
43
|
+
end
|
40
44
|
end
|
41
45
|
it "connects to a Resource" do
|
42
46
|
require 'conjur/resource'
|
@@ -59,4 +63,15 @@ describe Conjur::User do
|
|
59
63
|
user.role
|
60
64
|
end
|
61
65
|
end
|
66
|
+
|
67
|
+
describe '#update', api: :dummy do
|
68
|
+
subject(:user) { api.user username }
|
69
|
+
it "calls set_cidr_restrictions if given CIDR" do
|
70
|
+
expect(user).to receive(:set_cidr_restrictions).with(['192.0.2.0/24'])
|
71
|
+
user.update cidr: ['192.0.2.0/24']
|
72
|
+
|
73
|
+
expect(user).to_not receive(:set_cidr_restrictions)
|
74
|
+
user.update foo: 42
|
75
|
+
end
|
76
|
+
end
|
62
77
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -102,11 +102,13 @@ shared_context api: :dummy do
|
|
102
102
|
let(:api){ Conjur::API.new_from_key username, 'key' }
|
103
103
|
let(:authz_host) { 'http://authz.example.com' }
|
104
104
|
let(:audit_host) { 'http://audit.example.com' }
|
105
|
+
let(:authn_host) { 'http://authn.example.com' }
|
105
106
|
let(:credentials) { { headers: { authorization: "Token token=\"stub\"" } } } #, username: username } }
|
106
107
|
let(:core_host) { 'http://core.example.com' }
|
107
108
|
let(:account) { 'the-account' }
|
108
109
|
|
109
110
|
before do
|
111
|
+
allow(Conjur::Authn::API).to receive_messages host: authn_host
|
110
112
|
allow(Conjur::Authz::API).to receive_messages host: authz_host
|
111
113
|
allow(Conjur::Core::API).to receive_messages host: core_host
|
112
114
|
allow(Conjur::Core::API).to receive_messages conjur_account: account
|
@@ -1,15 +1,24 @@
|
|
1
1
|
require 'helpers/request_helpers'
|
2
2
|
shared_context api: :dummy do
|
3
3
|
include RequestHelpers
|
4
|
+
|
5
|
+
RSpec::Matchers.define :call_standard_create_with do |type, id, options|
|
6
|
+
match do |block|
|
7
|
+
expect(subject).to receive(:standard_create).with(
|
8
|
+
core_host, type, id, options
|
9
|
+
).and_return :response
|
10
|
+
expect(block[]).to eq(:response)
|
11
|
+
end
|
12
|
+
|
13
|
+
supports_block_expectations
|
14
|
+
end
|
15
|
+
|
4
16
|
subject { api }
|
5
17
|
end
|
6
18
|
|
7
19
|
shared_examples_for 'standard_create with' do |type, id, options|
|
8
20
|
it "calls through to standard_create" do
|
9
|
-
expect
|
10
|
-
core_host, type, id, options
|
11
|
-
).and_return :response
|
12
|
-
expect(invoke).to eq(:response)
|
21
|
+
expect { invoke }.to call_standard_create_with type, id, options
|
13
22
|
end
|
14
23
|
end
|
15
24
|
|
data/spec/variable_spec.rb
CHANGED
@@ -45,4 +45,36 @@ describe Conjur::Variable do
|
|
45
45
|
expect(subject.value(42)).to eq("the-value")
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
describe '#expire' do
|
50
|
+
context 'when duration is a number of seconds' do
|
51
|
+
let (:expiration) { 2.weeks }
|
52
|
+
it 'posts the expiration' do
|
53
|
+
expect_request(
|
54
|
+
:method => :post,
|
55
|
+
:url => "#{url}/expiration",
|
56
|
+
:payload => { :duration => "PT#{expiration.to_i}S" },
|
57
|
+
:headers => {}
|
58
|
+
).and_return(double('response', :body => '{}'))
|
59
|
+
|
60
|
+
subject.expires_in expiration
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when duration is an ISO8601 duration' do
|
65
|
+
let (:expiration) { "P2W" }
|
66
|
+
it 'posts the expiration' do
|
67
|
+
expect_request(
|
68
|
+
:method => :post,
|
69
|
+
:url => "#{url}/expiration",
|
70
|
+
:payload => { :duration => "P2W" },
|
71
|
+
:headers => {}
|
72
|
+
).and_return(double('response', :body => '{}'))
|
73
|
+
|
74
|
+
subject.expires_in expiration
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
48
80
|
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: 4.
|
4
|
+
version: 4.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafal Rzepecki
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -45,6 +45,20 @@ dependencies:
|
|
45
45
|
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: semantic
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
48
62
|
- !ruby/object:Gem::Dependency
|
49
63
|
name: rake
|
50
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,6 +101,20 @@ dependencies:
|
|
87
101
|
- - ~>
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '3'
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rspec-expectations
|
106
|
+
requirement: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.4'
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.4'
|
90
118
|
- !ruby/object:Gem::Dependency
|
91
119
|
name: webmock
|
92
120
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,6 +227,26 @@ dependencies:
|
|
199
227
|
- - '>='
|
200
228
|
- !ruby/object:Gem::Version
|
201
229
|
version: '0'
|
230
|
+
- !ruby/object:Gem::Dependency
|
231
|
+
name: tins
|
232
|
+
requirement: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ~>
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '1.6'
|
237
|
+
- - <
|
238
|
+
- !ruby/object:Gem::Version
|
239
|
+
version: 1.7.0
|
240
|
+
type: :development
|
241
|
+
prerelease: false
|
242
|
+
version_requirements: !ruby/object:Gem::Requirement
|
243
|
+
requirements:
|
244
|
+
- - ~>
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: '1.6'
|
247
|
+
- - <
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: 1.7.0
|
202
250
|
- !ruby/object:Gem::Dependency
|
203
251
|
name: inch
|
204
252
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,6 +274,7 @@ files:
|
|
226
274
|
- .project
|
227
275
|
- .yardopts
|
228
276
|
- CHANGELOG.md
|
277
|
+
- Dockerfile
|
229
278
|
- Gemfile
|
230
279
|
- LICENSE
|
231
280
|
- README.md
|
@@ -235,6 +284,7 @@ files:
|
|
235
284
|
- features/login.feature
|
236
285
|
- features/ping_as_server.feature
|
237
286
|
- features/ping_as_user.feature
|
287
|
+
- jenkins.sh
|
238
288
|
- lib/conjur-api.rb
|
239
289
|
- lib/conjur-api/version.rb
|
240
290
|
- lib/conjur/acts_as_asset.rb
|
@@ -247,7 +297,9 @@ files:
|
|
247
297
|
- lib/conjur/api/authn.rb
|
248
298
|
- lib/conjur/api/deputies.rb
|
249
299
|
- lib/conjur/api/groups.rb
|
300
|
+
- lib/conjur/api/host_factories.rb
|
250
301
|
- lib/conjur/api/hosts.rb
|
302
|
+
- lib/conjur/api/info.rb
|
251
303
|
- lib/conjur/api/layers.rb
|
252
304
|
- lib/conjur/api/pubkeys.rb
|
253
305
|
- lib/conjur/api/resources.rb
|
@@ -262,12 +314,14 @@ files:
|
|
262
314
|
- lib/conjur/build_from_response.rb
|
263
315
|
- lib/conjur/cast.rb
|
264
316
|
- lib/conjur/cert_utils.rb
|
317
|
+
- lib/conjur/cidr.rb
|
265
318
|
- lib/conjur/configuration.rb
|
266
319
|
- lib/conjur/core-api.rb
|
267
320
|
- lib/conjur/deputy.rb
|
268
321
|
- lib/conjur/env.rb
|
269
322
|
- lib/conjur/escape.rb
|
270
323
|
- lib/conjur/event_source.rb
|
324
|
+
- lib/conjur/exceptions.rb
|
271
325
|
- lib/conjur/exists.rb
|
272
326
|
- lib/conjur/graph.rb
|
273
327
|
- lib/conjur/group.rb
|
@@ -275,7 +329,10 @@ files:
|
|
275
329
|
- lib/conjur/has_id.rb
|
276
330
|
- lib/conjur/has_identifier.rb
|
277
331
|
- lib/conjur/has_owner.rb
|
332
|
+
- lib/conjur/host-factory-api.rb
|
278
333
|
- lib/conjur/host.rb
|
334
|
+
- lib/conjur/host_factory.rb
|
335
|
+
- lib/conjur/host_factory_token.rb
|
279
336
|
- lib/conjur/layer-api.rb
|
280
337
|
- lib/conjur/layer.rb
|
281
338
|
- lib/conjur/log.rb
|
@@ -294,6 +351,7 @@ files:
|
|
294
351
|
- spec/api/graph_spec.rb
|
295
352
|
- spec/api/groups_spec.rb
|
296
353
|
- spec/api/hosts_spec.rb
|
354
|
+
- spec/api/info_spec.rb
|
297
355
|
- spec/api/layer_spec.rb
|
298
356
|
- spec/api/pubkeys_spec.rb
|
299
357
|
- spec/api/resources_spec.rb
|
@@ -302,14 +360,17 @@ files:
|
|
302
360
|
- spec/api/users_spec.rb
|
303
361
|
- spec/api/variables_spec.rb
|
304
362
|
- spec/cas_rest_client.rb
|
363
|
+
- spec/cidr_helper.rb
|
305
364
|
- spec/helpers/errors_matcher.rb
|
306
365
|
- spec/helpers/request_helpers.rb
|
366
|
+
- spec/lib/acts_as_user_spec.rb
|
307
367
|
- spec/lib/annotations_spec.rb
|
308
368
|
- spec/lib/api_spec.rb
|
309
369
|
- spec/lib/asset_spec.rb
|
310
370
|
- spec/lib/audit_spec.rb
|
311
371
|
- spec/lib/build_from_response_spec.rb
|
312
372
|
- spec/lib/cert_utils_spec.rb
|
373
|
+
- spec/lib/cidr_spec.rb
|
313
374
|
- spec/lib/configuration_spec.rb
|
314
375
|
- spec/lib/deputy_spec.rb
|
315
376
|
- spec/lib/exists_spec.rb
|
@@ -350,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
350
411
|
version: '0'
|
351
412
|
requirements: []
|
352
413
|
rubyforge_project:
|
353
|
-
rubygems_version: 2.0.14
|
414
|
+
rubygems_version: 2.0.14.1
|
354
415
|
signing_key:
|
355
416
|
specification_version: 4
|
356
417
|
summary: Conjur API
|
@@ -363,6 +424,7 @@ test_files:
|
|
363
424
|
- spec/api/graph_spec.rb
|
364
425
|
- spec/api/groups_spec.rb
|
365
426
|
- spec/api/hosts_spec.rb
|
427
|
+
- spec/api/info_spec.rb
|
366
428
|
- spec/api/layer_spec.rb
|
367
429
|
- spec/api/pubkeys_spec.rb
|
368
430
|
- spec/api/resources_spec.rb
|
@@ -371,14 +433,17 @@ test_files:
|
|
371
433
|
- spec/api/users_spec.rb
|
372
434
|
- spec/api/variables_spec.rb
|
373
435
|
- spec/cas_rest_client.rb
|
436
|
+
- spec/cidr_helper.rb
|
374
437
|
- spec/helpers/errors_matcher.rb
|
375
438
|
- spec/helpers/request_helpers.rb
|
439
|
+
- spec/lib/acts_as_user_spec.rb
|
376
440
|
- spec/lib/annotations_spec.rb
|
377
441
|
- spec/lib/api_spec.rb
|
378
442
|
- spec/lib/asset_spec.rb
|
379
443
|
- spec/lib/audit_spec.rb
|
380
444
|
- spec/lib/build_from_response_spec.rb
|
381
445
|
- spec/lib/cert_utils_spec.rb
|
446
|
+
- spec/lib/cidr_spec.rb
|
382
447
|
- spec/lib/configuration_spec.rb
|
383
448
|
- spec/lib/deputy_spec.rb
|
384
449
|
- spec/lib/exists_spec.rb
|