scalingo 3.3.0 → 3.5.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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependabot.yml +17 -0
  3. data/.github/workflows/publish.yml +6 -3
  4. data/.github/workflows/ruby.yml +3 -3
  5. data/.rubocop.yml +9 -21
  6. data/CHANGELOG.md +10 -0
  7. data/README.md +1 -1
  8. data/lib/scalingo/api/client.rb +6 -15
  9. data/lib/scalingo/api/response.rb +3 -3
  10. data/lib/scalingo/auth/tokens.rb +2 -2
  11. data/lib/scalingo/auth.rb +1 -1
  12. data/lib/scalingo/billing.rb +1 -1
  13. data/lib/scalingo/client.rb +6 -6
  14. data/lib/scalingo/configuration.rb +3 -3
  15. data/lib/scalingo/core_client.rb +2 -3
  16. data/lib/scalingo/regional/addons.rb +1 -1
  17. data/lib/scalingo/regional.rb +1 -1
  18. data/lib/scalingo/regional_database/databases.rb +13 -0
  19. data/lib/scalingo/regional_database.rb +1 -1
  20. data/lib/scalingo/token_holder.rb +1 -1
  21. data/lib/scalingo/version.rb +1 -1
  22. data/samples/regional_database/backups/_meta.json +1 -1
  23. data/samples/regional_database/backups/archive-200.json +2 -2
  24. data/samples/regional_database/backups/archive-400.json +1 -1
  25. data/samples/regional_database/backups/create-201.json +1 -1
  26. data/samples/regional_database/backups/create-400.json +1 -1
  27. data/samples/regional_database/backups/for-200.json +1 -1
  28. data/samples/regional_database/backups/for-400.json +1 -1
  29. data/samples/regional_database/databases/_meta.json +1 -1
  30. data/samples/regional_database/databases/find-200.json +5 -3
  31. data/samples/regional_database/databases/find-400.json +1 -1
  32. data/samples/regional_database/databases/upgrade-202.json +39 -0
  33. data/samples/regional_database/databases/upgrade-400.json +24 -0
  34. data/scalingo.gemspec +4 -7
  35. metadata +13 -92
  36. data/spec/scalingo/api/client_spec.rb +0 -256
  37. data/spec/scalingo/api/endpoint_spec.rb +0 -45
  38. data/spec/scalingo/api/response_spec.rb +0 -301
  39. data/spec/scalingo/auth/keys_spec.rb +0 -58
  40. data/spec/scalingo/auth/scm_integrations_spec.rb +0 -58
  41. data/spec/scalingo/auth/tokens_spec.rb +0 -74
  42. data/spec/scalingo/auth/two_factor_auth_spec.rb +0 -69
  43. data/spec/scalingo/auth/user_spec.rb +0 -31
  44. data/spec/scalingo/auth_spec.rb +0 -15
  45. data/spec/scalingo/bearer_token_spec.rb +0 -72
  46. data/spec/scalingo/billing/profile_spec.rb +0 -55
  47. data/spec/scalingo/billing_spec.rb +0 -11
  48. data/spec/scalingo/client_spec.rb +0 -93
  49. data/spec/scalingo/configuration_spec.rb +0 -57
  50. data/spec/scalingo/core_client_spec.rb +0 -23
  51. data/spec/scalingo/regional/addons_spec.rb +0 -169
  52. data/spec/scalingo/regional/apps_spec.rb +0 -137
  53. data/spec/scalingo/regional/autoscalers_spec.rb +0 -84
  54. data/spec/scalingo/regional/collaborators_spec.rb +0 -69
  55. data/spec/scalingo/regional/containers_spec.rb +0 -67
  56. data/spec/scalingo/regional/deployments_spec.rb +0 -45
  57. data/spec/scalingo/regional/domains_spec.rb +0 -84
  58. data/spec/scalingo/regional/environment_spec.rb +0 -77
  59. data/spec/scalingo/regional/events_spec.rb +0 -65
  60. data/spec/scalingo/regional/logs_spec.rb +0 -39
  61. data/spec/scalingo/regional/metrics_spec.rb +0 -46
  62. data/spec/scalingo/regional/notifiers_spec.rb +0 -113
  63. data/spec/scalingo/regional/operations_spec.rb +0 -27
  64. data/spec/scalingo/regional/scm_repo_links_spec.rb +0 -48
  65. data/spec/scalingo/regional_database/backups_spec.rb +0 -58
  66. data/spec/scalingo/regional_database/databases_spec.rb +0 -23
  67. data/spec/scalingo/regional_database_spec.rb +0 -11
  68. data/spec/scalingo/regional_spec.rb +0 -14
  69. data/spec/scalingo/token_holder_spec.rb +0 -81
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scalingo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo Unbekandt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-01-03 00:00:00.000000000 Z
12
+ date: 2024-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -37,28 +37,14 @@ dependencies:
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
41
- type: :runtime
42
- prerelease: false
43
- version_requirements: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.0'
48
- - !ruby/object:Gem::Dependency
49
- name: faraday_middleware
50
- requirement: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.0'
40
+ version: '2.0'
55
41
  type: :runtime
