conjur-api 4.31.0 → 5.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +1 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +22 -3
  5. data/Dockerfile +12 -3
  6. data/Gemfile +3 -3
  7. data/Jenkinsfile +69 -0
  8. data/LICENSE.md +195 -0
  9. data/README.md +16 -0
  10. data/Rakefile +34 -18
  11. data/ci/wait_for_server.sh +10 -0
  12. data/conjur-api.gemspec +6 -14
  13. data/dev/docker-compose.yml +23 -0
  14. data/dev/empty.yml +2 -0
  15. data/dev/start.sh +15 -0
  16. data/dev/stop.sh +6 -0
  17. data/docker-compose.yml +27 -0
  18. data/features/exists.feature +37 -0
  19. data/features/group.feature +11 -0
  20. data/features/host.feature +20 -0
  21. data/features/host_factory_create_host.feature +28 -0
  22. data/features/host_factory_token.feature +63 -0
  23. data/features/load_policy.feature +61 -0
  24. data/features/members.feature +51 -0
  25. data/features/new_api.feature +36 -0
  26. data/features/permitted.feature +43 -0
  27. data/features/permitted_roles.feature +30 -0
  28. data/features/public_keys.feature +11 -0
  29. data/features/resource_fields.feature +53 -0
  30. data/features/role_fields.feature +15 -0
  31. data/features/rotate_api_key.feature +13 -0
  32. data/features/step_definitions/api_steps.rb +4 -54
  33. data/features/step_definitions/policy_steps.rb +35 -0
  34. data/features/step_definitions/result_steps.rb +7 -0
  35. data/features/support/env.rb +14 -5
  36. data/features/support/hooks.rb +3 -0
  37. data/features/support/world.rb +5 -6
  38. data/features/update_password.feature +14 -0
  39. data/features/user.feature +17 -0
  40. data/features/variable_fields.feature +20 -0
  41. data/features/variable_value.feature +67 -0
  42. data/lib/conjur/acts_as_resource.rb +95 -65
  43. data/lib/conjur/acts_as_role.rb +102 -51
  44. data/lib/conjur/{audit-api.rb → acts_as_rolsource.rb} +10 -14
  45. data/lib/conjur/acts_as_user.rb +13 -22
  46. data/lib/conjur/api/authn.rb +37 -72
  47. data/lib/conjur/api/host_factories.rb +35 -55
  48. data/lib/conjur/api/policies.rb +56 -0
  49. data/lib/conjur/api/pubkeys.rb +36 -160
  50. data/lib/conjur/api/resources.rb +32 -116
  51. data/lib/conjur/api/roles.rb +28 -105
  52. data/lib/conjur/api/variables.rb +22 -91
  53. data/lib/conjur/api.rb +19 -46
  54. data/lib/conjur/base.rb +21 -132
  55. data/lib/conjur/base_object.rb +57 -0
  56. data/lib/conjur/{authn-api.rb → build_object.rb} +23 -11
  57. data/lib/conjur/cast.rb +12 -17
  58. data/lib/conjur/cert_utils.rb +1 -1
  59. data/lib/conjur/cidr.rb +1 -1
  60. data/lib/conjur/configuration.rb +13 -91
  61. data/lib/conjur/escape.rb +1 -2
  62. data/lib/conjur/group.rb +9 -65
  63. data/lib/conjur/has_attributes.rb +22 -59
  64. data/lib/conjur/host.rb +5 -35
  65. data/lib/conjur/host_factory.rb +40 -40
  66. data/lib/conjur/host_factory_token.rb +38 -23
  67. data/lib/conjur/id.rb +63 -0
  68. data/lib/conjur/layer.rb +5 -80
  69. data/lib/conjur/log.rb +1 -1
  70. data/lib/conjur/log_source.rb +1 -1
  71. data/lib/conjur/{secret.rb → policy.rb} +11 -14
  72. data/lib/conjur/{api/secrets.rb → policy_load_result.rb} +35 -22
  73. data/lib/conjur/query_string.rb +2 -1
  74. data/lib/conjur/resource.rb +5 -299
  75. data/lib/conjur/role.rb +5 -317
  76. data/lib/conjur/role_grant.rb +20 -28
  77. data/lib/conjur/user.rb +5 -63
  78. data/lib/conjur/variable.rb +31 -76
  79. data/lib/conjur/{authz-api.rb → webservice.rb} +8 -16
  80. data/lib/conjur-api/version.rb +2 -2
  81. data/publish.sh +7 -0
  82. data/spec/api_spec.rb +208 -0
  83. data/spec/cast_spec.rb +21 -0
  84. data/spec/{lib/cert_utils_spec.rb → cert_utils_spec.rb} +0 -0
  85. data/spec/{lib/cidr_spec.rb → cidr_spec.rb} +0 -0
  86. data/spec/{lib/configuration_spec.rb → configuration_spec.rb} +40 -140
  87. data/spec/{lib/has_attributes_spec.rb → has_attributes_spec.rb} +6 -2
  88. data/spec/{lib/log_source_spec.rb → log_source_spec.rb} +0 -0
  89. data/spec/{lib/log_spec.rb → log_spec.rb} +0 -0
  90. data/spec/roles_spec.rb +24 -0
  91. data/spec/spec_helper.rb +63 -78
  92. data/spec/ssl_spec.rb +3 -5
  93. data/spec/vendor/rest_client_spec.rb +0 -54
  94. data/test.sh +40 -0
  95. metadata +122 -281
  96. data/.kateproject +0 -5
  97. data/LICENSE +0 -22
  98. data/ci/test.sh +0 -9
  99. data/features/audit_resources.feature +0 -15
  100. data/features/audit_roles.feature +0 -15
  101. data/features/bootstrap.feature +0 -31
  102. data/features/step_definitions/cli_steps.rb +0 -5
  103. data/jenkins.sh +0 -27
  104. data/lib/conjur/acts_as_asset.rb +0 -88
  105. data/lib/conjur/annotations.rb +0 -186
  106. data/lib/conjur/api/audit.rb +0 -138
  107. data/lib/conjur/api/deputies.rb +0 -57
  108. data/lib/conjur/api/groups.rb +0 -111
  109. data/lib/conjur/api/hosts.rb +0 -109
  110. data/lib/conjur/api/info.rb +0 -126
  111. data/lib/conjur/api/layers.rb +0 -62
  112. data/lib/conjur/api/ldapsync.rb +0 -115
  113. data/lib/conjur/api/users.rb +0 -106
  114. data/lib/conjur/bootstrap.rb +0 -161
  115. data/lib/conjur/build_from_response.rb +0 -49
  116. data/lib/conjur/core-api.rb +0 -74
  117. data/lib/conjur/deputy.rb +0 -55
  118. data/lib/conjur/env.rb +0 -54
  119. data/lib/conjur/event_source.rb +0 -101
  120. data/lib/conjur/exists.rb +0 -60
  121. data/lib/conjur/graph.rb +0 -295
  122. data/lib/conjur/has_id.rb +0 -43
  123. data/lib/conjur/has_identifier.rb +0 -36
  124. data/lib/conjur/has_owner.rb +0 -51
  125. data/lib/conjur/host-factory-api.rb +0 -38
  126. data/lib/conjur/layer-api.rb +0 -13
  127. data/lib/conjur/ldap_sync_job.rb +0 -89
  128. data/lib/conjur/path_based.rb +0 -86
  129. data/lib/conjur/pubkeys-api.rb +0 -50
  130. data/lib/conjur/standard_methods.rb +0 -91
  131. data/reqspeed.rb +0 -20
  132. data/spec/api/authn_spec.rb +0 -81
  133. data/spec/api/graph_spec.rb +0 -117
  134. data/spec/api/groups_spec.rb +0 -40
  135. data/spec/api/hosts_spec.rb +0 -36
  136. data/spec/api/info_spec.rb +0 -89
  137. data/spec/api/layer_spec.rb +0 -18
  138. data/spec/api/ldapsync_spec.rb +0 -44
  139. data/spec/api/pubkeys_spec.rb +0 -66
  140. data/spec/api/resources_spec.rb +0 -92
  141. data/spec/api/roles_spec.rb +0 -100
  142. data/spec/api/secrets_spec.rb +0 -16
  143. data/spec/api/users_spec.rb +0 -71
  144. data/spec/api/variables_spec.rb +0 -112
  145. data/spec/cas_rest_client.rb +0 -17
  146. data/spec/cidr_helper.rb +0 -24
  147. data/spec/lib/acts_as_user_spec.rb +0 -27
  148. data/spec/lib/annotations_spec.rb +0 -109
  149. data/spec/lib/api_spec.rb +0 -480
  150. data/spec/lib/asset_spec.rb +0 -80
  151. data/spec/lib/audit_spec.rb +0 -155
  152. data/spec/lib/build_from_response_spec.rb +0 -49
  153. data/spec/lib/deputy_spec.rb +0 -25
  154. data/spec/lib/exists_spec.rb +0 -24
  155. data/spec/lib/group_spec.rb +0 -18
  156. data/spec/lib/host_spec.rb +0 -31
  157. data/spec/lib/resource_spec.rb +0 -240
  158. data/spec/lib/role_grant_spec.rb +0 -13
  159. data/spec/lib/role_spec.rb +0 -231
  160. data/spec/lib/standard_methods_spec.rb +0 -66
  161. data/spec/lib/user_spec.rb +0 -77
  162. data/spec/standard_methods_helper.rb +0 -41
  163. data/spec/variable_spec.rb +0 -101
  164. data/spec/vcr_cassettes/Conjur_Resource/_create/with_path-like_identifier.yml +0 -87
  165. data/spec/vcr_cassettes/Conjur_Resource/_create/with_un-encoded_path-like_identifier.yml +0 -87
  166. data/spec/vcr_cassettes/Conjur_Resource/_create/with_uuid_identifier.yml +0 -87
