scalingo 3.0.0.beta.2 → 3.0.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/CHANGELOG.md +11 -0
- data/README.md +4 -14
- data/lib/scalingo/api/client.rb +38 -10
- data/lib/scalingo/api/endpoint.rb +12 -2
- data/lib/scalingo/api/response.rb +7 -1
- data/lib/scalingo/auth/keys.rb +4 -4
- data/lib/scalingo/auth/scm_integrations.rb +4 -4
- data/lib/scalingo/auth/tokens.rb +6 -6
- data/lib/scalingo/auth/two_factor_auth.rb +4 -4
- data/lib/scalingo/auth/user.rb +2 -2
- data/lib/scalingo/bearer_token.rb +15 -0
- data/lib/scalingo/billing/profile.rb +3 -3
- data/lib/scalingo/client.rb +26 -113
- data/lib/scalingo/configuration.rb +7 -36
- data/lib/scalingo/core_client.rb +106 -0
- data/lib/scalingo/regional/addons.rb +21 -8
- data/lib/scalingo/regional/apps.rb +8 -8
- data/lib/scalingo/regional/collaborators.rb +4 -4
- data/lib/scalingo/regional/containers.rb +4 -4
- data/lib/scalingo/regional/deployments.rb +3 -3
- data/lib/scalingo/regional/domains.rb +5 -5
- data/lib/scalingo/regional/environment.rb +6 -6
- data/lib/scalingo/regional/events.rb +4 -4
- data/lib/scalingo/regional/logs.rb +2 -2
- data/lib/scalingo/regional/metrics.rb +2 -2
- data/lib/scalingo/regional/notifiers.rb +7 -7
- data/lib/scalingo/regional/operations.rb +1 -1
- data/lib/scalingo/regional/scm_repo_links.rb +8 -8
- data/lib/scalingo/token_holder.rb +31 -0
- data/lib/scalingo/version.rb +1 -1
- data/samples/regional/addons/token-200.json +49 -0
- data/samples/regional/addons/token-404.json +24 -0
- data/scalingo.gemspec +1 -1
- data/spec/scalingo/api/client_spec.rb +58 -11
- data/spec/scalingo/api/endpoint_spec.rb +3 -2
- data/spec/scalingo/api/response_spec.rb +16 -16
- data/spec/scalingo/auth_spec.rb +1 -1
- data/spec/scalingo/billing_spec.rb +11 -0
- data/spec/scalingo/configuration_spec.rb +32 -30
- data/spec/scalingo/regional/addons_spec.rb +16 -0
- data/spec/scalingo/regional_spec.rb +1 -1
- metadata +8 -2
@@ -22,9 +22,10 @@ RSpec.describe Scalingo::API::Endpoint do
|
|
22
22
|
|
23
23
|
describe "unpack" do
|
24
24
|
it "forwards unpack to Response" do
|
25
|
-
|
25
|
+
mock = proc { 1 }
|
26
26
|
|
27
|
-
expect(
|
27
|
+
expect(Scalingo::API::Response).to receive(:unpack).with(client, key: :a, &mock).and_return(:d).once
|
28
|
+
expect(subject.send(:unpack, :a, &mock)).to eq :d
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -33,19 +33,19 @@ RSpec.describe Scalingo::API::Response do
|
|
33
33
|
}
|
34
34
|
|
35
35
|
it "passes the client supplied" do
|
36
|
-
object = described_class.unpack(:some_client
|
36
|
+
object = described_class.unpack(:some_client) { response }
|
37
37
|
|
38
38
|
expect(object.client).to eq :some_client
|
39
39
|
end
|
40
40
|
|
41
41
|
it "passes the response status" do
|
42
|
-
object = described_class.unpack(:client
|
42
|
+
object = described_class.unpack(:client) { response }
|
43
43
|
|
44
44
|
expect(object.status).to eq status
|
45
45
|
end
|
46
46
|
|
47
47
|
it "passes the response headers" do
|
48
|
-
object = described_class.unpack(:client
|
48
|
+
object = described_class.unpack(:client) { response }
|
49
49
|
|
50
50
|
expect(object.headers).to eq headers
|
51
51
|
end
|
@@ -54,7 +54,7 @@ RSpec.describe Scalingo::API::Response do
|
|
54
54
|
let(:body) { "" }
|
55
55
|
|
56
56
|
it "without key" do
|
57
|
-
object = described_class.unpack(client
|
57
|
+
object = described_class.unpack(client) { response }
|
58
58
|
|
59
59
|
expect(object.data).to eq ""
|
60
60
|
expect(object.full_body).to eq ""
|
@@ -62,7 +62,7 @@ RSpec.describe Scalingo::API::Response do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "ignores key if supplied" do
|
65
|
-
object = described_class.unpack(client,
|
65
|
+
object = described_class.unpack(client, key: :key) { response }
|
66
66
|
|
67
67
|
expect(object.data).to eq ""
|
68
68
|
expect(object.full_body).to eq ""
|
@@ -74,7 +74,7 @@ RSpec.describe Scalingo::API::Response do
|
|
74
74
|
let(:body) { nil }
|
75
75
|
|
76
76
|
it "without key" do
|
77
|
-
object = described_class.unpack(client
|
77
|
+
object = described_class.unpack(client) { response }
|
78
78
|
|
79
79
|
expect(object.data).to eq nil
|
80
80
|
expect(object.full_body).to eq nil
|
@@ -82,7 +82,7 @@ RSpec.describe Scalingo::API::Response do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it "ignores key if supplied" do
|
85
|
-
object = described_class.unpack(client,
|
85
|
+
object = described_class.unpack(client, key: :key) { response }
|
86
86
|
|
87
87
|
expect(object.data).to eq nil
|
88
88
|
expect(object.full_body).to eq nil
|
@@ -94,7 +94,7 @@ RSpec.describe Scalingo::API::Response do
|
|
94
94
|
let(:body) { "this is a string body, probably due to an error" }
|
95
95
|
|
96
96
|
it "without key" do
|
97
|
-
object = described_class.unpack(client
|
97
|
+
object = described_class.unpack(client) { response }
|
98
98
|
|
99
99
|
expect(object.data).to eq body
|
100
100
|
expect(object.full_body).to eq body
|
@@ -102,7 +102,7 @@ RSpec.describe Scalingo::API::Response do
|
|
102
102
|
end
|
103
103
|
|
104
104
|
it "ignores key if supplied" do
|
105
|
-
object = described_class.unpack(client,
|
105
|
+
object = described_class.unpack(client, key: :key) { response }
|
106
106
|
|
107
107
|
expect(object.data).to eq body
|
108
108
|
expect(object.full_body).to eq body
|
@@ -116,7 +116,7 @@ RSpec.describe Scalingo::API::Response do
|
|
116
116
|
}
|
117
117
|
|
118
118
|
it "without key" do
|
119
|
-
object = described_class.unpack(client
|
119
|
+
object = described_class.unpack(client) { response }
|
120
120
|
|
121
121
|
expect(object.data).to eq body
|
122
122
|
expect(object.full_body).to eq body
|
@@ -124,7 +124,7 @@ RSpec.describe Scalingo::API::Response do
|
|
124
124
|
end
|
125
125
|
|
126
126
|
it "ignores key if supplied" do
|
127
|
-
object = described_class.unpack(client,
|
127
|
+
object = described_class.unpack(client, key: :root) { response }
|
128
128
|
|
129
129
|
expect(object.data).to eq body
|
130
130
|
expect(object.full_body).to eq body
|
@@ -138,7 +138,7 @@ RSpec.describe Scalingo::API::Response do
|
|
138
138
|
}
|
139
139
|
|
140
140
|
it "without key" do
|
141
|
-
object = described_class.unpack(client
|
141
|
+
object = described_class.unpack(client) { response }
|
142
142
|
|
143
143
|
expect(object.data).to eq body
|
144
144
|
expect(object.full_body).to eq body
|
@@ -146,7 +146,7 @@ RSpec.describe Scalingo::API::Response do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
it "with valid key" do
|
149
|
-
object = described_class.unpack(client,
|
149
|
+
object = described_class.unpack(client, key: :root) { response }
|
150
150
|
|
151
151
|
expect(object.data).to eq({key: :value})
|
152
152
|
expect(object.full_body).to eq body
|
@@ -154,7 +154,7 @@ RSpec.describe Scalingo::API::Response do
|
|
154
154
|
end
|
155
155
|
|
156
156
|
it "with invalid key" do
|
157
|
-
object = described_class.unpack(client,
|
157
|
+
object = described_class.unpack(client, key: :other) { response }
|
158
158
|
|
159
159
|
expect(object.data).to eq nil
|
160
160
|
expect(object.full_body).to eq body
|
@@ -167,7 +167,7 @@ RSpec.describe Scalingo::API::Response do
|
|
167
167
|
}
|
168
168
|
|
169
169
|
it "extracts the meta object" do
|
170
|
-
object = described_class.unpack(client
|
170
|
+
object = described_class.unpack(client) { response }
|
171
171
|
|
172
172
|
expect(object.meta).to eq({meta1: :value})
|
173
173
|
end
|
@@ -179,7 +179,7 @@ RSpec.describe Scalingo::API::Response do
|
|
179
179
|
let(:body) { {root: {key: :value}} }
|
180
180
|
|
181
181
|
it "does not dig in the response hash, even with a valid key" do
|
182
|
-
object = described_class.unpack(client,
|
182
|
+
object = described_class.unpack(client, key: :root) { response }
|
183
183
|
|
184
184
|
expect(object.data).to eq body
|
185
185
|
expect(object.full_body).to eq body
|
data/spec/scalingo/auth_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe Scalingo::Auth do
|
4
|
-
subject { described_class.new(
|
4
|
+
subject { described_class.new("url") }
|
5
5
|
|
6
6
|
%w[keys scm_integrations tokens two_factor_auth user].each do |section|
|
7
7
|
it "handles requests for #{section}" do
|
@@ -3,36 +3,6 @@ require "spec_helper"
|
|
3
3
|
RSpec.describe Scalingo::Configuration do
|
4
4
|
subject { described_class.default }
|
5
5
|
|
6
|
-
describe "default_region" do
|
7
|
-
it "must be an existing region" do
|
8
|
-
expect {
|
9
|
-
subject.default_region = "another-region"
|
10
|
-
}.to raise_error(ArgumentError)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "regions" do
|
15
|
-
it "can be assigned from a hash" do
|
16
|
-
subject.regions = {
|
17
|
-
local_name: "some-url"
|
18
|
-
}
|
19
|
-
|
20
|
-
expect(subject.regions.local_name).to eq "some-url"
|
21
|
-
end
|
22
|
-
|
23
|
-
it "can be assigned from a openstruct" do
|
24
|
-
subject.regions = OpenStruct.new(local_name: "some-url")
|
25
|
-
|
26
|
-
expect(subject.regions.local_name).to eq "some-url"
|
27
|
-
end
|
28
|
-
|
29
|
-
it "raises with an argument from the wrong type" do
|
30
|
-
expect {
|
31
|
-
subject.regions = "1"
|
32
|
-
}.to raise_error(ArgumentError)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
6
|
describe "inheritance" do
|
37
7
|
it "can inherit configuration from a parent" do
|
38
8
|
object = described_class.new({}, subject)
|
@@ -52,4 +22,36 @@ RSpec.describe Scalingo::Configuration do
|
|
52
22
|
expect(object.user_agent).to eq "Agent"
|
53
23
|
end
|
54
24
|
end
|
25
|
+
|
26
|
+
describe "faraday adapter" do
|
27
|
+
let(:scalingo) { Scalingo::Client.new(config).tap { |s| s.authenticate_with(bearer_token: "some-token") } }
|
28
|
+
let(:client) { Scalingo::API::Client.new("http://example.test", scalingo: scalingo) }
|
29
|
+
|
30
|
+
context "when unspecified" do
|
31
|
+
let(:config) { {} }
|
32
|
+
|
33
|
+
it "uses the default one when unspecificied" do
|
34
|
+
expect(client.authenticated_connection.adapter).to eq Faraday::Adapter::NetHttp
|
35
|
+
expect(client.unauthenticated_connection.adapter).to eq Faraday::Adapter::NetHttp
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when set to an unkown adapter" do
|
40
|
+
let(:config) { {faraday_adapter: :yo} }
|
41
|
+
|
42
|
+
it "uses the default one when unspecificied" do
|
43
|
+
expect { client.authenticated_connection.adapter }.to raise_error(Faraday::Error)
|
44
|
+
expect { client.unauthenticated_connection.adapter }.to raise_error(Faraday::Error)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when set to a valid adapter" do
|
49
|
+
let(:config) { {faraday_adapter: :test} }
|
50
|
+
|
51
|
+
it "uses the default one when unspecificied" do
|
52
|
+
expect(client.authenticated_connection.adapter).to eq Faraday::Adapter::Test
|
53
|
+
expect(client.unauthenticated_connection.adapter).to eq Faraday::Adapter::Test
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
55
57
|
end
|
@@ -99,6 +99,22 @@ RSpec.describe Scalingo::Regional::Addons do
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
describe_method "token" do
|
103
|
+
context "success" do
|
104
|
+
let(:arguments) { [meta[:app_id], meta[:id]] }
|
105
|
+
let(:stub_pattern) { "token-200" }
|
106
|
+
|
107
|
+
it_behaves_like "a singular object response"
|
108
|
+
end
|
109
|
+
|
110
|
+
context "not found" do
|
111
|
+
let(:arguments) { [meta[:app_id], meta[:not_found_id]] }
|
112
|
+
let(:stub_pattern) { "token-404" }
|
113
|
+
|
114
|
+
it_behaves_like "a not found response"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
102
118
|
describe_method "update" do
|
103
119
|
context "success" do
|
104
120
|
let(:arguments) { [meta[:app_id], meta[:id], meta[:update][:valid]] }
|
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.0.0.beta.
|
4
|
+
version: 3.0.0.beta.3
|
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: 2020-
|
12
|
+
date: 2020-08-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -210,6 +210,7 @@ files:
|
|
210
210
|
- lib/scalingo/billing/profile.rb
|
211
211
|
- lib/scalingo/client.rb
|
212
212
|
- lib/scalingo/configuration.rb
|
213
|
+
- lib/scalingo/core_client.rb
|
213
214
|
- lib/scalingo/error/expired_token.rb
|
214
215
|
- lib/scalingo/error/unauthenticated.rb
|
215
216
|
- lib/scalingo/errors.rb
|
@@ -227,6 +228,7 @@ files:
|
|
227
228
|
- lib/scalingo/regional/notifiers.rb
|
228
229
|
- lib/scalingo/regional/operations.rb
|
229
230
|
- lib/scalingo/regional/scm_repo_links.rb
|
231
|
+
- lib/scalingo/token_holder.rb
|
230
232
|
- lib/scalingo/version.rb
|
231
233
|
- samples/auth/keys/_meta.json
|
232
234
|
- samples/auth/keys/all-200.json
|
@@ -289,6 +291,8 @@ files:
|
|
289
291
|
- samples/regional/addons/provision-400.json
|
290
292
|
- samples/regional/addons/sso-200.json
|
291
293
|
- samples/regional/addons/sso-404.json
|
294
|
+
- samples/regional/addons/token-200.json
|
295
|
+
- samples/regional/addons/token-404.json
|
292
296
|
- samples/regional/addons/update-200.json
|
293
297
|
- samples/regional/addons/update-404.json
|
294
298
|
- samples/regional/apps/_meta.json
|
@@ -407,6 +411,7 @@ files:
|
|
407
411
|
- spec/scalingo/auth_spec.rb
|
408
412
|
- spec/scalingo/bearer_token_spec.rb
|
409
413
|
- spec/scalingo/billing/profile_spec.rb
|
414
|
+
- spec/scalingo/billing_spec.rb
|
410
415
|
- spec/scalingo/client_spec.rb
|
411
416
|
- spec/scalingo/configuration_spec.rb
|
412
417
|
- spec/scalingo/regional/addons_spec.rb
|
@@ -479,3 +484,4 @@ test_files:
|
|
479
484
|
- spec/scalingo/auth_spec.rb
|
480
485
|
- spec/scalingo/billing/profile_spec.rb
|
481
486
|
- spec/scalingo/regional_spec.rb
|
487
|
+
- spec/scalingo/billing_spec.rb
|