56
42
  prerelease: false
57
43
  version_requirements: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '1.0'
47
+ version: '2.0'
62
48
  - !ruby/object:Gem::Dependency
63
49
  name: multi_json
64
50
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +113,14 @@ dependencies:
127
113
  requirements:
128
114
  - - "~>"
129
115
  - !ruby/object:Gem::Version
130
- version: 1.1.0
116
+ version: '1.32'
131
117
  type: :development
132
118
  prerelease: false
133
119
  version_requirements: !ruby/object:Gem::Requirement
134
120
  requirements:
135
121
  - - "~>"
136
122
  - !ruby/object:Gem::Version
137
- version: 1.1.0
123
+ version: '1.32'
138
124
  - !ruby/object:Gem::Dependency
139
125
  name: rubocop-rspec
140
126
  requirement: !ruby/object:Gem::Requirement
@@ -169,14 +155,14 @@ dependencies:
169
155
  requirements:
170
156
  - - "~>"
171
157
  - !ruby/object:Gem::Version
172
- version: 3.12.2
158
+ version: '3.19'
173
159
  type: :development
174
160
  prerelease: false
175
161
  version_requirements: !ruby/object:Gem::Requirement
176
162
  requirements:
177
163
  - - "~>"
178
164
  - !ruby/object:Gem::Version
179
- version: 3.12.2
165
+ version: '3.19'
180
166
  description: Ruby client library for the web APIs of Scalingo, a european Platform-as-a-Service
181
167
  email:
182
168
  - leo@scalingo.com
@@ -186,6 +172,7 @@ extensions: []
186
172
  extra_rdoc_files: []
187
173
  files:
188
174
  - ".github/dependabot.yml"
175
+ - ".github/workflows/dependabot.yml"
189
176
  - ".github/workflows/publish.yml"
190
177
  - ".github/workflows/ruby.yml"
191
178
  - ".gitignore"
@@ -428,41 +415,9 @@ files:
428
415
  - samples/regional_database/databases/_meta.json
429
416
  - samples/regional_database/databases/find-200.json
430
417
  - samples/regional_database/databases/find-400.json
418
+ - samples/regional_database/databases/upgrade-202.json
419
+ - samples/regional_database/databases/upgrade-400.json
431
420
  - scalingo.gemspec
432
- - spec/scalingo/api/client_spec.rb
433
- - spec/scalingo/api/endpoint_spec.rb
434
- - spec/scalingo/api/response_spec.rb
435
- - spec/scalingo/auth/keys_spec.rb
436
- - spec/scalingo/auth/scm_integrations_spec.rb
437
- - spec/scalingo/auth/tokens_spec.rb
438
- - spec/scalingo/auth/two_factor_auth_spec.rb
439
- - spec/scalingo/auth/user_spec.rb
440
- - spec/scalingo/auth_spec.rb
441
- - spec/scalingo/bearer_token_spec.rb
442
- - spec/scalingo/billing/profile_spec.rb
443
- - spec/scalingo/billing_spec.rb
444
- - spec/scalingo/client_spec.rb
445
- - spec/scalingo/configuration_spec.rb
446
- - spec/scalingo/core_client_spec.rb
447
- - spec/scalingo/regional/addons_spec.rb
448
- - spec/scalingo/regional/apps_spec.rb
449
- - spec/scalingo/regional/autoscalers_spec.rb
450
- - spec/scalingo/regional/collaborators_spec.rb
451
- - spec/scalingo/regional/containers_spec.rb
452
- - spec/scalingo/regional/deployments_spec.rb
453
- - spec/scalingo/regional/domains_spec.rb
454
- - spec/scalingo/regional/environment_spec.rb
455
- - spec/scalingo/regional/events_spec.rb
456
- - spec/scalingo/regional/logs_spec.rb
457
- - spec/scalingo/regional/metrics_spec.rb
458
- - spec/scalingo/regional/notifiers_spec.rb
459
- - spec/scalingo/regional/operations_spec.rb
460
- - spec/scalingo/regional/scm_repo_links_spec.rb
461
- - spec/scalingo/regional_database/backups_spec.rb
462
- - spec/scalingo/regional_database/databases_spec.rb
463
- - spec/scalingo/regional_database_spec.rb
464
- - spec/scalingo/regional_spec.rb
465
- - spec/scalingo/token_holder_spec.rb
466
421
  homepage: https://www.scalingo.com