@@ -1,231 +0,0 @@
1
- require 'spec_helper'
2
- require 'standard_methods_helper'
3
-
4
- describe Conjur::Role, api: :dummy do
5
- let(:account) { "the-account" }
6
- let(:kind) { "test" }
7
- let(:url) { "#{authz_host}/#{account}/roles/#{kind}/#{id}" }
8
- let(:role) { Conjur::Role.new url }
9
- subject { role }
10
-
11
- describe ".new" do
12
- context "with plain id" do
13
- let(:id) { "foo" }
14
-
15
- describe '#options' do
16
- subject { super().options }
17
- it {}
18
- end
19
-
20
- describe '#kind' do
21
- subject { super().kind }
22
- it { is_expected.to eq(kind) }
23
- end
24
-
25
- describe '#id' do
26
- subject { super().id }
27
- it { is_expected.to eq(id) }
28
- end
29
- end
30
-
31
- context "with more complex id" do
32
- let(:id) { "foo/bar" }
33
-
34
- describe '#kind' do
35
- subject { super().kind }
36
- it { is_expected.to eq(kind) }
37
- end
38
-
39
- describe '#id' do
40
- subject { super().id }
41
- it { is_expected.to eq(id) }
42
- end
43
- end
44
- end
45
-
46
- let(:id) { "role/id" }
47
-
48
- describe "#grant_to" do
49
- it "should take hash as the second argument and put it" do
50
- members = double "members request"
51
- expect(subject).to receive(:[]).with('?members&member=other').and_return(members)
52
- expect(members).to receive(:put).with admin_option: true
53
- subject.grant_to "other", admin_option: true
54
- end
55
-
56
- it "works without arguments" do
57
- members = double "members request"
58
- expect(subject).to receive(:[]).with('?members&member=other').and_return(members)
59
- expect(members).to receive(:put).with({})
60
- subject.grant_to "other"
61
- end
62
-
63
- it "converts an object to roleid" do
64
- members = double "members request"
65
- expect(subject).to receive(:[]).with('?members&member=other').and_return(members)
66
- expect(members).to receive(:put).with({})
67
- require 'ostruct'
68
- subject.grant_to OpenStruct.new(roleid: "other")
69
- end
70
-
71
- it "converts an Array to roleid" do
72
- members = double "members request"
73
- expect(subject).to receive(:[]).with('?members&member=other').and_return(members)
74
- expect(members).to receive(:put).with({})
75
- subject.grant_to %w(other)
76
- end
77
- end
78
-
79
- describe '#create' do
80
- it 'simply puts' do
81
- expect_request(
82
- method: :put,
83
- url: url,
84
- payload: {},
85
- headers: {}
86
- )
87
- role.create
88
- end
89
- end
90
-
91
- describe '#all' do
92
- it 'returns roles for ids got from ?all' do
93
- roles = ['foo:k:bar', 'baz:k:xyzzy']
94
- expect_request(
95
- method: :get,
96
- url: role.url + "/?all=true",
97
- headers: {}
98
- ).and_return roles.to_json
99
- all = role.all
100
- expect(all[0].account).to eq('foo')
101
- expect(all[0].id).to eq('bar')
102
- expect(all[1].account).to eq('baz')
103
- expect(all[1].id).to eq('xyzzy')
104
- end
105
-
106
- it "handles 'count' parameter" do
107
- expect_request(
108
- method: :get,
109
- url: role.url + "/?all=true&count=true",
110
- headers: {}
111
- ).and_return({count: 12}.to_json)
112
- expect(role.all(count: true)).to eq(12)
113
- end
114
-
115
- describe "direct memberships" do
116
- it 'routes to ?memberships' do
117
- expect_request(
118
- method: :get,
119
- url: role.url + "/?memberships=true",
120
- headers: {}
121
- ).and_return("[]")
122
- role.all(recursive: false)
123
- end
124
- end
125
-
126
- describe "filter param" do
127
- it "applies #cast to the filter" do
128
- filter = %w(foo bar)
129
- filter.each{ |e| expect(subject).to receive(:cast).with(e, :roleid).and_return e }
130
- allow(RestClient::Request).to receive_messages execute: [].to_json
131
- role.all filter: filter
132
- end
133
-
134
- def self.it_passes_the_filter_as(query_string)
135
- it "calls ?all&#{query_string}" do
136
- expect_request(
137
- method: :get,
138
- url: role.url + "/?all=true&#{query_string}",
139
- headers:{}
140
- ).and_return([].to_json)
141
- role.all filter: filter
142
- end
143
- end
144
-
145
- context "when a string" do
146
- let(:filter){ 'string' }
147
- it_passes_the_filter_as ['string'].to_query('filter')
148
- end
149
-
150
- context "when an array" do
151
- let(:filter){ ['foo', 'bar'] }
152
- it_passes_the_filter_as ['foo', 'bar'].to_query('filter')
153
- end
154
- end
155
-
156
- end
157
-
158
- describe '#member_of?' do
159
- it 'calls #all with :filter=>id and returns true if the result is non-empty' do
160
- expect(role).to receive(:all).with(filter: 'the filter').and_return ['an id']
161
- expect(role.member_of?('the filter')).to be_truthy
162
- expect(role).to receive(:all).with(filter: 'the filter').and_return []
163
- expect(role.member_of?('the filter')).to be_falsey
164
- end
165
-
166
- it "accepts a Role" do
167
- other = double('Role', roleid: 'foo')
168
- expect(role).to receive(:all).with(filter: other.roleid).and_return []
169
- role.member_of?(other)
170
- end
171
- end
172
-
173
- describe '#revoke_from' do
174
- it 'deletes member' do
175
- expect_request(
176
- method: :delete,
177
- url: role.url + "/?members&member=the-member",
178
- headers: {}
179
- )
180
- role.revoke_from 'the-member'
181
- end
182
- end
183
-
184
- describe '#permitted?' do
185
- before do
186
- allow_request(
187
- method: :get,
188
- url: role.url + "/?check&resource_id=chunky:bacon&privilege=fry",
189
- headers: {}
190
- ) { result }
191
- end
192
-
193
- context "when get ?check is successful" do
194
- let(:result) { :ok }
195
- it "returns true" do
196
- expect(role.permitted?('chunky:bacon', 'fry')).to be_truthy
197
- end
198
- end
199
-
200
- context "when get ?check not found" do
201
- let(:result) { raise RestClient::ResourceNotFound, 'foo' }
202
- it "returns false" do
203
- expect(role.permitted?('chunky:bacon', 'fry')).to be_falsey
204
- end
205
- end
206
- end
207
-
208
- describe '#members' do
209
- it "can count the grants" do
210
- expect_request(
211
- method: :get,
212
- url: role.url + "/?count=true&members=true"
213
- ).and_return({count: 12}.to_json)
214
-
215
- expect(subject.members(count: true)).to eq(12)
216
- end
217
-
218
- it "gets ?members and turns each into RoleGrant" do
219
- grants = %w(foo bar)
220
- expect_request(
221
- method: :get,
222
- url: role.url + "/?members=true"
223
- ).and_return grants.to_json
224
- grants.each do |g|
225
- expect(Conjur::RoleGrant).to receive(:parse_from_json).with(g, anything).and_return g
226
- end
227
-
228
- expect(subject.members).to eq(grants)
229
- end
230
- end
231
- end
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Conjur::StandardMethods do
4
- let(:credentials) { "whatever" }
5
- subject { double("class", credentials: credentials, log: nil) }
6
- let(:host) { 'http://example.com' }
7
- let(:type) { :widget }
8
-
9
- let(:rest_resource) { double "rest base resource" }
10
- let(:subresource) { double "rest subresource" }
11
-
12
- let(:widget_class) { double "widget class" }
13
-
14
- before do
15
- subject.extend Conjur::StandardMethods
16
- allow(subject).to receive(:fully_escape){|x|x}
17
- allow(RestClient::Resource).to receive(:new).with(host, credentials).and_return rest_resource
18
- allow(rest_resource).to receive(:[]).with('widgets').and_return subresource
19
- stub_const 'Conjur::Widget', widget_class
20
- end
21
-
22
- describe '#standard_create' do
23
- let(:id) { "some-id" }
24
- let(:options) {{ foo: 'bar', baz: 'xyzzy' }}
25
-
26
- let(:response) { double "response" }
27
- let(:widget) { double "widget" }
28
-
29
- before do
30
- allow(subresource).to receive(:post).with(options.merge(id: id)).and_return response
31
- allow(widget_class).to receive(:build_from_response).with(response, credentials).and_return widget
32
- end
33
-
34
- it "uses restclient to post data and creates an object of the response" do
35
- expect(subject.send(:standard_create, host, type, id, options)).to eq(widget)
36
- end
37
- end
38
-
39
- describe '#standard_list' do
40
- let(:attrs) {[{id: 'one', foo: 'bar'}, {id: 'two', foo: 'pub'}]}
41
- let(:options) {{ foo: 'bar', baz: 'xyzzy' }}
42
- let(:json) { attrs.to_json }
43
-
44
- before do
45
- allow(subresource).to receive(:get).with(options).and_return json
46
- end
47
-
48
- it "gets the list, then builds objects from json response" do
49
- expect(subject).to receive(:widget).with('one').and_return(one = double)
50
- expect(one).to receive(:attributes=).with(attrs[0].stringify_keys)
51
- expect(subject).to receive(:widget).with('two').and_return(two = double)
52
- expect(two).to receive(:attributes=).with(attrs[1].stringify_keys)
53
-
54
- expect(subject.send(:standard_list, host, type, options)).to eq([one, two])
55
- end
56
- end
57
-
58
- describe "#standard_show" do
59
- let(:id) { "some-id" }
60
- it "builds a path and returns indexed object" do
61
- allow(widget_class).to receive(:new).with(host, credentials).and_return(bound = double)
62
- allow(bound).to receive(:[]) { |x| "path: #{x}" }
63
- expect(subject.send(:standard_show, host, type, id)).to eq("path: widgets/some-id")
64
- end
65
- end
66
- end
@@ -1,77 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Conjur::User do
4
- context "#new" do
5
- let(:login) { 'the-login' }
6
- let(:url) { "https://example.com/users/#{login}" }
7
- let(:api_key) { 'the-api-key' }
8
- let(:credentials) { { user: login, password: api_key } }
9
- let(:user) { Conjur::User.new(url, credentials)}
10
- describe "attributes" do
11
- subject { user }
12
-
13
- describe '#id' do
14
- subject { super().id }
15
- it { is_expected.to eq(login) }
16
- end
17
-
18
- describe '#login' do
19
- subject { super().login }
20
- it { is_expected.to eq(login) }
21
- end
22
-
23
- describe '#resource_id' do
24
- subject { super().resource_id }
25
- it { is_expected.to eq(login) }
26
- end
27
-
28
- describe '#resource_kind' do
29
- subject { super().resource_kind }
30
- it { is_expected.to eq("user") }
31
- end
32
-
33
- describe '#options' do
34
- subject { super().options }
35
- it { is_expected.to match(hash_including credentials) }
36
- end
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
44
- end
45
- it "connects to a Resource" do
46
- require 'conjur/resource'
47
- expect(Conjur::Core::API).to receive(:conjur_account).and_return 'ci'
48
- expect(Conjur::Resource).to receive(:new).with(
49
- Conjur::Authz::API.host, hash_including(credentials)
50
- ).and_return resource = double(:resource)
51
- expect(resource).to receive(:[]).with("ci/resources/user/the-login")
52
-
53
- user.resource
54
- end
55
- it "connects to a Role" do
56
- require 'conjur/role'
57
- expect(Conjur::Core::API).to receive(:conjur_account).and_return 'ci'
58
- expect(Conjur::Role).to receive(:new).with(
59
- Conjur::Authz::API.host, hash_including(credentials)
60
- ).and_return role = double(:role)
61
- expect(role).to receive(:[]).with("ci/roles/user/the-login")
62
-
63
- user.role
64
- end
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
77
- end
@@ -1,41 +0,0 @@
1
- require 'helpers/request_helpers'
2
- shared_context api: :dummy do
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
-
16
- subject { api }
17
- end
18
-
19
- shared_examples_for 'standard_create with' do |type, id, options|
20
- it "calls through to standard_create" do
21
- expect { invoke }.to call_standard_create_with type, id, options
22
- end
23
- end
24
-
25
- shared_examples_for 'standard_list with' do |type, options|
26
- it "calls through to standard_list" do
27
- expect(subject).to receive(:standard_list).with(
28
- core_host, type, options
29
- ).and_return :response
30
- expect(invoke).to eq(:response)
31
- end
32
- end
33
-
34
- shared_examples_for 'standard_show with' do |type, id|
35
- it "calls through to standard_show" do
36
- expect(subject).to receive(:standard_show).with(
37
- core_host, type, id
38
- ).and_return :response
39
- expect(invoke).to eq(:response)
40
- end
41
- end
@@ -1,101 +0,0 @@
1
- require 'spec_helper'
2
- require 'helpers/request_helpers'
3
-
4
- describe Conjur::Variable do
5
- include RequestHelpers
6
- let(:url) { "http://example.com/variable" }
7
- subject(:variable) { Conjur::Variable.new url }
8
-
9
- before { subject.attributes = {'version_count' => 42} }
10
-
11
- describe '#version_count' do
12
- it "is read from the attributes" do
13
- expect(variable.version_count).to eq(42)
14
- end
15
- end
16
-
17
- describe '#add_value' do
18
- it "posts the new value" do
19
- expect_request(
20
- method: :post,
21
- url: "#{url}/values",
22
- payload: { value: 'new-value' },
23
- headers: {}
24
- )
25
- subject.add_value 'new-value'
26
- end
27
- end
28
-
29
- describe '#value' do
30
- it "gets the value" do
31
- allow_request(
32
- method: :get,
33
- url: "#{url}/value",
34
- headers: {}
35
- ).and_return(double "response", body: "the-value")
36
- expect(subject.value).to eq("the-value")
37
- end
38
-
39
- it "parameterizes the request with a version" do
40
- allow_request(
41
- method: :get,
42
- url: "#{url}/value?version=42",
43
- headers: {}
44
- ).and_return(double "response", body: "the-value")
45
- expect(subject.value(42)).to eq("the-value")
46
- end
47
-
48
- it 'will show the latest expired version' do
49
- allow_request(
50
- :method => :get,
51
- :url => "#{url}/value?show_expired=true",
52
- :headers => {}
53
- ).and_return(double('response', :body => 'the-value'))
54
- expect(subject.value(nil, :show_expired => true)).to eq('the-value')
55
- end
56
-
57
- it 'will show some other version, even if expired' do
58
- allow_request(
59
- :method => :get,
60
- # Hash.to_query (used to build the query string for this
61
- # request) sorts the params into lexicographic order
62
- :url => "#{url}/value?show_expired=true&version=42",
63
- :headers => {}
64
- ).and_return(double('response', :body => 'the-value'))
65
- expect(subject.value(42, :show_expired => true)).to eq('the-value')
66
- end
67
-
68
- end
69
-
70
- describe '#expire' do
71
- context 'when duration is a number of seconds' do
72
- let (:expiration) { 2.weeks }
73
- it 'posts the expiration' do
74
- expect_request(
75
- :method => :post,
76
- :url => "#{url}/expiration",
77
- :payload => { :duration => "PT#{expiration.to_i}S" },
78
- :headers => {}
79
- ).and_return(double('response', :body => '{}'))
80
-
81
- subject.expires_in expiration
82
- end
83
- end
84
-
85
- context 'when duration is an ISO8601 duration' do
86
- let (:expiration) { "P2W" }
87
- it 'posts the expiration' do
88
- expect_request(
89
- :method => :post,
90
- :url => "#{url}/expiration",
91
- :payload => { :duration => "P2W" },
92
- :headers => {}
93
- ).and_return(double('response', :body => '{}'))
94
-
95
- subject.expires_in expiration
96
- end
97
- end
98
-
99
- end
100
-
101
- end
@@ -1,87 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: put
5
- uri: http://admin:%5E6feWZpr@localhost:5100/spec/ddd1f59a-494d-48fb-b045-0374c4a6eef9%2Fxxx
6
- body:
7
- encoding: ASCII-8BIT
8
- string: !binary ""
9
- headers:
10
- Accept:
11
- - ! '*/*; q=0.5, application/xml'
12
- Accept-Encoding:
13
- - gzip, deflate
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- Content-Length:
17
- - '0'
18
- User-Agent:
19
- - Ruby
20
- response:
21
- status:
22
- code: 200
23
- message: ! 'OK '
24
- headers:
25
- Content-Type:
26
- - text/html; charset=utf-8
27
- Cache-Control:
28
- - no-cache
29
- X-Request-Id:
30
- - 98704b39989fbbf3466b5be63ab9149b
31
- X-Runtime:
32
- - '0.089084'
33
- Server:
34
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10)
35
- Date:
36
- - Wed, 30 Jan 2013 18:17:15 GMT
37
- Content-Length:
38
- - '0'
39
- Connection:
40
- - Keep-Alive
41
- body:
42
- encoding: US-ASCII
43
- string: ''
44
- http_version:
45
- recorded_at: Wed, 30 Jan 2013 18:17:15 GMT
46
- - request:
47
- method: head
48
- uri: http://admin:%5E6feWZpr@localhost:5100/spec/ddd1f59a-494d-48fb-b045-0374c4a6eef9%2Fxxx
49
- body:
50
- encoding: US-ASCII
51
- string: ''
52
- headers:
53
- Accept:
54
- - ! '*/*; q=0.5, application/xml'
55
- Accept-Encoding:
56
- - gzip, deflate
57
- User-Agent:
58
- - Ruby
59
- response:
60
- status:
61
- code: 200
62
- message: ! 'OK '
63
- headers:
64
- Content-Type:
65
- - application/json; charset=utf-8
66
- Etag:
67
- - ! '"6b15850e72c52c9bc10b0f67349774c9"'
68
- Cache-Control:
69
- - max-age=0, private, must-revalidate
70
- X-Request-Id:
71
- - 28a81334baa7bf4aedf12a56a0e294c7
72
- X-Runtime:
73
- - '0.088457'
74
- Server:
75
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10)
76
- Date:
77
- - Wed, 30 Jan 2013 18:17:15 GMT
78
- Content-Length:
79
- - '0'
80
- Connection:
81
- - Keep-Alive
82
- body:
83
- encoding: US-ASCII
84
- string: ''
85
- http_version:
86
- recorded_at: Wed, 30 Jan 2013 18:17:15 GMT
87
- recorded_with: VCR 2.3.0
@@ -1,87 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: put
5
- uri: http://admin:%5E6feWZpr@localhost:5100/spec/ddd1f59a-494d-48fb-b045-0374c4a6eef9%2F+%3F!!%3F+%2Fxxx
6
- body:
7
- encoding: ASCII-8BIT
8
- string: !binary ""
9
- headers:
10
- Accept:
11
- - ! '*/*; q=0.5, application/xml'
12
- Accept-Encoding:
13
- - gzip, deflate
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- Content-Length:
17
- - '0'
18
- User-Agent:
19
- - Ruby
20
- response:
21
- status:
22
- code: 200
23
- message: ! 'OK '
24
- headers:
25
- Content-Type:
26
- - text/html; charset=utf-8
27
- Cache-Control:
28
- - no-cache
29
- X-Request-Id:
30
- - 9b6cc33f59907307da678452e0e3faa4
31
- X-Runtime:
32
- - '0.086922'
33
- Server:
34
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10)
35
- Date:
36
- - Wed, 30 Jan 2013 18:17:15 GMT
37
- Content-Length:
38
- - '0'
39
- Connection:
40
- - Keep-Alive
41
- body:
42
- encoding: US-ASCII
43
- string: ''
44
- http_version:
45
- recorded_at: Wed, 30 Jan 2013 18:17:15 GMT
46
- - request:
47
- method: head
48
- uri: http://admin:%5E6feWZpr@localhost:5100/spec/ddd1f59a-494d-48fb-b045-0374c4a6eef9%2F+%3F!!%3F+%2Fxxx
49
- body:
50
- encoding: US-ASCII
51
- string: ''
52
- headers:
53
- Accept:
54
- - ! '*/*; q=0.5, application/xml'
55
- Accept-Encoding:
56
- - gzip, deflate
57
- User-Agent:
58
- - Ruby
59
- response:
60
- status:
61
- code: 200
62
- message: ! 'OK '
63
- headers:
64
- Content-Type:
65
- - application/json; charset=utf-8
66
- Etag:
67
- - ! '"efa2bc5554b480a61948855b3b06a97e"'
68
- Cache-Control:
69
- - max-age=0, private, must-revalidate
70
- X-Request-Id:
71
- - 9790615667d793e342ac1ece26a0bbde
72
- X-Runtime:
73
- - '0.089211'
74
- Server:
75
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10)
76
- Date:
77
- - Wed, 30 Jan 2013 18:17:15 GMT
78
- Content-Length:
79
- - '0'
80
- Connection:
81
- - Keep-Alive
82
- body:
83
- encoding: US-ASCII
84
- string: ''
85
- http_version:
86
- recorded_at: Wed, 30 Jan 2013 18:17:15 GMT
87
- recorded_with: VCR 2.3.0