omniauth-ebay-oauth 0.2.0 → 0.3.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/omniauth/ebay-oauth/errors.rb +5 -3
- data/lib/omniauth/ebay-oauth/user_info_request.rb +11 -1
- data/lib/omniauth/ebay-oauth/version.rb +1 -1
- data/lib/omniauth/strategies/ebay_oauth.rb +6 -0
- data/omniauth-ebay-oauth.gemspec +2 -2
- data/spec/fixtures/user_suspended.xml +18 -0
- data/spec/omniauth/ebay-oauth/user_info_request_spec.rb +9 -0
- data/spec/omniauth/strategies/ebay_oauth_spec.rb +18 -7
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fb141a515171c5891e73fa328ffe959abbea166644a927f43f546143b9384ad
|
4
|
+
data.tar.gz: fcdba1511fd15fd35f0dbc21b52ef5ebc37c319b744dd344de550410bcfb5dd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1035eaf825e69b8e9de0a6eefcd5054228b7366c10ccfd81ce5370f6998e7d03650c40c65e70709ea635a43bc70ce596064b941f3a52a69c9f109fda3f45988f
|
7
|
+
data.tar.gz: b173b770f3d439d956cd4c287201b4eb523392a3bda50b10e4bc3fe93d0002ef4a45cd63884765ae48cf7756cf86b8c67ee4ed615c212ee61494e66227309457
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.3.0] - 2018-03-23
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Handling of suspended users login. @Envek
|
12
|
+
|
13
|
+
Fail authentication with specific code so application can handle it.
|
14
|
+
|
7
15
|
## [0.2.0] - 2018-03-16
|
8
16
|
|
9
17
|
### Changed
|
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
module OmniAuth
|
4
4
|
module EbayOauth
|
5
|
-
class
|
6
|
-
class
|
7
|
-
class
|
5
|
+
class Error < RuntimeError; end
|
6
|
+
class FailureResponseCode < Error; end
|
7
|
+
class FailureResponseResult < Error; end
|
8
|
+
class UnsupportedSchemaError < Error; end
|
9
|
+
class UserSuspended < Error; end
|
8
10
|
end
|
9
11
|
end
|
@@ -19,6 +19,10 @@ module OmniAuth
|
|
19
19
|
'X-EBAY-API-CALL-NAME' => 'GetUser'
|
20
20
|
}.freeze
|
21
21
|
|
22
|
+
ERRORS = {
|
23
|
+
'841' => UserSuspended
|
24
|
+
}.freeze
|
25
|
+
|
22
26
|
def initialize(access_token, request: USER_REQUEST,
|
23
27
|
user_info_endpoint:, read_timeout:, **_args)
|
24
28
|
@access_token = access_token
|
@@ -45,7 +49,13 @@ module OmniAuth
|
|
45
49
|
|
46
50
|
def ensure_success_result(body)
|
47
51
|
return if body.dig(*STATUS_PATH) == SUCCESS_CODE
|
48
|
-
|
52
|
+
|
53
|
+
error_code = body.dig('GetUserResponse', 'Errors', 'ErrorCode')
|
54
|
+
raise(FailureResponseResult, body) unless ERRORS.key?(error_code)
|
55
|
+
|
56
|
+
err_class = ERRORS[error_code]
|
57
|
+
err_message = body.dig('GetUserResponse', 'Errors', 'LongMessage')
|
58
|
+
raise err_class, err_message
|
49
59
|
end
|
50
60
|
|
51
61
|
def http
|
data/omniauth-ebay-oauth.gemspec
CHANGED
@@ -7,8 +7,8 @@ require 'omniauth/ebay-oauth/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'omniauth-ebay-oauth'
|
9
9
|
spec.version = OmniAuth::EbayOauth::VERSION
|
10
|
-
spec.authors = ['Ignat Zakrevsky']
|
11
|
-
spec.email = ['iezakrevsky@gmail.com']
|
10
|
+
spec.authors = ['Ignat Zakrevsky', 'Andrey Novikov']
|
11
|
+
spec.email = ['iezakrevsky@gmail.com', 'envek@envek.name']
|
12
12
|
spec.summary = 'OmniAuth strategy for new eBay OAuth API'
|
13
13
|
spec.homepage = 'https://github.com/evilmartians/omniauth-ebay-oauth'
|
14
14
|
spec.license = 'MIT'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<GetUserResponse xmlns="urn:ebay:apis:eBLBaseComponents">
|
3
|
+
<Timestamp>2018-03-21T09:22:11.985Z</Timestamp>
|
4
|
+
<Ack>Failure</Ack>
|
5
|
+
<Errors>
|
6
|
+
<ShortMessage>Requested user is suspended.</ShortMessage>
|
7
|
+
<LongMessage>The account for user ID \"evilenvek\" specified in this request is suspended. Sorry, you can only request information for current users.</LongMessage>
|
8
|
+
<ErrorCode>841</ErrorCode>
|
9
|
+
<SeverityCode>Error</SeverityCode>
|
10
|
+
<ErrorClassification>RequestError</ErrorClassification>
|
11
|
+
<ErrorParameters>
|
12
|
+
<ParamID>0</ParamID>
|
13
|
+
<Value>evilenvek</Value>
|
14
|
+
</ErrorParameters>
|
15
|
+
</Errors>
|
16
|
+
<Version>1045</Version>
|
17
|
+
<Build>E1045_CORE_APISIGNIN_18614794_R</Build>
|
18
|
+
</GetUserResponse>
|
@@ -15,6 +15,7 @@ RSpec.describe OmniAuth::EbayOauth::UserInfoRequest do
|
|
15
15
|
let(:request_headers) { YAML.load_file('spec/fixtures/request_headers.yml') }
|
16
16
|
let(:failure_result) { File.read('spec/fixtures/result_failure.xml') }
|
17
17
|
let(:success_result) { File.read('spec/fixtures/result_success.xml') }
|
18
|
+
let(:user_suspended_result) { File.read('spec/fixtures/user_suspended.xml') }
|
18
19
|
|
19
20
|
it 'raises error if eBay API request returned non-successful code' do
|
20
21
|
stub_request(:post, endpoint)
|
@@ -39,4 +40,12 @@ RSpec.describe OmniAuth::EbayOauth::UserInfoRequest do
|
|
39
40
|
expect(subject.call.fetch('GetUserResponse').keys)
|
40
41
|
.to eql %w[xmlns Timestamp Ack Version Build User]
|
41
42
|
end
|
43
|
+
|
44
|
+
it 'raises error if eBay user is suspended' do
|
45
|
+
stub_request(:post, endpoint)
|
46
|
+
.with(body: body, headers: request_headers)
|
47
|
+
.to_return(status: 200, body: user_suspended_result, headers: {})
|
48
|
+
expect { subject.call }
|
49
|
+
.to raise_error(OmniAuth::EbayOauth::UserSuspended)
|
50
|
+
end
|
42
51
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe OmniAuth::Strategies::EbayOauth do
|
6
|
+
let(:options) { {} }
|
7
|
+
|
6
8
|
subject { described_class.new(nil, options) }
|
7
9
|
|
8
10
|
describe '#callback_url' do
|
@@ -14,8 +16,6 @@ RSpec.describe OmniAuth::Strategies::EbayOauth do
|
|
14
16
|
end
|
15
17
|
|
16
18
|
describe '#options' do
|
17
|
-
let(:options) { {} }
|
18
|
-
|
19
19
|
before { subject.setup_phase }
|
20
20
|
|
21
21
|
it 'default mode is sandbox' do
|
@@ -33,8 +33,6 @@ RSpec.describe OmniAuth::Strategies::EbayOauth do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
context "when scopes aren't passed" do
|
36
|
-
let(:options) { {} }
|
37
|
-
|
38
36
|
it 'uses empty string as scope' do
|
39
37
|
expect(subject.options.scope).to eql ''
|
40
38
|
end
|
@@ -99,7 +97,6 @@ RSpec.describe OmniAuth::Strategies::EbayOauth do
|
|
99
97
|
|
100
98
|
describe '#user_info' do
|
101
99
|
let(:access_token) { instance_double(OAuth2::AccessToken, token: :token) }
|
102
|
-
let(:options) { {} }
|
103
100
|
let(:user_info) { instance_double(OmniAuth::EbayOauth::UserInfo) }
|
104
101
|
let(:request) do
|
105
102
|
instance_double(OmniAuth::EbayOauth::UserInfoRequest, call: {})
|
@@ -120,8 +117,6 @@ RSpec.describe OmniAuth::Strategies::EbayOauth do
|
|
120
117
|
|
121
118
|
describe '#credentials' do
|
122
119
|
let(:access_token) { OAuth2::AccessToken.new(client, token, opts) }
|
123
|
-
let(:options) { {} }
|
124
|
-
|
125
120
|
let(:client) { instance_double(OAuth2::Client) }
|
126
121
|
let(:token) { 'v^1.1#i^1#f^0#I^3#r^0#p^3#t^H4sIAAAAAAAAAOlongstringtoken' }
|
127
122
|
let(:opts) do
|
@@ -144,4 +139,20 @@ RSpec.describe OmniAuth::Strategies::EbayOauth do
|
|
144
139
|
.to be_between(current_time, current_time + expiration_time)
|
145
140
|
end
|
146
141
|
end
|
142
|
+
|
143
|
+
describe '#callback_phase' do
|
144
|
+
context 'when user is suspended' do
|
145
|
+
before do
|
146
|
+
allow(subject).to receive(:request) do
|
147
|
+
raise OmniAuth::EbayOauth::UserSuspended
|
148
|
+
end
|
149
|
+
allow(subject).to receive(:fail!)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'fails with user_suspended message' do
|
153
|
+
subject.callback_phase
|
154
|
+
expect(subject).to have_received(:fail!).with(:user_suspended, anything)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
147
158
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-ebay-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignat Zakrevsky
|
8
|
+
- Andrey Novikov
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
12
|
+
date: 2018-03-23 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: omniauth
|
@@ -125,6 +126,7 @@ dependencies:
|
|
125
126
|
description:
|
126
127
|
email:
|
127
128
|
- iezakrevsky@gmail.com
|
129
|
+
- envek@envek.name
|
128
130
|
executables: []
|
129
131
|
extensions: []
|
130
132
|
extra_rdoc_files: []
|
@@ -150,6 +152,7 @@ files:
|
|
150
152
|
- spec/fixtures/request_headers.yml
|
151
153
|
- spec/fixtures/result_failure.xml
|
152
154
|
- spec/fixtures/result_success.xml
|
155
|
+
- spec/fixtures/user_suspended.xml
|
153
156
|
- spec/omniauth/ebay-oauth/user_info_request_spec.rb
|
154
157
|
- spec/omniauth/ebay-oauth/user_info_spec.rb
|
155
158
|
- spec/omniauth/strategies/ebay_oauth_spec.rb
|