pisoni 1.26.0 → 1.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/3scale/core/application.rb +10 -3
- data/lib/3scale/core/application_key.rb +6 -2
- data/lib/3scale/core/version.rb +1 -1
- data/spec/application_key_spec.rb +37 -15
- data/spec/application_spec.rb +92 -9
- data/spec/service_spec.rb +0 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b9921a2c40849229cd27b57db87570d21794d2d65d4673aef8faa157f5f4782
|
4
|
+
data.tar.gz: 5b6b50ff45e57e8c55ba4b873b0529b7902a2c67c34372475aefe39938e0df74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3c2931b7987037a397b43e491db1dcf3985148672270b33b5703b08a4a4f9e01ac15de8a29433f13fdd9d5985d50f87275a7a17542bfddc2d71b2e42f6d528d
|
7
|
+
data.tar.gz: 2fa14e7b0ff82f7701b279503e2957a6978aca5bdb07b59a2ba75d9a1724926009bf46876202985c4a3414c1694a28929e7f6b79424686171e8d1d9eabedccf9
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
Notable changes to Pisoni will be tracked in this document.
|
4
4
|
|
5
|
+
## 1.27.0 - 2019-06-28
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Support for app credentials with special characters ('*', '$', etc.). [#22](https://github.com/3scale/pisoni/pull/22)
|
10
|
+
|
5
11
|
## 1.26.0 - 2019-03-05
|
6
12
|
|
7
13
|
### Added
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
module ThreeScale
|
2
4
|
module Core
|
3
5
|
class Application < APIClient::Resource
|
@@ -16,12 +18,16 @@ module ThreeScale
|
|
16
18
|
private_class_method :base_uri
|
17
19
|
|
18
20
|
def self.app_uri(service_id, id)
|
19
|
-
|
21
|
+
escaped_id = CGI::escape(id.to_s)
|
22
|
+
|
23
|
+
"#{base_uri(service_id)}#{escaped_id}"
|
20
24
|
end
|
21
25
|
private_class_method :app_uri
|
22
26
|
|
23
27
|
def self.key_uri(service_id, key)
|
24
|
-
|
28
|
+
escaped_key = CGI::escape(key)
|
29
|
+
|
30
|
+
"#{base_uri(service_id)}key/#{escaped_key}"
|
25
31
|
end
|
26
32
|
private_class_method :key_uri
|
27
33
|
|
@@ -71,7 +77,8 @@ module ThreeScale
|
|
71
77
|
|
72
78
|
def self.save_id_by_key(service_id, user_key, id)
|
73
79
|
raise ApplicationHasInconsistentData.new(id, user_key) if (service_id.nil? || id.nil? || user_key.nil? || service_id=="" || id=="" || user_key=="")
|
74
|
-
|
80
|
+
escaped_key = CGI::escape(user_key)
|
81
|
+
ret = api_do_put({}, uri: "#{app_uri(service_id, id)}/key/#{escaped_key}")
|
75
82
|
ret[:ok]
|
76
83
|
end
|
77
84
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
module ThreeScale
|
2
4
|
module Core
|
3
5
|
class ApplicationKey < APIClient::Resource
|
@@ -25,8 +27,10 @@ module ThreeScale
|
|
25
27
|
end
|
26
28
|
private_class_method :base_uri
|
27
29
|
|
28
|
-
def self.application_key_uri(service_id, application_id, value =
|
29
|
-
|
30
|
+
def self.application_key_uri(service_id, application_id, value = '')
|
31
|
+
escaped_value = CGI::escape(value)
|
32
|
+
|
33
|
+
"#{base_uri(service_id, application_id)}#{escaped_value}"
|
30
34
|
end
|
31
35
|
private_class_method :application_key_uri
|
32
36
|
end
|
data/lib/3scale/core/version.rb
CHANGED
@@ -57,38 +57,60 @@ module ThreeScale
|
|
57
57
|
application_key.must_be_kind_of ApplicationKey
|
58
58
|
application_key.value.must_equal value
|
59
59
|
end
|
60
|
+
|
61
|
+
describe 'with a key that contains special chars (*, _, etc.)' do
|
62
|
+
let(:key) { '#$*' }
|
63
|
+
|
64
|
+
before do
|
65
|
+
ApplicationKey.delete(service_id, app_id, key)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'saves it correctly' do
|
69
|
+
application_key = ApplicationKey.save(service_id, app_id, key)
|
70
|
+
|
71
|
+
application_key.must_be_kind_of ApplicationKey
|
72
|
+
application_key.value.must_equal key
|
73
|
+
end
|
74
|
+
end
|
60
75
|
end
|
61
76
|
|
62
77
|
describe '.delete' do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
let(:value) { "foo" }
|
78
|
+
let(:service_id) { 300 }
|
79
|
+
let(:app_id) { 200 }
|
80
|
+
let(:key) { 'foo' }
|
67
81
|
|
68
|
-
|
69
|
-
|
70
|
-
|
82
|
+
before do
|
83
|
+
Application.save service_id: service_id, id: app_id, state: 'suspended',
|
84
|
+
plan_id: '3066', plan_name: 'crappy', redirect_url: 'blah'
|
85
|
+
end
|
71
86
|
|
72
|
-
|
87
|
+
describe 'with an existing application key' do
|
88
|
+
before do
|
89
|
+
ApplicationKey.save(service_id, app_id, key)
|
73
90
|
end
|
74
91
|
|
75
92
|
it 'returns true' do
|
76
|
-
ApplicationKey.delete(service_id, app_id,
|
93
|
+
ApplicationKey.delete(service_id, app_id, key).must_equal true
|
77
94
|
end
|
78
95
|
end
|
79
96
|
|
80
97
|
describe 'with a non-existing application key' do
|
81
|
-
let(:
|
82
|
-
|
83
|
-
|
98
|
+
let(:key) { 'non_existing_key' }
|
99
|
+
|
100
|
+
it 'returns false' do
|
101
|
+
ApplicationKey.delete(service_id, app_id, key).must_equal false
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'with a key that contains special chars (*, _, etc.)' do
|
106
|
+
let(:key_with_special_chars) { '#$*' }
|
84
107
|
|
85
108
|
before do
|
86
|
-
|
87
|
-
plan_id: '3066', plan_name: 'crappy', redirect_url: 'blah'
|
109
|
+
ApplicationKey.save(service_id, app_id, key)
|
88
110
|
end
|
89
111
|
|
90
112
|
it 'returns true' do
|
91
|
-
ApplicationKey.delete(service_id, app_id,
|
113
|
+
ApplicationKey.delete(service_id, app_id, key).must_equal true
|
92
114
|
end
|
93
115
|
end
|
94
116
|
end
|
data/spec/application_spec.rb
CHANGED
@@ -44,6 +44,20 @@ module ThreeScale
|
|
44
44
|
Application.load(1999, 7999).must_be_nil
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
describe 'with an app ID that contains special characters' do
|
49
|
+
let(:service_id) { 2001 }
|
50
|
+
let(:app_id) { '#$*' }
|
51
|
+
|
52
|
+
before do
|
53
|
+
Application.save service_id: service_id, id: app_id, state: 'suspended',
|
54
|
+
plan_id: '3066', plan_name: 'crappy', redirect_url: 'blah'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'returns an app with the correct ID' do
|
58
|
+
Application.load(service_id, app_id).id.must_equal app_id
|
59
|
+
end
|
60
|
+
end
|
47
61
|
end
|
48
62
|
|
49
63
|
describe '.delete' do
|
@@ -73,6 +87,20 @@ module ThreeScale
|
|
73
87
|
Application.delete(1999, 8011).must_equal false
|
74
88
|
end
|
75
89
|
end
|
90
|
+
|
91
|
+
describe 'with an app ID that contains special characters' do
|
92
|
+
let(:service_id) { 2001 }
|
93
|
+
let(:app_id) { '#$*' }
|
94
|
+
|
95
|
+
before do
|
96
|
+
Application.save service_id: service_id, id: app_id, state: 'suspended',
|
97
|
+
plan_id: '3066', plan_name: 'crappy', redirect_url: 'blah'
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns true when deleting an existing app' do
|
101
|
+
Application.delete(service_id, app_id).must_equal true
|
102
|
+
end
|
103
|
+
end
|
76
104
|
end
|
77
105
|
|
78
106
|
describe '.save' do
|
@@ -126,6 +154,22 @@ module ThreeScale
|
|
126
154
|
end.must_raise KeyError # minitest wont catch parent exceptions :/
|
127
155
|
end
|
128
156
|
end
|
157
|
+
|
158
|
+
describe 'with an app ID that contains special characters' do
|
159
|
+
let(:service_id) { 2001 }
|
160
|
+
let(:app_id) { '#$*' }
|
161
|
+
|
162
|
+
before do
|
163
|
+
Application.delete(service_id, app_id)
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'returns an object with the correct ID' do
|
167
|
+
app = Application.save service_id: service_id, id: app_id, state: 'suspended',
|
168
|
+
plan_id: '3066', plan_name: 'crappy', redirect_url: 'blah'
|
169
|
+
|
170
|
+
app.id.must_equal app_id
|
171
|
+
end
|
172
|
+
end
|
129
173
|
end
|
130
174
|
|
131
175
|
describe '#save' do
|
@@ -226,31 +270,70 @@ module ThreeScale
|
|
226
270
|
end
|
227
271
|
|
228
272
|
describe 'by_key' do
|
273
|
+
let(:key) { 'a_key' }
|
274
|
+
let(:key_with_special_chars) { '#$*' }
|
275
|
+
let(:service_id) { 2001 }
|
276
|
+
let(:app_id) { 8011 }
|
277
|
+
|
229
278
|
before do
|
230
|
-
Application.save_id_by_key(
|
279
|
+
Application.save_id_by_key(service_id, key, app_id)
|
231
280
|
end
|
232
281
|
|
233
282
|
describe '.load_id_by_key' do
|
234
283
|
it 'returns the app ID linked to the specified service and key' do
|
235
|
-
Application.load_id_by_key(
|
284
|
+
Application.load_id_by_key(service_id, key).must_equal app_id.to_s
|
285
|
+
end
|
286
|
+
|
287
|
+
describe 'with a key that contains special chars (*, _, etc.)' do
|
288
|
+
before do
|
289
|
+
Application.save_id_by_key(service_id, key_with_special_chars, app_id)
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'returns the correct app ID' do
|
293
|
+
Application.load_id_by_key(service_id, key_with_special_chars).must_equal app_id.to_s
|
294
|
+
end
|
236
295
|
end
|
237
296
|
end
|
238
297
|
|
239
298
|
describe '.save_id_by_key' do
|
299
|
+
let(:another_key) { key.succ }
|
300
|
+
|
240
301
|
it 'changes the key linked to the app ID and service' do
|
241
|
-
Application.load_id_by_key(
|
242
|
-
Application.save_id_by_key(
|
243
|
-
Application.load_id_by_key(
|
302
|
+
Application.load_id_by_key(service_id, another_key).must_be_nil
|
303
|
+
Application.save_id_by_key(service_id, another_key, app_id).must_equal true
|
304
|
+
Application.load_id_by_key(service_id, another_key).must_equal app_id.to_s
|
244
305
|
# clean up this key
|
245
|
-
Application.delete_id_by_key(
|
306
|
+
Application.delete_id_by_key(service_id, another_key)
|
307
|
+
end
|
308
|
+
|
309
|
+
describe 'with a key that contains special chars (*, _, etc.)' do
|
310
|
+
after do
|
311
|
+
Application.delete_id_by_key(service_id, key_with_special_chars)
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'changes the key linked to the app ID and service' do
|
315
|
+
Application.save_id_by_key(service_id, key_with_special_chars, app_id).must_equal true
|
316
|
+
Application.load_id_by_key(service_id, key_with_special_chars).must_equal app_id.to_s
|
317
|
+
end
|
246
318
|
end
|
247
319
|
end
|
248
320
|
|
249
321
|
describe '.delete_id_by_key' do
|
250
322
|
it 'deletes the key linked to the app ID and service' do
|
251
|
-
Application.load_id_by_key(
|
252
|
-
Application.delete_id_by_key(
|
253
|
-
Application.load_id_by_key(
|
323
|
+
Application.load_id_by_key(service_id, key).must_equal app_id.to_s
|
324
|
+
Application.delete_id_by_key(service_id, key)
|
325
|
+
Application.load_id_by_key(service_id, key).must_be_nil
|
326
|
+
end
|
327
|
+
|
328
|
+
describe 'with a key that contains special chars (*, _, etc.)' do
|
329
|
+
before do
|
330
|
+
Application.save_id_by_key(service_id, key_with_special_chars, app_id)
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'deletes the app' do
|
334
|
+
Application.delete_id_by_key(service_id, key_with_special_chars)
|
335
|
+
Application.load_id_by_key(service_id, key_with_special_chars).must_be_nil
|
336
|
+
end
|
254
337
|
end
|
255
338
|
end
|
256
339
|
end
|
data/spec/service_spec.rb
CHANGED
@@ -245,16 +245,6 @@ module ThreeScale
|
|
245
245
|
Service.delete_stats(default_service_id, delete_job).must_equal true
|
246
246
|
end
|
247
247
|
end
|
248
|
-
|
249
|
-
describe 'with invalid job' do
|
250
|
-
# to < from
|
251
|
-
let(:to) { Time.new(2001, 10, 31).to_i }
|
252
|
-
it 'raises error' do
|
253
|
-
lambda {
|
254
|
-
Service.delete_stats(default_service_id, delete_job)
|
255
|
-
}.must_raise APIClient::APIError
|
256
|
-
end
|
257
|
-
end
|
258
248
|
end
|
259
249
|
end
|
260
250
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pisoni
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Martinez Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
|
-
rubygems_version: 3.0.
|
161
|
+
rubygems_version: 3.0.1
|
162
162
|
signing_key:
|
163
163
|
specification_version: 4
|
164
164
|
summary: Client for the Apisonator internal API for model data
|