pisoni 1.29.1 → 1.30.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 +8 -0
- data/lib/3scale/core/api_client/operations.rb +1 -1
- data/lib/3scale/core/api_client/support.rb +6 -0
- data/lib/3scale/core/application.rb +3 -10
- data/lib/3scale/core/application_key.rb +2 -4
- data/lib/3scale/core/application_referrer_filter.rb +1 -1
- data/lib/3scale/core/utilization.rb +1 -1
- data/lib/3scale/core/version.rb +1 -1
- data/lib/3scale/core.rb +2 -9
- data/pisoni.gemspec +7 -6
- data/spec/application_key_spec.rb +4 -4
- data/spec/application_referrer_filter_spec.rb +5 -4
- data/spec/application_spec.rb +4 -4
- data/spec/spec_helper.rb +2 -0
- data/spec/utilization_spec.rb +10 -0
- metadata +32 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc7b659e66478ddb954b8144e47cd83cbf80acd54e16f7f051c82f07f47c221f
|
4
|
+
data.tar.gz: fb1ab6344af206a17085bf42134622fef72e57093bad247ce8efaa2b823b8ff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b39b7a9ed13db3500fb782b1f1f5e75cc9d15261938f70e11788f84a96957a6f38ca3cc801bf84f7b5ee94cb4bac4a1bfed12ec9a4bc99fb5c01f73ed4ea860
|
7
|
+
data.tar.gz: 1de636e31c5d8c5897eda7282283a157553a032c81f26b58378c39a342021786285b851c59bd786dbbf3f5ea536ed3cd4f564c415240887af136e46e18345c2f
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
Notable changes to Pisoni will be tracked in this document.
|
4
4
|
|
5
|
+
## 1.30.0 - 2024-02-29
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- Fixed the issue with fetching utilization and managing referrer filters for applications with special characters in the
|
10
|
+
application IDs by escaping them. [#33](https://github.com/3scale/pisoni/pull/33)
|
11
|
+
- Upgrade dependencies, specifically `faraday` and `json`, making Ruby 2.6 the minimum supported version. [#34](https://github.com/3scale/pisoni/pull/34)
|
12
|
+
|
5
13
|
## 1.29.1 - 2023-11-30
|
6
14
|
|
7
15
|
### Changed
|
@@ -106,7 +106,7 @@ module ThreeScale
|
|
106
106
|
else
|
107
107
|
Core.faraday.send method, uri, attributes.to_json
|
108
108
|
end
|
109
|
-
rescue Faraday::
|
109
|
+
rescue Faraday::ClientError, SystemCallError => e
|
110
110
|
raise ConnectionError, e
|
111
111
|
end
|
112
112
|
private :api_http
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
1
3
|
module ThreeScale
|
2
4
|
module Core
|
3
5
|
module APIClient
|
@@ -38,6 +40,10 @@ module ThreeScale
|
|
38
40
|
@default_prefix = prefix
|
39
41
|
end
|
40
42
|
|
43
|
+
def url_encode(str)
|
44
|
+
ERB::Util.url_encode(str)
|
45
|
+
end
|
46
|
+
|
41
47
|
private
|
42
48
|
|
43
49
|
def internal_api_error(status)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
|
3
1
|
module ThreeScale
|
4
2
|
module Core
|
5
3
|
class Application < APIClient::Resource
|
@@ -18,16 +16,12 @@ module ThreeScale
|
|
18
16
|
private_class_method :base_uri
|
19
17
|
|
20
18
|
def self.app_uri(service_id, id)
|
21
|
-
|
22
|
-
|
23
|
-
"#{base_uri(service_id)}#{escaped_id}"
|
19
|
+
"#{base_uri(service_id)}#{url_encode(id)}"
|
24
20
|
end
|
25
21
|
private_class_method :app_uri
|
26
22
|
|
27
23
|
def self.key_uri(service_id, key)
|
28
|
-
|
29
|
-
|
30
|
-
"#{base_uri(service_id)}key/#{escaped_key}"
|
24
|
+
"#{base_uri(service_id)}key/#{url_encode(key)}"
|
31
25
|
end
|
32
26
|
private_class_method :key_uri
|
33
27
|
|
@@ -77,8 +71,7 @@ module ThreeScale
|
|
77
71
|
|
78
72
|
def self.save_id_by_key(service_id, user_key, id)
|
79
73
|
raise ApplicationHasInconsistentData.new(id, user_key) if (service_id.nil? || id.nil? || user_key.nil? || service_id=="" || id=="" || user_key=="")
|
80
|
-
|
81
|
-
ret = api_do_put({}, uri: "#{app_uri(service_id, id)}/key/#{escaped_key}")
|
74
|
+
ret = api_do_put({}, uri: "#{app_uri(service_id, id)}/key/#{url_encode(user_key)}")
|
82
75
|
ret[:ok]
|
83
76
|
end
|
84
77
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
|
3
1
|
module ThreeScale
|
4
2
|
module Core
|
5
3
|
class ApplicationKey < APIClient::Resource
|
@@ -23,12 +21,12 @@ module ThreeScale
|
|
23
21
|
end
|
24
22
|
|
25
23
|
def self.base_uri(service_id, application_id)
|
26
|
-
"#{default_uri}#{service_id}/applications/#{
|
24
|
+
"#{default_uri}#{service_id}/applications/#{url_encode(application_id)}/keys/"
|
27
25
|
end
|
28
26
|
private_class_method :base_uri
|
29
27
|
|
30
28
|
def self.application_key_uri(service_id, application_id, value = '')
|
31
|
-
"#{base_uri(service_id, application_id)}#{
|
29
|
+
"#{base_uri(service_id, application_id)}#{url_encode(value)}"
|
32
30
|
end
|
33
31
|
private_class_method :application_key_uri
|
34
32
|
end
|
@@ -25,7 +25,7 @@ module ThreeScale
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.base_uri(service_id, application_id)
|
28
|
-
"#{default_uri}#{service_id}/applications/#{application_id}/referrer_filters"
|
28
|
+
"#{default_uri}#{service_id}/applications/#{url_encode(application_id)}/referrer_filters"
|
29
29
|
end
|
30
30
|
private_class_method :base_uri
|
31
31
|
end
|
@@ -6,7 +6,7 @@ module ThreeScale
|
|
6
6
|
default_uri '/internal/services/'
|
7
7
|
|
8
8
|
def self.utilization_uri(service_id, app_id)
|
9
|
-
"#{default_uri}#{service_id}/applications/#{app_id}/utilization/"
|
9
|
+
"#{default_uri}#{service_id}/applications/#{url_encode(app_id)}/utilization/"
|
10
10
|
end
|
11
11
|
private_class_method :utilization_uri
|
12
12
|
|
data/lib/3scale/core/version.rb
CHANGED
data/lib/3scale/core.rb
CHANGED
@@ -1,14 +1,7 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'json'
|
3
3
|
require 'faraday'
|
4
|
-
require '
|
5
|
-
|
6
|
-
# Warn that Faraday < 0.13 and Net::HTTP::Persistent >= 3.0.0 don't mix well
|
7
|
-
if Faraday::VERSION =~ /0\.([0-9]|1[012])\.\d+/ &&
|
8
|
-
Net::HTTP::Persistent::VERSION =~ /^[^012]\.\d+\.\d+/
|
9
|
-
warn 'The combination of faraday < 0.13 and net-http-persistent 3.0+ is ' \
|
10
|
-
'known to have issues. See https://github.com/lostisland/faraday/issues/617'
|
11
|
-
end
|
4
|
+
require 'faraday/net_http_persistent'
|
12
5
|
|
13
6
|
require '3scale/core/version'
|
14
7
|
require '3scale/core/logger'
|
@@ -56,7 +49,7 @@ module ThreeScale
|
|
56
49
|
@password = uri.password
|
57
50
|
end
|
58
51
|
|
59
|
-
@faraday.
|
52
|
+
@faraday.set_basic_auth(@username, @password) if @username || @password
|
60
53
|
@faraday
|
61
54
|
end
|
62
55
|
|
data/pisoni.gemspec
CHANGED
@@ -18,12 +18,13 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.description = 'Client for the Apisonator internal API for model data.'
|
19
19
|
s.license = 'Apache-2.0'
|
20
20
|
|
21
|
-
|
22
|
-
s.
|
23
|
-
s.
|
24
|
-
s.
|
21
|
+
# faraday v2.9.0 removes support for Ruby 2.7, see https://github.com/lostisland/faraday/releases/tag/v2.9.0
|
22
|
+
s.add_runtime_dependency 'faraday', '~> 2.0', '<= 2.9'
|
23
|
+
s.add_runtime_dependency 'json', '~> 2.7', '>= 2.7.1'
|
24
|
+
s.add_runtime_dependency 'injectedlogger', '0.0.13'
|
25
|
+
s.add_runtime_dependency 'faraday-net_http_persistent', '~> 2.1'
|
25
26
|
|
26
|
-
s.add_development_dependency 'rake'
|
27
|
+
s.add_development_dependency 'rake', '~> 13.1'
|
27
28
|
|
28
29
|
s.files = `git ls-files`.split($/).reject do |f| [
|
29
30
|
%r{^\.[^\/]},
|
@@ -39,5 +40,5 @@ Gem::Specification.new do |s|
|
|
39
40
|
|
40
41
|
s.rdoc_options = ["--charset=UTF-8"]
|
41
42
|
|
42
|
-
s.required_ruby_version = '>= 2.
|
43
|
+
s.required_ruby_version = '>= 2.6.0'
|
43
44
|
end
|
@@ -59,7 +59,7 @@ module ThreeScale
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe 'with a key that contains special chars (*, _, etc.)' do
|
62
|
-
let(:key) {
|
62
|
+
let(:key) { SPECIAL_CHARACTERS }
|
63
63
|
|
64
64
|
before do
|
65
65
|
ApplicationKey.delete(service_id, app_id, key)
|
@@ -74,8 +74,8 @@ module ThreeScale
|
|
74
74
|
end
|
75
75
|
|
76
76
|
describe 'with app ID that contains special characters ({, $, ? etc.)' do
|
77
|
-
let(:app_id) {
|
78
|
-
let(:key) {
|
77
|
+
let(:app_id) { SPECIAL_CHARACTERS }
|
78
|
+
let(:key) { SPECIAL_CHARACTERS }
|
79
79
|
|
80
80
|
before do
|
81
81
|
ApplicationKey.delete(service_id, app_id, key)
|
@@ -119,7 +119,7 @@ module ThreeScale
|
|
119
119
|
end
|
120
120
|
|
121
121
|
describe 'with a key that contains special chars (*, _, etc.)' do
|
122
|
-
let(:key_with_special_chars) {
|
122
|
+
let(:key_with_special_chars) { SPECIAL_CHARACTERS }
|
123
123
|
|
124
124
|
before do
|
125
125
|
ApplicationKey.save(service_id, app_id, key)
|
@@ -3,7 +3,7 @@ module ThreeScale
|
|
3
3
|
module Core
|
4
4
|
describe ApplicationReferrerFilter do
|
5
5
|
let(:service_id) { 10 }
|
6
|
-
let(:app_id) {
|
6
|
+
let(:app_id) { SPECIAL_CHARACTERS }
|
7
7
|
let(:filters) { %w(foo bar doopah) }
|
8
8
|
let(:application) do
|
9
9
|
{ service_id: service_id,
|
@@ -24,6 +24,8 @@ module ThreeScale
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe '.load_all' do
|
27
|
+
subject { ApplicationReferrerFilter.load_all(service_id, app_id) }
|
28
|
+
|
27
29
|
describe 'Getting all referrer filters' do
|
28
30
|
let(:ref_filters) { %w(foo bar) }
|
29
31
|
|
@@ -32,14 +34,13 @@ module ThreeScale
|
|
32
34
|
end
|
33
35
|
|
34
36
|
it 'returns a sorted list of filters' do
|
35
|
-
|
36
|
-
filters.must_equal ref_filters.sort
|
37
|
+
subject.must_equal ref_filters.sort
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
describe 'when there are no referrer filters' do
|
41
42
|
it 'returns an empty list' do
|
42
|
-
|
43
|
+
subject.must_equal []
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
data/spec/application_spec.rb
CHANGED
@@ -47,7 +47,7 @@ module ThreeScale
|
|
47
47
|
|
48
48
|
describe 'with an app ID that contains special characters' do
|
49
49
|
let(:service_id) { 2001 }
|
50
|
-
let(:app_id) {
|
50
|
+
let(:app_id) { SPECIAL_CHARACTERS }
|
51
51
|
|
52
52
|
before do
|
53
53
|
Application.save service_id: service_id, id: app_id, state: 'suspended',
|
@@ -90,7 +90,7 @@ module ThreeScale
|
|
90
90
|
|
91
91
|
describe 'with an app ID that contains special characters' do
|
92
92
|
let(:service_id) { 2001 }
|
93
|
-
let(:app_id) {
|
93
|
+
let(:app_id) { SPECIAL_CHARACTERS }
|
94
94
|
|
95
95
|
before do
|
96
96
|
Application.save service_id: service_id, id: app_id, state: 'suspended',
|
@@ -157,7 +157,7 @@ module ThreeScale
|
|
157
157
|
|
158
158
|
describe 'with an app ID that contains special characters' do
|
159
159
|
let(:service_id) { 2001 }
|
160
|
-
let(:app_id) {
|
160
|
+
let(:app_id) { SPECIAL_CHARACTERS }
|
161
161
|
|
162
162
|
before do
|
163
163
|
Application.delete(service_id, app_id)
|
@@ -271,7 +271,7 @@ module ThreeScale
|
|
271
271
|
|
272
272
|
describe 'by_key' do
|
273
273
|
let(:key) { 'a_key' }
|
274
|
-
let(:key_with_special_chars) {
|
274
|
+
let(:key_with_special_chars) { SPECIAL_CHARACTERS }
|
275
275
|
let(:service_id) { 2001 }
|
276
276
|
let(:app_id) { 8011 }
|
277
277
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/utilization_spec.rb
CHANGED
@@ -105,6 +105,16 @@ module ThreeScale
|
|
105
105
|
Utilization.load(service_id, non_existing_app_id).must_be_nil
|
106
106
|
end
|
107
107
|
end
|
108
|
+
|
109
|
+
describe 'with an application ID with special characters' do
|
110
|
+
let(:app_id) { SPECIAL_CHARACTERS }
|
111
|
+
|
112
|
+
subject { Utilization.load(service_id, app_id) }
|
113
|
+
|
114
|
+
it 'gets expected results' do
|
115
|
+
subject.wont_be_empty
|
116
|
+
end
|
117
|
+
end
|
108
118
|
end
|
109
119
|
end
|
110
120
|
end
|
metadata
CHANGED
@@ -1,85 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pisoni
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.30.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:
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
- - "<="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: '2.9'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0
|
29
|
+
version: '2.0'
|
30
|
+
- - "<="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.9'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: json
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.7'
|
31
40
|
- - ">="
|
32
41
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
42
|
+
version: 2.7.1
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.7'
|
38
50
|
- - ">="
|
39
51
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
52
|
+
version: 2.7.1
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: injectedlogger
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
44
56
|
requirements:
|
45
|
-
- -
|
57
|
+
- - '='
|
46
58
|
- !ruby/object:Gem::Version
|
47
59
|
version: 0.0.13
|
48
60
|
type: :runtime
|
49
61
|
prerelease: false
|
50
62
|
version_requirements: !ruby/object:Gem::Requirement
|
51
63
|
requirements:
|
52
|
-
- -
|
64
|
+
- - '='
|
53
65
|
- !ruby/object:Gem::Version
|
54
66
|
version: 0.0.13
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
68
|
+
name: faraday-net_http_persistent
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
58
70
|
requirements:
|
59
|
-
- - "
|
71
|
+
- - "~>"
|
60
72
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
73
|
+
version: '2.1'
|
62
74
|
type: :runtime
|
63
75
|
prerelease: false
|
64
76
|
version_requirements: !ruby/object:Gem::Requirement
|
65
77
|
requirements:
|
66
|
-
- - "
|
78
|
+
- - "~>"
|
67
79
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
80
|
+
version: '2.1'
|
69
81
|
- !ruby/object:Gem::Dependency
|
70
82
|
name: rake
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
72
84
|
requirements:
|
73
|
-
- - "
|
85
|
+
- - "~>"
|
74
86
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
87
|
+
version: '13.1'
|
76
88
|
type: :development
|
77
89
|
prerelease: false
|
78
90
|
version_requirements: !ruby/object:Gem::Requirement
|
79
91
|
requirements:
|
80
|
-
- - "
|
92
|
+
- - "~>"
|
81
93
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
94
|
+
version: '13.1'
|
83
95
|
description: Client for the Apisonator internal API for model data.
|
84
96
|
email:
|
85
97
|
- alex@3scale.net
|
@@ -146,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
158
|
requirements:
|
147
159
|
- - ">="
|
148
160
|
- !ruby/object:Gem::Version
|
149
|
-
version: 2.
|
161
|
+
version: 2.6.0
|
150
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
163
|
requirements:
|
152
164
|
- - ">="
|