pisoni 1.28.0 → 1.29.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile +2 -4
- data/lib/3scale/core/application.rb +1 -1
- data/lib/3scale/core/application_key.rb +2 -4
- data/lib/3scale/core/service.rb +1 -6
- data/lib/3scale/core/version.rb +1 -1
- data/lib/3scale/core.rb +0 -1
- data/spec/alert_limit_spec.rb +13 -13
- data/spec/application_key_spec.rb +24 -8
- data/spec/application_referrer_filter_spec.rb +3 -3
- data/spec/service_spec.rb +0 -5
- data/spec/utilization_spec.rb +0 -2
- metadata +6 -11
- data/lib/3scale/core/transaction.rb +0 -26
- data/spec/private_endpoints/transaction.rb +0 -16
- data/spec/transaction_spec.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bc480ca255fad3679c652ee5913824d543c7f4e5d51b0866f3919d4d1a496c3
|
4
|
+
data.tar.gz: d5b36dd8d28242573d3e476ae4420c93dfd30275848ea16c4526ad61db1a386e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffb11b5ae16138162d9fbb2c5b0784618b94d478cbbfd6e8edc377ae05b3554471ffd360db902ba5e569b0c90b96ceca3005860d53f57cfdab744cb48f019716
|
7
|
+
data.tar.gz: 5ff19f326743a8e56b8cb2df1ab37bbef54bafbd075a4e8d6a90ee729b51e8950e7248d331724982fbf7f42c5e6ceb265f13767bd4c9b7d4c09633ab982b3eca
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
Notable changes to Pisoni will be tracked in this document.
|
4
4
|
|
5
|
+
## 1.29.1 - 2023-11-30
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- Fixed the issue with updating/deleting keys for applications with special characters in the
|
10
|
+
application IDs by escaping them. [#31](https://github.com/3scale/pisoni/pull/31)
|
11
|
+
|
12
|
+
## 1.29.0 - 2020-03-17
|
13
|
+
|
14
|
+
### Removed
|
15
|
+
|
16
|
+
- "Latest transactions" functionality
|
17
|
+
[#27](https://github.com/3scale/pisoni/pull/27)
|
18
|
+
|
5
19
|
## 1.28.0 - 2019-12-20
|
6
20
|
|
7
21
|
### Changed
|
data/Gemfile
CHANGED
@@ -3,14 +3,12 @@ source "https://rubygems.org"
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
gem 'turn', '~> 0.9.7'
|
7
6
|
gem 'minitest'
|
8
7
|
gem "codeclimate-test-reporter", require: nil
|
9
8
|
end
|
10
9
|
|
11
10
|
group :development, :test do
|
12
|
-
gem 'pry',
|
13
|
-
gem 'pry-
|
14
|
-
gem 'pry-byebug', '~> 2.0.0'
|
11
|
+
gem 'pry-doc', '>= 0.8'
|
12
|
+
gem 'pry-byebug', '>= 3.7.0'
|
15
13
|
gem 'license_finder', '~> 5', require: false
|
16
14
|
end
|
@@ -23,14 +23,12 @@ module ThreeScale
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.base_uri(service_id, application_id)
|
26
|
-
"#{default_uri}#{service_id}/applications/#{application_id}/keys/"
|
26
|
+
"#{default_uri}#{service_id}/applications/#{CGI::escape(application_id.to_s)}/keys/"
|
27
27
|
end
|
28
28
|
private_class_method :base_uri
|
29
29
|
|
30
30
|
def self.application_key_uri(service_id, application_id, value = '')
|
31
|
-
|
32
|
-
|
33
|
-
"#{base_uri(service_id, application_id)}#{escaped_value}"
|
31
|
+
"#{base_uri(service_id, application_id)}#{CGI::escape(value.to_s)}"
|
34
32
|
end
|
35
33
|
private_class_method :application_key_uri
|
36
34
|
end
|
data/lib/3scale/core/service.rb
CHANGED
@@ -2,8 +2,7 @@ module ThreeScale
|
|
2
2
|
module Core
|
3
3
|
class Service < APIClient::Resource
|
4
4
|
attributes :provider_key, :id, :backend_version, :referrer_filters_required,
|
5
|
-
:
|
6
|
-
:default_user_plan_name, :default_service, :state
|
5
|
+
:default_service, :state
|
7
6
|
|
8
7
|
class << self
|
9
8
|
def load_by_id(service_id)
|
@@ -85,10 +84,6 @@ module ThreeScale
|
|
85
84
|
@referrer_filters_required
|
86
85
|
end
|
87
86
|
|
88
|
-
def user_registration_required?
|
89
|
-
@user_registration_required
|
90
|
-
end
|
91
|
-
|
92
87
|
def active?
|
93
88
|
state == :active
|
94
89
|
end
|
data/lib/3scale/core/version.rb
CHANGED
data/lib/3scale/core.rb
CHANGED
@@ -24,7 +24,6 @@ require '3scale/core/errors'
|
|
24
24
|
require '3scale/core/application_key'
|
25
25
|
require '3scale/core/application_referrer_filter'
|
26
26
|
require '3scale/core/service_error'
|
27
|
-
require '3scale/core/transaction'
|
28
27
|
require '3scale/core/utilization'
|
29
28
|
require '3scale/core/service_token'
|
30
29
|
|
data/spec/alert_limit_spec.rb
CHANGED
@@ -5,17 +5,17 @@ module ThreeScale
|
|
5
5
|
describe '.load_all' do
|
6
6
|
describe 'when there are alert limits' do
|
7
7
|
let(:service_id) { 100 }
|
8
|
-
let(:
|
8
|
+
let(:limits) { [50, 100] }
|
9
9
|
before do
|
10
|
-
|
11
|
-
|
10
|
+
limits.map { |value| AlertLimit.delete(service_id, value) }
|
11
|
+
limits.map { |value| AlertLimit.save(service_id, value) }
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'returns a list of alert limits' do
|
15
15
|
alert_limits = AlertLimit.load_all(service_id)
|
16
16
|
|
17
17
|
alert_limits.size.must_equal 2
|
18
|
-
alert_limits.map(&:value).must_equal
|
18
|
+
alert_limits.map(&:value).must_equal limits
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -30,40 +30,40 @@ module ThreeScale
|
|
30
30
|
|
31
31
|
describe '.save' do
|
32
32
|
let(:service_id) { 500 }
|
33
|
-
let(:
|
33
|
+
let(:limit) { 100 }
|
34
34
|
|
35
35
|
before do
|
36
|
-
AlertLimit.delete(service_id,
|
36
|
+
AlertLimit.delete(service_id, limit)
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'returns a AlertLimit object' do
|
40
|
-
alert_limit = AlertLimit.save(service_id,
|
40
|
+
alert_limit = AlertLimit.save(service_id, limit)
|
41
41
|
|
42
42
|
alert_limit.must_be_kind_of AlertLimit
|
43
|
-
alert_limit.value.must_equal
|
43
|
+
alert_limit.value.must_equal limit
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe '.delete' do
|
48
48
|
describe 'with an existing alert limit' do
|
49
49
|
let(:service_id) { 300 }
|
50
|
-
let(:
|
50
|
+
let(:limit) { 50 }
|
51
51
|
|
52
52
|
before do
|
53
|
-
AlertLimit.save(service_id,
|
53
|
+
AlertLimit.save(service_id, limit)
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'returns true' do
|
57
|
-
AlertLimit.delete(service_id,
|
57
|
+
AlertLimit.delete(service_id, limit).must_equal true
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe 'with a non-existing alert limit' do
|
62
62
|
let(:service_id) { 300 }
|
63
|
-
let(:
|
63
|
+
let(:limit) { 75 }
|
64
64
|
|
65
65
|
it 'returns true' do
|
66
|
-
AlertLimit.delete(service_id,
|
66
|
+
AlertLimit.delete(service_id, limit).must_equal false
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -6,21 +6,21 @@ module ThreeScale
|
|
6
6
|
describe 'when there are application keys' do
|
7
7
|
let(:service_id) { 100 }
|
8
8
|
let(:app_id) { 2001 }
|
9
|
-
let(:
|
9
|
+
let(:keys) { %w[foo bar] }
|
10
10
|
before do
|
11
|
-
|
11
|
+
keys.map { |key| ApplicationKey.delete(service_id, app_id, key) }
|
12
12
|
|
13
13
|
Application.save service_id: service_id, id: app_id, state: 'suspended',
|
14
14
|
plan_id: '3066', plan_name: 'crappy', redirect_url: 'blah'
|
15
15
|
|
16
|
-
|
16
|
+
keys.map { |key| ApplicationKey.save(service_id, app_id, key) }
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'returns a list of application keys' do
|
20
20
|
application_keys = ApplicationKey.load_all(service_id, app_id)
|
21
21
|
|
22
22
|
application_keys.size.must_equal 2
|
23
|
-
application_keys.map(&:value).sort.must_equal
|
23
|
+
application_keys.map(&:value).sort.must_equal keys.sort
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -42,20 +42,20 @@ module ThreeScale
|
|
42
42
|
describe '.save' do
|
43
43
|
let(:service_id) { 500 }
|
44
44
|
let(:app_id) { 500 }
|
45
|
-
let(:
|
45
|
+
let(:key) { "foobar" }
|
46
46
|
|
47
47
|
before do
|
48
|
-
ApplicationKey.delete(service_id, app_id,
|
48
|
+
ApplicationKey.delete(service_id, app_id, key)
|
49
49
|
|
50
50
|
Application.save service_id: service_id, id: app_id, state: 'suspended',
|
51
51
|
plan_id: '3066', plan_name: 'crappy', redirect_url: 'blah'
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'returns an ApplicationKey object' do
|
55
|
-
application_key = ApplicationKey.save(service_id, app_id,
|
55
|
+
application_key = ApplicationKey.save(service_id, app_id, key)
|
56
56
|
|
57
57
|
application_key.must_be_kind_of ApplicationKey
|
58
|
-
application_key.value.must_equal
|
58
|
+
application_key.value.must_equal key
|
59
59
|
end
|
60
60
|
|
61
61
|
describe 'with a key that contains special chars (*, _, etc.)' do
|
@@ -72,6 +72,22 @@ module ThreeScale
|
|
72
72
|
application_key.value.must_equal key
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
describe 'with app ID that contains special characters ({, $, ? etc.)' do
|
77
|
+
let(:app_id) { 'abc{1}$3?' }
|
78
|
+
let(:key) { 'z#$*' }
|
79
|
+
|
80
|
+
before do
|
81
|
+
ApplicationKey.delete(service_id, app_id, key)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'saves it correctly' do
|
85
|
+
application_key = ApplicationKey.save(service_id, app_id, key)
|
86
|
+
|
87
|
+
application_key.must_be_kind_of ApplicationKey
|
88
|
+
application_key.value.must_equal key
|
89
|
+
end
|
90
|
+
end
|
75
91
|
end
|
76
92
|
|
77
93
|
describe '.delete' do
|
@@ -25,15 +25,15 @@ module ThreeScale
|
|
25
25
|
|
26
26
|
describe '.load_all' do
|
27
27
|
describe 'Getting all referrer filters' do
|
28
|
-
let(:
|
28
|
+
let(:ref_filters) { %w(foo bar) }
|
29
29
|
|
30
30
|
before do
|
31
|
-
|
31
|
+
ref_filters.map { |value| ApplicationReferrerFilter.save(service_id, app_id, value) }
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'returns a sorted list of filters' do
|
35
35
|
filters = ApplicationReferrerFilter.load_all(service_id, app_id)
|
36
|
-
filters.must_equal
|
36
|
+
filters.must_equal ref_filters.sort
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
data/spec/service_spec.rb
CHANGED
@@ -26,8 +26,6 @@ module ThreeScale
|
|
26
26
|
id: default_service_id,
|
27
27
|
referrer_filters_required: true,
|
28
28
|
backend_version: 'oauth',
|
29
|
-
default_user_plan_id: 15,
|
30
|
-
default_user_plan_name: 'test name',
|
31
29
|
default_service: true
|
32
30
|
raise unless service.default_service
|
33
31
|
|
@@ -47,10 +45,7 @@ module ThreeScale
|
|
47
45
|
service.provider_key.must_equal default_provider_key
|
48
46
|
service.id.must_equal default_service_id.to_s
|
49
47
|
service.referrer_filters_required?.must_equal true
|
50
|
-
service.user_registration_required?.must_equal true
|
51
48
|
service.backend_version.must_equal 'oauth'
|
52
|
-
service.default_user_plan_id.must_equal '15'
|
53
|
-
service.default_user_plan_name.must_equal 'test name'
|
54
49
|
end
|
55
50
|
end
|
56
51
|
|
data/spec/utilization_spec.rb
CHANGED
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.29.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Martinez Ruiz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -113,7 +113,6 @@ files:
|
|
113
113
|
- lib/3scale/core/service.rb
|
114
114
|
- lib/3scale/core/service_error.rb
|
115
115
|
- lib/3scale/core/service_token.rb
|
116
|
-
- lib/3scale/core/transaction.rb
|
117
116
|
- lib/3scale/core/usage_limit.rb
|
118
117
|
- lib/3scale/core/utilization.rb
|
119
118
|
- lib/3scale/core/version.rb
|
@@ -128,19 +127,17 @@ files:
|
|
128
127
|
- spec/metric_spec.rb
|
129
128
|
- spec/private_endpoints/event.rb
|
130
129
|
- spec/private_endpoints/service_error.rb
|
131
|
-
- spec/private_endpoints/transaction.rb
|
132
130
|
- spec/service_error_spec.rb
|
133
131
|
- spec/service_spec.rb
|
134
132
|
- spec/service_token_spec.rb
|
135
133
|
- spec/spec_helper.rb
|
136
|
-
- spec/transaction_spec.rb
|
137
134
|
- spec/usagelimit_spec.rb
|
138
135
|
- spec/utilization_spec.rb
|
139
136
|
homepage: https://github.com/3scale/pisoni
|
140
137
|
licenses:
|
141
138
|
- Apache-2.0
|
142
139
|
metadata: {}
|
143
|
-
post_install_message:
|
140
|
+
post_install_message:
|
144
141
|
rdoc_options:
|
145
142
|
- "--charset=UTF-8"
|
146
143
|
require_paths:
|
@@ -156,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
153
|
- !ruby/object:Gem::Version
|
157
154
|
version: '0'
|
158
155
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
160
|
-
signing_key:
|
156
|
+
rubygems_version: 3.1.6
|
157
|
+
signing_key:
|
161
158
|
specification_version: 4
|
162
159
|
summary: Client for the Apisonator internal API for model data
|
163
160
|
test_files:
|
@@ -169,11 +166,9 @@ test_files:
|
|
169
166
|
- spec/metric_spec.rb
|
170
167
|
- spec/private_endpoints/event.rb
|
171
168
|
- spec/private_endpoints/service_error.rb
|
172
|
-
- spec/private_endpoints/transaction.rb
|
173
169
|
- spec/service_error_spec.rb
|
174
170
|
- spec/service_spec.rb
|
175
171
|
- spec/service_token_spec.rb
|
176
172
|
- spec/spec_helper.rb
|
177
|
-
- spec/transaction_spec.rb
|
178
173
|
- spec/usagelimit_spec.rb
|
179
174
|
- spec/utilization_spec.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module ThreeScale
|
2
|
-
module Core
|
3
|
-
class Transaction < APIClient::Resource
|
4
|
-
attributes :application_id, :usage, :timestamp
|
5
|
-
|
6
|
-
default_uri '/internal/services/'
|
7
|
-
|
8
|
-
def self.transactions_uri(service_id)
|
9
|
-
"#{default_uri}#{service_id}/transactions/"
|
10
|
-
end
|
11
|
-
private_class_method :transactions_uri
|
12
|
-
|
13
|
-
def self.load_all(service_id)
|
14
|
-
result = api_do_get({}, { uri: transactions_uri(service_id),
|
15
|
-
rprefix: :transactions }) do |res|
|
16
|
-
return nil if res[:response].status == 404
|
17
|
-
true
|
18
|
-
end
|
19
|
-
|
20
|
-
return nil if result.nil?
|
21
|
-
|
22
|
-
APIClient::Collection.new(result[:attributes].map { |attrs| new attrs })
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module PrivateEndpoints
|
2
|
-
module Transaction
|
3
|
-
def save(service_id, transactions)
|
4
|
-
api_create(transactions,
|
5
|
-
{ uri: transactions_uri(service_id),
|
6
|
-
prefix: :transactions })
|
7
|
-
end
|
8
|
-
|
9
|
-
def delete_all(service_id)
|
10
|
-
api_delete({}, uri: transactions_uri(service_id))
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
ThreeScale::Core::Transaction.extend PrivateEndpoints::Transaction
|
16
|
-
|
data/spec/transaction_spec.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require_relative './spec_helper'
|
2
|
-
require_relative './private_endpoints/transaction'
|
3
|
-
|
4
|
-
module ThreeScale
|
5
|
-
module Core
|
6
|
-
describe Transaction do
|
7
|
-
before do
|
8
|
-
Service.delete_by_id!(service_id)
|
9
|
-
Service.save!(provider_key: 'foo_transaction_spec', id: service_id)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '.load_all' do
|
13
|
-
let(:service_id) { '7575_transaction_spec' }
|
14
|
-
let(:non_existing_service_id) { service_id.to_i.succ.to_s }
|
15
|
-
|
16
|
-
before do
|
17
|
-
Transaction.delete_all(service_id)
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'when there are transactions' do
|
21
|
-
let(:first_transaction_time) { Time.new(2015, 1, 1) }
|
22
|
-
let(:second_transaction_time) { Time.new(2015, 1, 2) }
|
23
|
-
let(:test_transactions) do
|
24
|
-
transactions = []
|
25
|
-
transactions << { application_id: 'first_test_application',
|
26
|
-
usage: 'first_usage',
|
27
|
-
timestamp: first_transaction_time.to_s }
|
28
|
-
transactions << { application_id: 'second_test_application',
|
29
|
-
usage: 'second_usage',
|
30
|
-
timestamp: second_transaction_time.to_s }
|
31
|
-
end
|
32
|
-
|
33
|
-
before do
|
34
|
-
Transaction.save(service_id, test_transactions)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'returns a collection with the transactions' do
|
38
|
-
transactions = Transaction.load_all(service_id)
|
39
|
-
|
40
|
-
transactions.total.must_equal test_transactions.size
|
41
|
-
transactions.size.must_equal test_transactions.size
|
42
|
-
|
43
|
-
latest_transaction = transactions[0]
|
44
|
-
latest_transaction.application_id.must_equal test_transactions[1][:application_id]
|
45
|
-
latest_transaction.usage.must_equal test_transactions[1][:usage]
|
46
|
-
latest_transaction.timestamp.must_equal second_transaction_time
|
47
|
-
|
48
|
-
previous_transaction = transactions[1]
|
49
|
-
previous_transaction.application_id.must_equal test_transactions[0][:application_id]
|
50
|
-
previous_transaction.usage.must_equal test_transactions[0][:usage]
|
51
|
-
previous_transaction.timestamp.must_equal first_transaction_time
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe 'when there are no transactions' do
|
56
|
-
it 'returns an empty collection' do
|
57
|
-
transactions = Transaction.load_all(service_id)
|
58
|
-
transactions.must_be_empty
|
59
|
-
transactions.total.must_equal 0
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe 'with an invalid service ID' do
|
64
|
-
it 'returns nil' do
|
65
|
-
Transaction.load_all(non_existing_service_id).must_be_nil
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|