spearly-sdk-ruby 0.9.0 → 0.11.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/.github/workflows/main.yml +11 -6
- data/.rubocop.yml +3 -1
- data/CHANGELOG.md +11 -0
- data/Gemfile +8 -1
- data/README.md +1 -1
- data/Rakefile +3 -1
- data/lib/spearly/auth/authorizer.rb +0 -1
- data/lib/spearly/auth/client.rb +34 -142
- data/lib/spearly/auth/team.rb +43 -12
- data/lib/spearly/auth/team_member.rb +28 -0
- data/lib/spearly/auth/team_subscription.rb +18 -0
- data/lib/spearly/auth/token.rb +18 -50
- data/lib/spearly/auth/user.rb +17 -55
- data/lib/spearly/auth.rb +2 -9
- data/lib/spearly/cloud/client.rb +2 -2
- data/lib/spearly/version.rb +1 -1
- data/spearly.gemspec +1 -8
- data/spec/spearly/auth/client_spec.rb +6 -35
- data/spec/spearly/auth/team_member_spec.rb +159 -0
- data/spec/spearly/auth/team_spec.rb +371 -0
- data/spec/spearly/auth/team_subscription_spec.rb +82 -0
- data/spec/spearly/auth/token_spec.rb +150 -0
- data/spec/spearly/auth/user_spec.rb +168 -0
- data/spec/spec_helper.rb +0 -1
- metadata +12 -92
- data/lib/spearly/auth/engine.rb +0 -13
- data/lib/spearly/auth/oauth_user.rb +0 -32
- data/lib/spearly/auth/rails/helpers.rb +0 -31
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Spearly::Auth::Token do
|
|
6
|
+
let!(:connection_double) { instance_double(Faraday::Connection) }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
stub_const('ENV', { 'SPEARLY_API_URL' => 'https://api.spearly.test' })
|
|
10
|
+
|
|
11
|
+
allow(Faraday).to receive(:new).and_return(connection_double)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '.get_token_info()' do
|
|
15
|
+
let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'resource_owner_id' => 'token_1' }.to_json) }
|
|
16
|
+
let!(:client) { Spearly::Auth::Client.new('token') }
|
|
17
|
+
|
|
18
|
+
before do
|
|
19
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'makes GET request to /oauth/token/info' do
|
|
23
|
+
uri_parsed = Addressable::URI.parse('/oauth/token/info').normalize.to_s
|
|
24
|
+
|
|
25
|
+
expect(connection_double).to receive(:run_request).with(:get,
|
|
26
|
+
uri_parsed,
|
|
27
|
+
nil,
|
|
28
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
29
|
+
'Authorization' => 'token')
|
|
30
|
+
|
|
31
|
+
client.get_token_info
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'returns data array if status is 200' do
|
|
35
|
+
res = client.get_token_info
|
|
36
|
+
|
|
37
|
+
expect(res).to eq('resource_owner_id' => 'token_1')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'throws AuthorizationError if 401' do
|
|
41
|
+
response_double = instance_double(Faraday::Response, status: 401)
|
|
42
|
+
|
|
43
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
44
|
+
|
|
45
|
+
expect do
|
|
46
|
+
client.get_token_info
|
|
47
|
+
end.to raise_error(Spearly::Auth::AuthorizationError)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'throws NotFoundError if 404' do
|
|
51
|
+
response_double = instance_double(Faraday::Response, status: 404)
|
|
52
|
+
|
|
53
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
54
|
+
|
|
55
|
+
expect do
|
|
56
|
+
client.get_token_info
|
|
57
|
+
end.to raise_error(Spearly::Auth::NotFoundError)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'throws ServerError if 500' do
|
|
61
|
+
response_double = instance_double(Faraday::Response, status: 500)
|
|
62
|
+
|
|
63
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
64
|
+
|
|
65
|
+
expect do
|
|
66
|
+
client.get_token_info
|
|
67
|
+
end.to raise_error(Spearly::Auth::ServerError)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'throws ServiceUnavailableError if 503' do
|
|
71
|
+
response_double = instance_double(Faraday::Response, status: 503)
|
|
72
|
+
|
|
73
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
74
|
+
|
|
75
|
+
expect do
|
|
76
|
+
client.get_token_info
|
|
77
|
+
end.to raise_error(Spearly::Auth::ServiceUnavailableError)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe '.revoke_token()' do
|
|
82
|
+
let!(:response_double) { instance_double(Faraday::Response, status: 200, body: {}.to_json) }
|
|
83
|
+
let!(:access_token) { 'Bearer asdf1234' }
|
|
84
|
+
let!(:client) { Spearly::Auth::Client.new(access_token) }
|
|
85
|
+
|
|
86
|
+
let!(:params) do
|
|
87
|
+
{
|
|
88
|
+
client_id: 'client_1',
|
|
89
|
+
client_secret: 'client_s3cr3t',
|
|
90
|
+
token: access_token.gsub(/^Bearer /i, '')
|
|
91
|
+
}
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
before do
|
|
95
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'makes GET request to /oauth/revoke' do
|
|
99
|
+
uri_parsed = Addressable::URI.parse('/oauth/revoke').normalize.to_s
|
|
100
|
+
|
|
101
|
+
expect(connection_double).to receive(:run_request).with(:post,
|
|
102
|
+
uri_parsed,
|
|
103
|
+
params,
|
|
104
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
105
|
+
'Authorization' => access_token)
|
|
106
|
+
|
|
107
|
+
client.revoke_token(params.slice(:client_id, :client_secret))
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'throws AuthorizationError if 401' do
|
|
111
|
+
response_double = instance_double(Faraday::Response, status: 401)
|
|
112
|
+
|
|
113
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
114
|
+
|
|
115
|
+
expect do
|
|
116
|
+
client.revoke_token(params.slice(:client_id, :client_secret))
|
|
117
|
+
end.to raise_error(Spearly::Auth::AuthorizationError)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'throws NotFoundError if 404' do
|
|
121
|
+
response_double = instance_double(Faraday::Response, status: 404)
|
|
122
|
+
|
|
123
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
124
|
+
|
|
125
|
+
expect do
|
|
126
|
+
client.revoke_token(params.slice(:client_id, :client_secret))
|
|
127
|
+
end.to raise_error(Spearly::Auth::NotFoundError)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'throws ServerError if 500' do
|
|
131
|
+
response_double = instance_double(Faraday::Response, status: 500)
|
|
132
|
+
|
|
133
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
134
|
+
|
|
135
|
+
expect do
|
|
136
|
+
client.revoke_token(params.slice(:client_id, :client_secret))
|
|
137
|
+
end.to raise_error(Spearly::Auth::ServerError)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'throws ServiceUnavailableError if 503' do
|
|
141
|
+
response_double = instance_double(Faraday::Response, status: 503)
|
|
142
|
+
|
|
143
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
144
|
+
|
|
145
|
+
expect do
|
|
146
|
+
client.revoke_token(params.slice(:client_id, :client_secret))
|
|
147
|
+
end.to raise_error(Spearly::Auth::ServiceUnavailableError)
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Spearly::Auth::User do
|
|
6
|
+
let!(:connection_double) { instance_double(Faraday::Connection) }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
stub_const('ENV', { 'SPEARLY_API_URL' => 'https://api.spearly.test' })
|
|
10
|
+
|
|
11
|
+
allow(Faraday).to receive(:new).and_return(connection_double)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '.get_user()' do
|
|
15
|
+
let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'data' => { 'id' => 'user_1' } }.to_json) }
|
|
16
|
+
let!(:user_id) { 'user_1' }
|
|
17
|
+
let!(:client) { Spearly::Auth::Client.new('token') }
|
|
18
|
+
|
|
19
|
+
before do
|
|
20
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'makes GET request to /users/:user_id' do
|
|
24
|
+
uri_parsed = Addressable::URI.parse("/users/#{user_id}").normalize.to_s
|
|
25
|
+
|
|
26
|
+
expect(connection_double).to receive(:run_request).with(:get,
|
|
27
|
+
uri_parsed,
|
|
28
|
+
nil,
|
|
29
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
30
|
+
'Authorization' => 'token')
|
|
31
|
+
|
|
32
|
+
client.get_user(user_id)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'returns data array if status is 200' do
|
|
36
|
+
res = client.get_user(user_id)
|
|
37
|
+
|
|
38
|
+
expect(res).to eq('data' => { 'id' => 'user_1' })
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'returns errors object if 422' do
|
|
42
|
+
response_double = instance_double(Faraday::Response, status: 422, body: { 'errors' => { 'owner' => ["can't own more than 2 free teams"] } }.to_json)
|
|
43
|
+
|
|
44
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
45
|
+
|
|
46
|
+
res = client.get_user(user_id)
|
|
47
|
+
|
|
48
|
+
expect(res['errors']).to eq('owner' => ["can't own more than 2 free teams"])
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'throws AuthorizationError if 401' do
|
|
52
|
+
response_double = instance_double(Faraday::Response, status: 401)
|
|
53
|
+
|
|
54
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
55
|
+
|
|
56
|
+
expect do
|
|
57
|
+
client.get_user(user_id)
|
|
58
|
+
end.to raise_error(Spearly::Auth::AuthorizationError)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'throws NotFoundError if 404' do
|
|
62
|
+
response_double = instance_double(Faraday::Response, status: 404)
|
|
63
|
+
|
|
64
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
65
|
+
|
|
66
|
+
expect do
|
|
67
|
+
client.get_user(user_id)
|
|
68
|
+
end.to raise_error(Spearly::Auth::NotFoundError)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'throws ServerError if 500' do
|
|
72
|
+
response_double = instance_double(Faraday::Response, status: 500)
|
|
73
|
+
|
|
74
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
75
|
+
|
|
76
|
+
expect do
|
|
77
|
+
client.get_user(user_id)
|
|
78
|
+
end.to raise_error(Spearly::Auth::ServerError)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'throws ServiceUnavailableError if 503' do
|
|
82
|
+
response_double = instance_double(Faraday::Response, status: 503)
|
|
83
|
+
|
|
84
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
85
|
+
|
|
86
|
+
expect do
|
|
87
|
+
client.get_user(user_id)
|
|
88
|
+
end.to raise_error(Spearly::Auth::ServiceUnavailableError)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe '.get_profile()' do
|
|
93
|
+
let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'data' => { 'id' => 'user_1' } }.to_json) }
|
|
94
|
+
let!(:client) { Spearly::Auth::Client.new('token') }
|
|
95
|
+
|
|
96
|
+
before do
|
|
97
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'makes GET request to /profile' do
|
|
101
|
+
uri_parsed = Addressable::URI.parse('/profile').normalize.to_s
|
|
102
|
+
|
|
103
|
+
expect(connection_double).to receive(:run_request).with(:get,
|
|
104
|
+
uri_parsed,
|
|
105
|
+
nil,
|
|
106
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
107
|
+
'Authorization' => 'token')
|
|
108
|
+
|
|
109
|
+
client.get_profile
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'returns data array if status is 200' do
|
|
113
|
+
res = client.get_profile
|
|
114
|
+
|
|
115
|
+
expect(res).to eq('data' => { 'id' => 'user_1' })
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'returns errors object if 422' do
|
|
119
|
+
response_double = instance_double(Faraday::Response, status: 422, body: { 'errors' => { 'owner' => ["can't own more than 2 free teams"] } }.to_json)
|
|
120
|
+
|
|
121
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
122
|
+
|
|
123
|
+
res = client.get_profile
|
|
124
|
+
|
|
125
|
+
expect(res['errors']).to eq('owner' => ["can't own more than 2 free teams"])
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it 'throws AuthorizationError if 401' do
|
|
129
|
+
response_double = instance_double(Faraday::Response, status: 401)
|
|
130
|
+
|
|
131
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
132
|
+
|
|
133
|
+
expect do
|
|
134
|
+
client.get_profile
|
|
135
|
+
end.to raise_error(Spearly::Auth::AuthorizationError)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it 'throws NotFoundError if 404' do
|
|
139
|
+
response_double = instance_double(Faraday::Response, status: 404)
|
|
140
|
+
|
|
141
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
142
|
+
|
|
143
|
+
expect do
|
|
144
|
+
client.get_profile
|
|
145
|
+
end.to raise_error(Spearly::Auth::NotFoundError)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'throws ServerError if 500' do
|
|
149
|
+
response_double = instance_double(Faraday::Response, status: 500)
|
|
150
|
+
|
|
151
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
152
|
+
|
|
153
|
+
expect do
|
|
154
|
+
client.get_profile
|
|
155
|
+
end.to raise_error(Spearly::Auth::ServerError)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it 'throws ServiceUnavailableError if 503' do
|
|
159
|
+
response_double = instance_double(Faraday::Response, status: 503)
|
|
160
|
+
|
|
161
|
+
allow(connection_double).to receive(:run_request).and_return(response_double)
|
|
162
|
+
|
|
163
|
+
expect do
|
|
164
|
+
client.get_profile
|
|
165
|
+
end.to raise_error(Spearly::Auth::ServiceUnavailableError)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spearly-sdk-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Spearly
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-09-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -72,90 +72,6 @@ dependencies:
|
|
|
72
72
|
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
74
|
version: '0.15'
|
|
75
|
-
- !ruby/object:Gem::Dependency
|
|
76
|
-
name: bundler-audit
|
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - "~>"
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: '0.9'
|
|
82
|
-
type: :development
|
|
83
|
-
prerelease: false
|
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - "~>"
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: '0.9'
|
|
89
|
-
- !ruby/object:Gem::Dependency
|
|
90
|
-
name: fuubar
|
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - "~>"
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: '2.5'
|
|
96
|
-
type: :development
|
|
97
|
-
prerelease: false
|
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
-
requirements:
|
|
100
|
-
- - "~>"
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: '2.5'
|
|
103
|
-
- !ruby/object:Gem::Dependency
|
|
104
|
-
name: pry
|
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
|
106
|
-
requirements:
|
|
107
|
-
- - "~>"
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: '0.13'
|
|
110
|
-
type: :development
|
|
111
|
-
prerelease: false
|
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
-
requirements:
|
|
114
|
-
- - "~>"
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version: '0.13'
|
|
117
|
-
- !ruby/object:Gem::Dependency
|
|
118
|
-
name: rspec
|
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - "~>"
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: '3.10'
|
|
124
|
-
type: :development
|
|
125
|
-
prerelease: false
|
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - "~>"
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '3.10'
|
|
131
|
-
- !ruby/object:Gem::Dependency
|
|
132
|
-
name: rubocop
|
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
|
134
|
-
requirements:
|
|
135
|
-
- - "~>"
|
|
136
|
-
- !ruby/object:Gem::Version
|
|
137
|
-
version: '1.15'
|
|
138
|
-
type: :development
|
|
139
|
-
prerelease: false
|
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
141
|
-
requirements:
|
|
142
|
-
- - "~>"
|
|
143
|
-
- !ruby/object:Gem::Version
|
|
144
|
-
version: '1.15'
|
|
145
|
-
- !ruby/object:Gem::Dependency
|
|
146
|
-
name: rubocop-rspec
|
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
|
148
|
-
requirements:
|
|
149
|
-
- - "~>"
|
|
150
|
-
- !ruby/object:Gem::Version
|
|
151
|
-
version: '2.3'
|
|
152
|
-
type: :development
|
|
153
|
-
prerelease: false
|
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
155
|
-
requirements:
|
|
156
|
-
- - "~>"
|
|
157
|
-
- !ruby/object:Gem::Version
|
|
158
|
-
version: '2.3'
|
|
159
75
|
description:
|
|
160
76
|
email:
|
|
161
77
|
- dj@unimal.jp
|
|
@@ -179,10 +95,9 @@ files:
|
|
|
179
95
|
- lib/spearly/auth.rb
|
|
180
96
|
- lib/spearly/auth/authorizer.rb
|
|
181
97
|
- lib/spearly/auth/client.rb
|
|
182
|
-
- lib/spearly/auth/engine.rb
|
|
183
|
-
- lib/spearly/auth/oauth_user.rb
|
|
184
|
-
- lib/spearly/auth/rails/helpers.rb
|
|
185
98
|
- lib/spearly/auth/team.rb
|
|
99
|
+
- lib/spearly/auth/team_member.rb
|
|
100
|
+
- lib/spearly/auth/team_subscription.rb
|
|
186
101
|
- lib/spearly/auth/token.rb
|
|
187
102
|
- lib/spearly/auth/user.rb
|
|
188
103
|
- lib/spearly/cloud.rb
|
|
@@ -190,6 +105,11 @@ files:
|
|
|
190
105
|
- lib/spearly/version.rb
|
|
191
106
|
- spearly.gemspec
|
|
192
107
|
- spec/spearly/auth/client_spec.rb
|
|
108
|
+
- spec/spearly/auth/team_member_spec.rb
|
|
109
|
+
- spec/spearly/auth/team_spec.rb
|
|
110
|
+
- spec/spearly/auth/team_subscription_spec.rb
|
|
111
|
+
- spec/spearly/auth/token_spec.rb
|
|
112
|
+
- spec/spearly/auth/user_spec.rb
|
|
193
113
|
- spec/spearly_spec.rb
|
|
194
114
|
- spec/spec_helper.rb
|
|
195
115
|
homepage: https://github.com/unimal-jp/spearly-sdk-ruby
|
|
@@ -197,7 +117,7 @@ licenses: []
|
|
|
197
117
|
metadata:
|
|
198
118
|
homepage_uri: https://github.com/unimal-jp/spearly-sdk-ruby
|
|
199
119
|
source_code_uri: https://github.com/unimal-jp/spearly-sdk-ruby
|
|
200
|
-
changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.
|
|
120
|
+
changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.11.0/CHANGELOG.md
|
|
201
121
|
rubygems_mfa_required: 'true'
|
|
202
122
|
post_install_message:
|
|
203
123
|
rdoc_options: []
|
|
@@ -207,14 +127,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
207
127
|
requirements:
|
|
208
128
|
- - ">="
|
|
209
129
|
- !ruby/object:Gem::Version
|
|
210
|
-
version:
|
|
130
|
+
version: 3.1.0
|
|
211
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
132
|
requirements:
|
|
213
133
|
- - ">="
|
|
214
134
|
- !ruby/object:Gem::Version
|
|
215
135
|
version: '0'
|
|
216
136
|
requirements: []
|
|
217
|
-
rubygems_version: 3.3.
|
|
137
|
+
rubygems_version: 3.3.26
|
|
218
138
|
signing_key:
|
|
219
139
|
specification_version: 4
|
|
220
140
|
summary: Spearly SDK for Ruby
|
data/lib/spearly/auth/engine.rb
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'addressable/uri'
|
|
4
|
-
require 'faraday'
|
|
5
|
-
|
|
6
|
-
module Spearly
|
|
7
|
-
module Auth
|
|
8
|
-
class OauthUser
|
|
9
|
-
attr_reader :data
|
|
10
|
-
|
|
11
|
-
def initialize(data)
|
|
12
|
-
@data = data
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def method_missing(name, *_args)
|
|
16
|
-
@data[name.to_s]
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def respond_to_missing?(_name, *_args)
|
|
20
|
-
true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def to_json(*_args)
|
|
24
|
-
@data.to_json
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def as_json
|
|
28
|
-
@data.as_json
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Spearly
|
|
4
|
-
module Auth
|
|
5
|
-
module Rails
|
|
6
|
-
module Helpers
|
|
7
|
-
def spearly_authorize!
|
|
8
|
-
raise Spearly::Auth::AuthorizationError unless spearly_token
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def spearly_token
|
|
14
|
-
@spearly_token ||= begin
|
|
15
|
-
token = Spearly::Auth::Token.new(request.authorization)
|
|
16
|
-
|
|
17
|
-
token.info ? token : nil
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def spearly_user
|
|
22
|
-
@spearly_user ||= begin
|
|
23
|
-
user = Spearly::Auth::User.new(request.authorization)
|
|
24
|
-
|
|
25
|
-
user.find ? user : nil
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|