omniauth-ebay-oauth 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fd4bb7ec09bb4c7eeb9871a39199b250ab98baec
4
- data.tar.gz: ddbddbd7ca71e8c70f7a86e30c3ebaa190d57381
2
+ SHA256:
3
+ metadata.gz: ab0104101de3fbd57ee567e17d4d8439528ce4ca6acb2c80ad7d35733d1e8e5d
4
+ data.tar.gz: 1cba5d5cbf2821445869057fe086aaf50983043090171a225c7d1cef66bf502b
5
5
  SHA512:
6
- metadata.gz: e5a1c86bc38a7e483ca6548b3ee65a2c784e0fe36147a5a2f0a64677e81bfe1e9ffe3ddf902184fb39cb90d40b2bd7b45c6c75492bc2aff0e62d123209bb4149
7
- data.tar.gz: c7dd0de77707d2ad3f2c33879f3a2eeac8f29296a97bba6759f7e57ed0b30f00555dae441238ed6557765e89fdc9f0f4e85dac4365b62a51b49bd9e6482e15d8
6
+ metadata.gz: fcc4e6adda2ce0b2a6a3aea277c7452e13b6bc8244c5162ced049d8e981918e0858a84dbbf43ad5ba0591327e1dba30e3b3c66bb540e869e340945ff3fba130f
7
+ data.tar.gz: edbe8b21811965d437b6a76e863d052a5f08da7fb64440e297d86245085bb034cf8237d99b54308614b834201884011ed96b384e52e63cfeaaeaa1db793f659c
@@ -0,0 +1,82 @@
1
+ name: Build and release gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ fetch-depth: 0 # Fetch current tag as annotated. See https://github.com/actions/checkout/issues/290
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.7
18
+ - name: "Extract data from tag: version, message, body"
19
+ id: tag
20
+ run: |
21
+ git fetch --tags --force # Really fetch annotated tag. See https://github.com/actions/checkout/issues/290#issuecomment-680260080
22
+ echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
23
+ echo ::set-output name=subject::$(git for-each-ref $GITHUB_REF --format='%(contents:subject)')
24
+ BODY="$(git for-each-ref $GITHUB_REF --format='%(contents:body)')"
25
+ # Extract changelog entries between this and previous version headers
26
+ escaped_version=$(echo ${GITHUB_REF#refs/tags/v} | sed -e 's/[]\/$*.^[]/\\&/g')
27
+ changelog=$(awk "BEGIN{inrelease=0} /## \[${escaped_version}\]/{inrelease=1;next} /## \[[0-9]+\.[0-9]+\.[0-9]+.*?\]/{inrelease=0;exit} {if (inrelease) print}" CHANGELOG.md)
28
+ # Multiline body for release. See https://github.community/t/set-output-truncates-multiline-strings/16852/5
29
+ BODY="${BODY}"$'\n'"${changelog}"
30
+ BODY="${BODY//'%'/'%25'}"
31
+ BODY="${BODY//$'\n'/'%0A'}"
32
+ BODY="${BODY//$'\r'/'%0D'}"
33
+ echo "::set-output name=body::$BODY"
34
+ # Add pre-release option if tag name has any suffix after vMAJOR.MINOR.PATCH
35
+ if [[ ${GITHUB_REF#refs/tags/} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.+ ]]; then
36
+ echo ::set-output name=prerelease::true
37
+ fi
38
+ - name: Build gem
39
+ run: gem build
40
+ - name: Calculate checksums
41
+ run: sha256sum omniauth-ebay-oauth-${{ steps.tag.outputs.version }}.gem > SHA256SUM
42
+ - name: Check version
43
+ run: ls -l omniauth-ebay-oauth-${{ steps.tag.outputs.version }}.gem
44
+ - name: Create Release
45
+ id: create_release
46
+ uses: actions/create-release@v1
47
+ env:
48
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49
+ with:
50
+ tag_name: ${{ github.ref }}
51
+ release_name: ${{ steps.tag.outputs.subject }}
52
+ body: ${{ steps.tag.outputs.body }}
53
+ draft: false
54
+ prerelease: ${{ steps.tag.outputs.prerelease }}
55
+ - name: Upload built gem as release asset
56
+ uses: actions/upload-release-asset@v1
57
+ env:
58
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59
+ with:
60
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
61
+ asset_path: omniauth-ebay-oauth-${{ steps.tag.outputs.version }}.gem
62
+ asset_name: omniauth-ebay-oauth-${{ steps.tag.outputs.version }}.gem
63
+ asset_content_type: application/x-tar
64
+ - name: Upload checksums as release asset
65
+ uses: actions/upload-release-asset@v1
66
+ env:
67
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68
+ with:
69
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
70
+ asset_path: SHA256SUM
71
+ asset_name: SHA256SUM
72
+ asset_content_type: text/plain
73
+ - name: Publish to GitHub packages
74
+ env:
75
+ GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
76
+ run: |
77
+ gem push omniauth-ebay-oauth-${{ steps.tag.outputs.version }}.gem --host https://rubygems.pkg.github.com/${{ github.repository_owner }}
78
+ - name: Publish to RubyGems
79
+ env:
80
+ GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
81
+ run: |
82
+ gem push omniauth-ebay-oauth-${{ steps.tag.outputs.version }}.gem
@@ -0,0 +1,57 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - '**'
8
+ tags-ignore:
9
+ - 'v*'
10
+
11
+ jobs:
12
+ test:
13
+ name: "Ruby ${{ matrix.ruby }}, omniauth ${{ matrix.omniauth }}"
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ include:
19
+ - ruby: "3.0"
20
+ omniauth: "~> 2.0"
21
+ - ruby: "2.7"
22
+ omniauth: "~> 2.0"
23
+ - ruby: "2.7"
24
+ omniauth: "~> 1.4"
25
+ - ruby: "2.6"
26
+ omniauth: "~> 1.4"
27
+ - ruby: "2.5"
28
+ omniauth: "~> 1.4"
29
+ - ruby: "2.4"
30
+ omniauth: "~> 1.4"
31
+ - ruby: "2.3"
32
+ omniauth: "~> 1.4"
33
+ container:
34
+ image: ruby:${{ matrix.ruby }}
35
+ env:
36
+ CI: true
37
+ OMNIAUTH_VERSION: "${{ matrix.omniauth }}"
38
+ steps:
39
+ - uses: actions/checkout@v2
40
+ - uses: actions/cache@v2
41
+ with:
42
+ path: vendor/bundle
43
+ key: bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
44
+ restore-keys: |
45
+ bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
46
+ bundle-${{ matrix.ruby }}-
47
+ - name: Upgrade Bundler to 2.0 (for older Rubies)
48
+ run: gem install bundler -v '~> 2.0'
49
+ - name: Bundle install
50
+ run: |
51
+ bundle config path vendor/bundle
52
+ bundle install
53
+ bundle update
54
+ - name: Run Rubocop
55
+ run: bundle exec rubocop
56
+ - name: Run RSpec
57
+ run: bundle exec rspec
data/CHANGELOG.md ADDED
@@ -0,0 +1,73 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [1.0.0] - 2021-04-01
8
+
9
+ Mark gem as stable
10
+
11
+ ### Changed
12
+
13
+ - Relax dependency to [OmniAuth](https://rubygems.org/gems/omniauth) gem to allow using 2.x versions.
14
+
15
+ See [OmniAuth 2.0.0 release notes](https://github.com/omniauth/omniauth/releases/tag/v2.0.0) if you want to upgrade to it in your app.
16
+
17
+ ## [0.5.0] - 2019-04-04
18
+
19
+ ### Added
20
+
21
+ - Added `prompt` option to allow login under different credentials. @Envek
22
+
23
+ See [Getting user consent](https://developer.ebay.com/api-docs/static/oauth-consent-request.html) documentation page for details.
24
+
25
+ ## [0.4.0] - 2018-08-10
26
+
27
+ ### Changed
28
+
29
+ - Changed default authentication endpoint. @Envek
30
+
31
+ Before: https://signin.ebay.com/authorize – always displays user consent screen “Allow APP_NAME to act on your behalf?”.
32
+
33
+ After: https://auth.ebay.com/oauth2/authorize – doesn't repeatedly ask for user consent.
34
+
35
+ I can't find new endpoint address in docs, but it is used in the wild.
36
+
37
+ ## [0.3.0] - 2018-03-23
38
+
39
+ ### Added
40
+
41
+ - Handling of suspended users login. @Envek
42
+
43
+ Fail authentication with specific code so application can handle it.
44
+
45
+ ## [0.2.0] - 2018-03-16
46
+
47
+ ### Changed
48
+
49
+ - Renamed strategy from `ebay` to `ebay_oauth`. @Envek
50
+
51
+ This allow to use this strategy simultaneously with old strategies (like [omniauth-ebay](https://github.com/TheGiftsProject/omniauth-ebay) and [ebay_request](https://github.com/gzigzigzeo/ebay_request#omniauth-strategy))
52
+
53
+ As eBay allows to have only one OAuth RUName per application keyset while allowing to have many Auth'n'auth RUNames, it may be desirable to use Auth'n'auth for auxilary signins, where obtaining of OAuth tokens is not required.
54
+
55
+ ## [0.1.1] - 2018-01-09
56
+
57
+ ### Fixed
58
+
59
+ - Add missing require to fix gem load errors when this gem is being required from another gem. @Envek
60
+
61
+
62
+ ## [0.1.0] - 2017-11-27
63
+
64
+ - Initial release: fully working strategy. @ignat-z
65
+
66
+
67
+ [1.0.0]: https://github.com/evilmartians/omniauth-ebay-oauth/compare/v0.5.0...v1.0.0
68
+ [0.5.0]: https://github.com/evilmartians/omniauth-ebay-oauth/compare/v0.4.0...v0.5.0
69
+ [0.4.0]: https://github.com/evilmartians/omniauth-ebay-oauth/compare/v0.3.0...v0.4.0
70
+ [0.3.0]: https://github.com/evilmartians/omniauth-ebay-oauth/compare/v0.2.0...v0.3.0
71
+ [0.2.0]: https://github.com/evilmartians/omniauth-ebay-oauth/compare/v0.1.1...v0.2.0
72
+ [0.1.1]: https://github.com/evilmartians/omniauth-ebay-oauth/compare/v0.1.0...v0.1.1
73
+ [0.1.0]: https://github.com/evilmartians/omniauth-ebay-oauth/compare/5213dada5fec8df5da551daf763b6acc84ec7330...v0.1.0
data/Gemfile CHANGED
@@ -5,3 +5,5 @@ source 'https://rubygems.org'
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  gemspec
8
+
9
+ gem 'omniauth', ENV['OMNIAUTH_VERSION'] if ENV['OMNIAUTH_VERSION']
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ [![Gem Version](https://badge.fury.io/rb/omniauth-ebay-oauth.svg)](https://badge.fury.io/rb/omniauth-ebay-oauth)
2
+ [![Tests Status](https://github.com/evilmartians/omniauth-ebay-oauth/actions/workflows/test.yml/badge.svg)](https://github.com/evilmartians/omniauth-ebay-oauth/actions)
3
+ [![Cult of Martians](http://cultofmartians.com/assets/badges/badge.svg)](http://cultofmartians.com/tasks/ebay-oauth-signin.html)
4
+
1
5
  # omniauth-ebay-oauth
2
6
 
3
7
  OmniAuth Strategy for eBay Apps (for using with eBay REST APIs)
@@ -16,15 +20,15 @@ This gem implements authorization with OAuth method while currently available ge
16
20
 
17
21
  __What is the difference? Access tokens!__
18
22
 
19
- With Auth'n'auth you will get a single token which you can use to access old eBay XML APIs (Trading API, etc.)
23
+ With Auth'n'auth you will get a single token which you can use to access only old eBay XML APIs (Trading API, etc.)
20
24
 
21
25
  With OAuth, you will get a pair of access and refresh tokens which can be used to access new eBay REST APIs (Buy API, Sell API, etc.)
22
26
 
23
- However, you can use new OAuth tokens to access old APIs by providing an access token in (not yet) documented HTTP header `X-EBAY-API-IAF-TOKEN` (like this gem uses it to obtain information about an authenticated user from Trading API).
27
+ However, you can use new OAuth tokens to access old APIs too by providing an access token in HTTP header `X-EBAY-API-IAF-TOKEN`. This is documented in eBay developer program website: [Using OAuth with the eBay traditional APIs](https://developer.ebay.com/api-docs/static/oauth-trad-apis.html#Implemen).
24
28
 
25
- If you plan to use only old APIs, you can look at [ebay_request](https://github.com/gzigzigzeo/ebay_request) gem.
29
+ If you plan to use new APIs, you are welcome to use this gem together with [ebay_api](https://github.com/nepalez/ebay_api) client gem for REST APIs.
26
30
 
27
- If you plan to use new APIs, you are welcome to use this gem either standalone or together with [ebay_api](https://github.com/nepalez/ebay_api) client get for REST APIs.
31
+ For old APIs, you can look at [ebay_request](https://github.com/gzigzigzeo/ebay_request) gem (you can configure it to use OAuth tokens).
28
32
 
29
33
  Now you can read the eBay docs about [REST APIs](https://developer.ebay.com/api-docs/static/ebay-rest-landing.html) and [OAuth](https://developer.ebay.com/api-docs/static/oauth-quick-ref-user-tokens.html) and then proceed to…
30
34
 
@@ -48,7 +52,7 @@ bundle install
48
52
 
49
53
  ```ruby
50
54
  use OmniAuth::Builder do
51
- provider :ebay, CLIENT_ID, CLIENT_SECRET, callback_url: RU_NAME,
55
+ provider :ebay_oauth, CLIENT_ID, CLIENT_SECRET, callback_url: RU_NAME,
52
56
  sandbox: false, scope: 'https://api.ebay.com/oauth/api_scope' # redefining additional default options
53
57
  end
54
58
  ```
@@ -60,6 +64,7 @@ Required options:
60
64
  Additional options:
61
65
  - __sandbox__ - Are you running your application in [sandbox mode](<https://developer.ebay.com/api-docs/static/sandbox-landing.html>), default __`true`__.
62
66
  - __scope__ - A list of [OAuth scopes](<https://developer.ebay.com/api-docs/static/oauth-details.html#scopes>) that provide access to the interfaces you call, default: __`[]`__. If you want change scopes you could pass it as string or as array of scopes like so: `['https://api.ebay.com/oauth/api_scope/sell.marketing.readonly', 'https://api.ebay.com/oauth/api_scope/sell.account.readonly']`
67
+ - __prompt__ - Use value `login` to ask user for login and password even if they're already logged in (useful for switching between multiple accounts). By default is absent.
63
68
  - __read_timeout__ - Number of seconds to wait for one block to be read for Auth'n'auth eBay API requests, default is 60.
64
69
  - \+ all [OmniAuth](<https://github.com/omniauth/omniauth>) supported options, like: `callback_path`, `provider_ignores_state` and so on.
65
70
 
@@ -74,8 +79,8 @@ require 'omniauth-ebay-oauth'
74
79
 
75
80
  use Rack::Session::Cookie
76
81
  use OmniAuth::Builder do
77
- provider :ebay, ENV['EBAY_CLIENT_ID'], ENV['EBAY_CLIENT_SECRET'],
78
- callback_url: ENV['EBAY_RU_NAME']
82
+ provider :ebay_oauth, ENV['EBAY_CLIENT_ID'], ENV['EBAY_CLIENT_SECRET'],
83
+ callback_url: ENV['EBAY_RU_NAME'], name: 'ebay'
79
84
  end
80
85
 
81
86
  get '/' do
@@ -98,6 +103,37 @@ bundle exec rake
98
103
 
99
104
  Please, keep in mind [OmniAuth Strategy Contribution Guide](<https://github.com/omniauth/omniauth/wiki/Strategy-Contribution-Guide>) and [eBay developers program](<https://developer.ebay.com/api-docs/static/oauth-tokens.html>).
100
105
 
106
+ ### Releasing new versions
107
+
108
+ 1. Bump version number in `lib/omniauth/ebay-oauth/version.rb`
109
+
110
+ In case of pre-releases keep in mind [rubygems/rubygems#3086](https://github.com/rubygems/rubygems/issues/3086) and check version with command like `Gem::Version.new(OmniAuth::EbayOauth::VERSION).to_s`
111
+
112
+ 2. Fill `CHANGELOG.md` with missing changes, add header with version and date.
113
+
114
+ 3. Make a commit:
115
+
116
+ ```sh
117
+ git add lib/omniauth/ebay-oauth/version.rb CHANGELOG.md
118
+ version=$(ruby -r ./lib/omniauth/ebay-oauth/version.rb -e "puts Gem::Version.new(OmniAuth::EbayOauth::VERSION)")
119
+ git commit --message="${version}: " --edit
120
+ ```
121
+
122
+ 4. Create annotated tag:
123
+
124
+ ```sh
125
+ git tag v${version} --annotate --message="${version}: " --edit --sign
126
+ ```
127
+
128
+ 5. Fill version name into subject line and (optionally) some description (list of changes will be taken from `CHANGELOG.md` and appended automatically)
129
+
130
+ 6. Push it:
131
+
132
+ ```sh
133
+ git push --follow-tags
134
+ ```
135
+
136
+ 7. GitHub Actions will create a new release, build and push gem into [rubygems.org](https://rubygems.org)! You're done!
101
137
 
102
138
  ## Contributing
103
139
 
@@ -7,4 +7,4 @@ require 'omniauth/ebay-oauth/version'
7
7
  require 'omniauth/ebay-oauth/errors'
8
8
  require 'omniauth/ebay-oauth/user_info'
9
9
  require 'omniauth/ebay-oauth/user_info_request'
10
- require 'omniauth/strategies/ebay'
10
+ require 'omniauth/strategies/ebay_oauth'
@@ -2,8 +2,10 @@
2
2
 
3
3
  module OmniAuth
4
4
  module EbayOauth
5
- class FailureResponseCode < StandardError; end
6
- class FailureResponseResult < StandardError; end
7
- class UnsupportedSchemaError < StandardError; end
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
@@ -40,12 +44,19 @@ module OmniAuth
40
44
 
41
45
  def ensure_success_code(response)
42
46
  return if (200..299).cover?(response.code.to_i)
47
+
43
48
  raise FailureResponseCode, response
44
49
  end
45
50
 
46
51
  def ensure_success_result(body)
47
52
  return if body.dig(*STATUS_PATH) == SUCCESS_CODE
48
- raise FailureResponseResult, body
53
+
54
+ error_code = body.dig('GetUserResponse', 'Errors', 'ErrorCode')
55
+ raise(FailureResponseResult, body) unless ERRORS.key?(error_code)
56
+
57
+ err_class = ERRORS[error_code]
58
+ err_message = body.dig('GetUserResponse', 'Errors', 'LongMessage')
59
+ raise err_class, err_message
49
60
  end
50
61
 
51
62
  def http
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module EbayOauth
5
- VERSION = '0.1.1'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  end
@@ -5,21 +5,21 @@ require 'omniauth-oauth2'
5
5
  module OmniAuth
6
6
  module Strategies
7
7
  # OmniAuth strategy for eBay
8
- class Ebay < OmniAuth::Strategies::OAuth2
8
+ class EbayOauth < OmniAuth::Strategies::OAuth2
9
9
  option :production_client_options,
10
10
  user_info_endpoint: 'https://api.ebay.com/ws/api.dll',
11
11
  token_url: 'https://api.ebay.com/identity/v1/oauth2/token',
12
- authorize_url: 'https://signin.ebay.com/authorize'
12
+ authorize_url: 'https://auth.ebay.com/oauth2/authorize'
13
13
  option :sandbox_client_options,
14
14
  user_info_endpoint: 'https://api.sandbox.ebay.com/ws/api.dll',
15
15
  token_url: 'https://api.sandbox.ebay.com/identity/v1/oauth2/token',
16
- authorize_url: 'https://signin.sandbox.ebay.com/authorize'
16
+ authorize_url: 'https://auth.sandbox.ebay.com/oauth2/authorize'
17
17
 
18
18
  option :name, :ebay
19
19
  option :sandbox, true
20
20
  option :callback_url
21
21
 
22
- option :authorize_options, %i[scope]
22
+ option :authorize_options, %i[scope prompt]
23
23
  option :client_options, auth_scheme: :basic_auth, read_timeout: 60
24
24
 
25
25
  uid { user_info.uid }
@@ -33,6 +33,12 @@ module OmniAuth
33
33
  super
34
34
  end
35
35
 
36
+ def callback_phase
37
+ super
38
+ rescue ::OmniAuth::EbayOauth::UserSuspended => e
39
+ fail!(:user_suspended, e)
40
+ end
41
+
36
42
  def callback_url
37
43
  options.callback_url
38
44
  end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'omniauth/ebay-oauth/version'
6
6
 
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'
@@ -18,13 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'omniauth', '~> 1.5'
21
+ spec.add_dependency 'omniauth', '>= 1.5', '< 3'
22
22
  spec.add_dependency 'omniauth-oauth2', '~> 1.4'
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.15'
24
+ spec.add_development_dependency 'bundler', '~> 2.0'
25
25
  spec.add_development_dependency 'rake', '>= 10'
26
26
  spec.add_development_dependency 'rspec', '~> 3.5'
27
- spec.add_development_dependency 'rubocop', '~> 0.42'
27
+ spec.add_development_dependency 'rubocop', '~> 0.81.0'
28
28
  spec.add_development_dependency 'simplecov', '~> 0.10'
29
29
  spec.add_development_dependency 'webmock', '~> 2.1'
30
30
  end
@@ -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
@@ -2,7 +2,9 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe OmniAuth::Strategies::Ebay do
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::Ebay 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::Ebay 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
@@ -58,6 +56,20 @@ RSpec.describe OmniAuth::Strategies::Ebay do
58
56
  end
59
57
  end
60
58
 
59
+ context "when prompt isn't provided" do
60
+ it 'is absent' do
61
+ expect(subject.options.prompt).to be_nil
62
+ end
63
+ end
64
+
65
+ context 'when prompt is provided' do
66
+ let(:options) { { prompt: :login } }
67
+
68
+ it 'concatenates passed scopes with space' do
69
+ expect(subject.options.prompt).to eql :login
70
+ end
71
+ end
72
+
61
73
  context 'sandbox mode' do
62
74
  let(:options) { { sandbox: true } }
63
75
 
@@ -73,7 +85,7 @@ RSpec.describe OmniAuth::Strategies::Ebay do
73
85
 
74
86
  it 'has correct eBay sandbox authorize url' do
75
87
  expect(subject.options.client_options.authorize_url)
76
- .to eq('https://signin.sandbox.ebay.com/authorize')
88
+ .to eq('https://auth.sandbox.ebay.com/oauth2/authorize')
77
89
  end
78
90
  end
79
91
 
@@ -92,14 +104,13 @@ RSpec.describe OmniAuth::Strategies::Ebay do
92
104
 
93
105
  it 'has correct eBay production authorize url' do
94
106
  expect(subject.options.client_options.authorize_url)
95
- .to eq('https://signin.ebay.com/authorize')
107
+ .to eq('https://auth.ebay.com/oauth2/authorize')
96
108
  end
97
109
  end
98
110
  end
99
111
 
100
112
  describe '#user_info' do
101
113
  let(:access_token) { instance_double(OAuth2::AccessToken, token: :token) }
102
- let(:options) { {} }
103
114
  let(:user_info) { instance_double(OmniAuth::EbayOauth::UserInfo) }
104
115
  let(:request) do
105
116
  instance_double(OmniAuth::EbayOauth::UserInfoRequest, call: {})
@@ -120,8 +131,6 @@ RSpec.describe OmniAuth::Strategies::Ebay do
120
131
 
121
132
  describe '#credentials' do
122
133
  let(:access_token) { OAuth2::AccessToken.new(client, token, opts) }
123
- let(:options) { {} }
124
-
125
134
  let(:client) { instance_double(OAuth2::Client) }
126
135
  let(:token) { 'v^1.1#i^1#f^0#I^3#r^0#p^3#t^H4sIAAAAAAAAAOlongstringtoken' }
127
136
  let(:opts) do
@@ -144,4 +153,20 @@ RSpec.describe OmniAuth::Strategies::Ebay do
144
153
  .to be_between(current_time, current_time + expiration_time)
145
154
  end
146
155
  end
156
+
157
+ describe '#callback_phase' do
158
+ context 'when user is suspended' do
159
+ before do
160
+ allow(subject).to receive(:request) do
161
+ raise OmniAuth::EbayOauth::UserSuspended
162
+ end
163
+ allow(subject).to receive(:fail!)
164
+ end
165
+
166
+ it 'fails with user_suspended message' do
167
+ subject.callback_phase
168
+ expect(subject).to have_received(:fail!).with(:user_suspended, anything)
169
+ end
170
+ end
171
+ end
147
172
  end
metadata CHANGED
@@ -1,29 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-ebay-oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.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-01-09 00:00:00.000000000 Z
12
+ date: 2021-04-01 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: omniauth
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - "~>"
18
+ - - ">="
18
19
  - !ruby/object:Gem::Version
19
20
  version: '1.5'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '3'
20
24
  type: :runtime
21
25
  prerelease: false
22
26
  version_requirements: !ruby/object:Gem::Requirement
23
27
  requirements:
24
- - - "~>"
28
+ - - ">="
25
29
  - !ruby/object:Gem::Version
26
30
  version: '1.5'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
27
34
  - !ruby/object:Gem::Dependency
28
35
  name: omniauth-oauth2
29
36
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +51,14 @@ dependencies:
44
51
  requirements:
45
52
  - - "~>"
46
53
  - !ruby/object:Gem::Version
47
- version: '1.15'
54
+ version: '2.0'
48
55
  type: :development
49
56
  prerelease: false
50
57
  version_requirements: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - "~>"
53
60
  - !ruby/object:Gem::Version
54
- version: '1.15'
61
+ version: '2.0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +93,14 @@ dependencies:
86
93
  requirements:
87
94
  - - "~>"
88
95
  - !ruby/object:Gem::Version
89
- version: '0.42'
96
+ version: 0.81.0
90
97
  type: :development
91
98
  prerelease: false
92
99
  version_requirements: !ruby/object:Gem::Requirement
93
100
  requirements:
94
101
  - - "~>"
95
102
  - !ruby/object:Gem::Version
96
- version: '0.42'
103
+ version: 0.81.0
97
104
  - !ruby/object:Gem::Dependency
98
105
  name: simplecov
99
106
  requirement: !ruby/object:Gem::Requirement
@@ -125,15 +132,17 @@ dependencies:
125
132
  description:
126
133
  email:
127
134
  - iezakrevsky@gmail.com
135
+ - envek@envek.name
128
136
  executables: []
129
137
  extensions: []
130
138
  extra_rdoc_files: []
131
139
  files:
140
+ - ".github/workflows/release.yml"
141
+ - ".github/workflows/test.yml"
132
142
  - ".gitignore"
133
143
  - ".rspec"
134
144
  - ".rubocop.yml"
135
- - ".ruby-version"
136
- - ".travis.yml"
145
+ - CHANGELOG.md
137
146
  - Gemfile
138
147
  - LICENSE
139
148
  - README.md
@@ -144,14 +153,15 @@ files:
144
153
  - lib/omniauth/ebay-oauth/user_info.rb
145
154
  - lib/omniauth/ebay-oauth/user_info_request.rb
146
155
  - lib/omniauth/ebay-oauth/version.rb
147
- - lib/omniauth/strategies/ebay.rb
156
+ - lib/omniauth/strategies/ebay_oauth.rb
148
157
  - omniauth-ebay-oauth.gemspec
149
158
  - spec/fixtures/request_headers.yml
150
159
  - spec/fixtures/result_failure.xml
151
160
  - spec/fixtures/result_success.xml
161
+ - spec/fixtures/user_suspended.xml
152
162
  - spec/omniauth/ebay-oauth/user_info_request_spec.rb
153
163
  - spec/omniauth/ebay-oauth/user_info_spec.rb
154
- - spec/omniauth/strategies/ebay_spec.rb
164
+ - spec/omniauth/strategies/ebay_oauth_spec.rb
155
165
  - spec/spec_helper.rb
156
166
  homepage: https://github.com/evilmartians/omniauth-ebay-oauth
157
167
  licenses:
@@ -172,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
182
  - !ruby/object:Gem::Version
173
183
  version: '0'
174
184
  requirements: []
175
- rubyforge_project:
176
- rubygems_version: 2.5.2.1
185
+ rubygems_version: 3.1.4
177
186
  signing_key:
178
187
  specification_version: 4
179
188
  summary: OmniAuth strategy for new eBay OAuth API
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.3.5
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.5
5
- - 2.4.2
6
- before_install: gem install bundler -v 1.15.4