467
422
  licenses:
468
423
  - MIT
@@ -487,42 +442,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
487
442
  - !ruby/object:Gem::Version
488
443
  version: '0'
489
444
  requirements: []
490
- rubygems_version: 3.4.1
445
+ rubygems_version: 3.5.4
491
446
  signing_key:
492
447
  specification_version: 4
493
448
  summary: Ruby client for Scalingo APIs
494
- test_files:
495
- - spec/scalingo/api/client_spec.rb
496
- - spec/scalingo/api/endpoint_spec.rb
497
- - spec/scalingo/api/response_spec.rb
498
- - spec/scalingo/auth/keys_spec.rb
499
- - spec/scalingo/auth/scm_integrations_spec.rb
500
- - spec/scalingo/auth/tokens_spec.rb
501
- - spec/scalingo/auth/two_factor_auth_spec.rb
502
- - spec/scalingo/auth/user_spec.rb
503
- - spec/scalingo/auth_spec.rb
504
- - spec/scalingo/bearer_token_spec.rb
505
- - spec/scalingo/billing/profile_spec.rb
506
- - spec/scalingo/billing_spec.rb
507
- - spec/scalingo/client_spec.rb
508
- - spec/scalingo/configuration_spec.rb
509
- - spec/scalingo/core_client_spec.rb
510
- - spec/scalingo/regional/addons_spec.rb
511
- - spec/scalingo/regional/apps_spec.rb
512
- - spec/scalingo/regional/autoscalers_spec.rb
513
- - spec/scalingo/regional/collaborators_spec.rb
514
- - spec/scalingo/regional/containers_spec.rb
515
- - spec/scalingo/regional/deployments_spec.rb
516
- - spec/scalingo/regional/domains_spec.rb
517
- - spec/scalingo/regional/environment_spec.rb
518
- - spec/scalingo/regional/events_spec.rb
519
- - spec/scalingo/regional/logs_spec.rb
520
- - spec/scalingo/regional/metrics_spec.rb
521
- - spec/scalingo/regional/notifiers_spec.rb
522
- - spec/scalingo/regional/operations_spec.rb
523
- - spec/scalingo/regional/scm_repo_links_spec.rb
524
- - spec/scalingo/regional_database/backups_spec.rb
525
- - spec/scalingo/regional_database/databases_spec.rb
526
- - spec/scalingo/regional_database_spec.rb
527
- - spec/scalingo/regional_spec.rb
528
- - spec/scalingo/token_holder_spec.rb
449
+ test_files: []
@@ -1,256 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Scalingo::API::Client do
4
- let(:url) { "http://localhost" }
5
-
6
- subject { described_class.new(url, scalingo: scalingo) }
7
-
8
- describe "initialize" do
9
- let(:config) { {default_region: :test} }
10
-
11
- describe "with only url" do
12
- subject { described_class.new(:url) }
13
-
14
- it "stores the url" do
15
- expect(subject.url).to eq(:url)
16
- end
17
-
18
- it "uses itself as token holder" do
19
- expect(subject.token_holder).to eq(subject)
20
- end
21
-
22
- it "configuration is the global one" do
23
- expect(Scalingo::Configuration).to receive(:new).with({}, Scalingo.config).and_return(:config).once
24
-
25
- expect(subject.config).to eq(:config)
26
- end
27
- end
28
-
29
- describe "with scalingo client supplied" do
30
- subject { described_class.new(:url, scalingo: scalingo) }
31
-
32
- it "uses the scalingo client as token holder" do
33
- expect(subject.token_holder).to eq(scalingo)
34
- end
35
-
36
- it "configuration is herited from the scalingo client" do
37
- expect(Scalingo::Configuration).to receive(:new).with({}, scalingo.config).once
38
-
39
- subject
40
- end
41
- end
42
-
43
- describe "with config supplied" do
44
- subject { described_class.new(:url, config: config) }
45
-
46
- it "configuration is herited from the global one" do
47
- expect(Scalingo::Configuration).to receive(:new).with(config, Scalingo.config).and_return(:config).once
48
-
49
- expect(subject.config).to eq(:config)
50
- end
51
- end
52
-
53
- describe "with both supplied" do
54
- subject { described_class.new(:url, scalingo: scalingo, config: config) }
55
-
56
- it "configuration is herited from the scalingo one" do
57
- expect(Scalingo::Configuration).to receive(:new).with(config, scalingo.config).once
58
-
59
- subject
60
- end
61
- end
62
- end
63
-
64
- describe "self.register_handler(s)!" do
65
- it "is called for each key/value pair" do
66
- expect(described_class).to receive(:register_handler!).with(:a, :b).once
67
- expect(described_class).to receive(:register_handler!).with(:c, :d).once
68
-
69
- described_class.register_handlers!(a: :b, c: :d)
70
- end
71
-
72
- it "defines a lazy-loaded memoized getter, returning an instance of the class supplied" do
73
- mock = double
74
-
75
- described_class.register_handler!(:handler, mock)
76
- instance = described_class.new(:url, scalingo: scalingo)
77
-
78
- # Only 1 instanciation should be done, no matter how many calls are done below
79
- expect(mock).to receive(:new).with(instance).and_return("1st").once
80
-
81
- # Not yet loaded...
82
- expect(instance.instance_variable_get(:@handler)).to eq(nil)
83
- instance.handler
84
-
85
- # Memoized...
86
- expect(instance.instance_variable_get(:@handler)).not_to eq(nil)
87
-
88
- # More calls won't try to perform more instanciations
89
- instance.handler
90
- instance.handler
91
- end
92
- end
93
-
94
- describe "headers" do
95
- before do
96
- expect(scalingo.config).to receive(:user_agent).and_return(user_agent).once
97
- end
98
-
99
- let(:user_agent) { "user agent" }
100
- let(:extra_hash) { {"X-Other" => "other"} }
101
- let(:extra_block) {
102
- proc { {"X-Another" => "another"} }
103
- }
104
-
105
- it "only returns the user agent and accept if nothing else is configured" do
106
- expect(subject.headers).to eq("Accept" => "application/json", "User-Agent" => user_agent)
107
- end
108
-
109
- it "allows additional headers to be globally configured" do
110
- expect(scalingo.config).to receive(:additional_headers).and_return(extra_hash)
111
-
112
- expect(subject.headers).to eq("Accept" => "application/json", "User-Agent" => user_agent, "X-Other" => "other")
113
- end
114
-
115
- it "additional headers can be a block" do
116
- expect(scalingo.config).to receive(:additional_headers).and_return(extra_block)
117
-
118
- expect(subject.headers).to eq("Accept" => "application/json", "User-Agent" => user_agent, "X-Another" => "another")
119
- end
120
- end
121
-
122
- describe "connection_options" do
123
- it "returns the url and headers" do
124
- expect(subject).to receive(:url).and_return("url").once
125
- expect(subject).to receive(:headers).and_return("headers").once
126
-
127
- expect(subject.connection_options).to eq(url: "url", headers: "headers")
128
- end
129
- end
130
-
131
- describe "unauthenticated_connection" do
132
- it "returns a memoized object" do
133
- expect(Faraday).to receive(:new).with(subject.connection_options).and_return("faraday").once
134
-
135
- expect(subject.unauthenticated_connection).to eq "faraday"
136
-
137
- subject.unauthenticated_connection
138
- subject.unauthenticated_connection
139
- end
140
-
141
- it "has no authentication header set" do
142
- expect(subject.unauthenticated_connection.headers.key?("Authorization")).not_to be true
143
- end
144
- end
145
-
146
- describe "authenticated_connection" do
147
- context "without bearer token" do
148
- let(:scalingo) { scalingo_guest }
149
-
150
- it "raises if configured to" do
151
- expect(scalingo.config).to receive(:raise_on_missing_authentication).and_return(true).once
152
-
153
- expect {
154
- subject.authenticated_connection
155
- }.to raise_error(Scalingo::Error::Unauthenticated)
156
- end
157
-
158
- it "returns an unauthenticated connection if configured to not raise" do
159
- expect(scalingo.config).to receive(:raise_on_missing_authentication).and_return(false).once
160
-
161
- expect(subject).to receive(:unauthenticated_connection).and_return(:object).once
162
- expect(subject.authenticated_connection).to eq(:object)
163
- end
164
- end
165
-
166
- context "with bearer token" do
167
- it "has an authentication header set with a bearer scheme" do
168
- expect(subject.connection.headers["Authorization"]).to eq "Bearer #{subject.token_holder.token.value}"
169
- end
170
- end
171
- end
172
-
173
- describe "database_connection" do
174
- let(:database_id) { "db-id-1234" }
175
-
176
- context "without bearer token" do
177
- let(:scalingo) { scalingo_guest }
178
-
179
- it "raises" do
180
- expect {
181
- subject.database_connection(database_id)
182
- }.to raise_error(Scalingo::Error::Unauthenticated)
183
- end
184
- end
185
-
186
- context "with bearer token" do
187
- it "has an authentication header set with a bearer scheme" do
188
- scalingo.authenticate_database_with_bearer_token(
189
- database_id,
190
- "1234",
191
- expires_at: Time.now + 1.hour,
192
- raise_on_expired_token: false,
193
- )
194
- expect(subject.database_connection(database_id).headers["Authorization"]).to eq "Bearer #{subject.token_holder.database_tokens[database_id].value}"
195
- end
196
- end
197
-
198
- context "with wrong bearer token" do
199
- it "raises" do
200
- database_id_2 = "db-id-5678"
201
- scalingo.authenticate_database_with_bearer_token(
202
- database_id_2,
203
- "1234",
204
- expires_at: Time.now + 1.hour,
205
- raise_on_expired_token: false,
206
- )
207
- expect {
208
- subject.database_connection(database_id)
209
- }.to raise_error(Scalingo::Error::Unauthenticated)
210
- end
211
- end
212
- end
213
-
214
- describe "connection" do
215
- context "logged" do
216
- context "no fallback to guest" do
217
- it "calls and return the authenticated_connection" do
218
- expect(subject).to receive(:authenticated_connection).and_return(:conn)
219
- expect(subject.connection).to eq(:conn)
220
- end
221
- end
222
-
223
- context "with fallback to guest" do
224
- it "calls and return the authenticated_connection" do
225
- expect(subject).to receive(:authenticated_connection).and_return(:conn)
226
- expect(subject.connection(fallback_to_guest: true)).to eq(:conn)
227
- end
228
- end
229
- end
230
-
231
- context "not logged" do
232
- let(:scalingo) { scalingo_guest }
233
-
234
- context "no fallback to guest" do
235
- it "raises when set to raise" do
236
- expect(scalingo.config).to receive(:raise_on_missing_authentication).and_return(true).once
237
-
238
- expect { subject.connection }.to raise_error(Scalingo::Error::Unauthenticated)
239
- end
240
-
241
- it "calls and return the unauthenticated_connection when set not to raise" do
242
- expect(scalingo.config).to receive(:raise_on_missing_authentication).and_return(false).once
243
- expect(subject).to receive(:unauthenticated_connection).and_return(:conn)
244
- expect(subject.connection(fallback_to_guest: true)).to eq(:conn)
245
- end
246
- end
247
-
248
- context "with fallback to guest" do
249
- it "calls and return the unauthenticated_connection" do
250
- expect(subject).to receive(:unauthenticated_connection).and_return(:conn)
251
- expect(subject.connection(fallback_to_guest: true)).to eq(:conn)
252
- end
253
- end
254
- end
255
- end
256
- end
@@ -1,45 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Scalingo::API::Endpoint do
4
- let(:client) { double }
5
-
6
- subject { described_class.new(client) }
7
-
8
- describe "initialize" do
9
- it "stores the client" do
10
- instance = described_class.new(:client)
11
-
12
- expect(instance.client).to eq(:client)
13
- end
14
- end
15
-
16
- describe "connection" do
17
- it "delegates the connection to the client" do
18
- expect(client).to receive(:connection).and_return(:value).once
19
- expect(subject.connection).to eq :value
20
- end
21
- end
22
-
23
- describe "unpack" do
24
- it "forwards unpack to Response without keys" do
25
- mock = proc { 1 }
26
-
27
- expect(Scalingo::API::Response).to receive(:unpack).with(client, keys: [], &mock).and_return(:d).once
28
- expect(subject.send(:unpack, &mock)).to eq :d
29
- end
30
-
31
- it "forwards unpack to Response with a single key" do
32
- mock = proc { 1 }
33
-
34
- expect(Scalingo::API::Response).to receive(:unpack).with(client, keys: [:a], &mock).and_return(:d).once
35
- expect(subject.send(:unpack, :a, &mock)).to eq :d
36
- end
37
-
38
- it "forwards unpack to Response with many keys" do
39
- mock = proc { 1 }
40
-
41
- expect(Scalingo::API::Response).to receive(:unpack).with(client, keys: [:a, :b], &mock).and_return(:d).once
42
- expect(subject.send(:unpack, :a, :b, &mock)).to eq :d
43
- end
44
- end
45
- end