Skip to content

Commit 5e0bdc5

Browse files
committed
Merge branch 'master' into patch-1
2 parents 6273f41 + ed39610 commit 5e0bdc5

File tree

4 files changed

+52
-43
lines changed

4 files changed

+52
-43
lines changed

.github/workflows/main.yml

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,42 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ubuntu-18.04
11+
runs-on: ${{ matrix.os }}
12+
timeout-minutes: 30
1213
strategy:
1314
fail-fast: false
1415
matrix:
15-
os: [ubuntu, macos]
16-
ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, head, debug, truffleruby, truffleruby-head]
16+
os: [ubuntu-latest, macos-latest]
17+
ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, head, debug, truffleruby, truffleruby-head, jruby, jruby-head]
1718
steps:
18-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
1920
- name: Set up Ruby
2021
uses: ruby/setup-ruby@v1
2122
with:
2223
ruby-version: ${{ matrix.ruby }}
2324
bundler-cache: true
24-
- name: Install dependencies
25-
run: bundle install
25+
- name: Set JRUBY_OPTS environment variable
26+
run: echo "JRUBY_OPTS=--debug" >> "$GITHUB_ENV"
27+
if: ${{ startsWith(matrix.ruby, 'jruby') }}
2628
- name: Run tests
2729
run: bundle exec rake
28-
test-jruby:
29-
runs-on: ubuntu-18.04
30-
strategy:
31-
fail-fast: false
32-
matrix:
33-
os: [ubuntu, macos]
34-
jruby: [jruby, jruby-head]
35-
steps:
36-
- uses: actions/checkout@v2
37-
- name: Set up Ruby
38-
uses: ruby/setup-ruby@v1
30+
- uses: actions/upload-artifact@v3
31+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.ruby == '3.0' }}
3932
with:
40-
ruby-version: ${{ matrix.jruby }}
41-
bundler-cache: true
42-
- name: Install dependencies
43-
env:
44-
JRUBY_OPTS: --debug
45-
run: bundle install
46-
- name: Run tests
47-
env:
48-
JRUBY_OPTS: --debug
49-
run: bundle exec rake
33+
name: coverage
34+
path: './coverage/lcov/omniauth-oauth2.lcov'
35+
retention-days: 1
36+
5037
coveralls:
51-
runs-on: ubuntu-18.04
38+
needs: test
39+
runs-on: ubuntu-latest
40+
timeout-minutes: 30
5241
steps:
53-
- uses: actions/checkout@v2
54-
- name: Set up Ruby
55-
uses: ruby/setup-ruby@v1
42+
- uses: actions/download-artifact@v3
5643
with:
57-
ruby-version: 2.6
58-
bundler-cache: true
59-
- name: Install dependencies
60-
run: bundle install
61-
- name: Run tests
62-
run: bundle exec rake
44+
name: coverage
45+
path: './coverage/lcov/'
6346
- name: Coveralls GitHub Action
64-
uses: coverallsapp/github-action@v1.1.2
47+
uses: coverallsapp/github-action@v2
6548
with:
66-
github-token: ${{ secrets.github_token }}
67-
path-to-lcov: './coverage/lcov/omniauth-oauth2.lcov'
49+
file: './coverage/lcov/omniauth-oauth2.lcov'

lib/omniauth/strategies/oauth2.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def callback_phase # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexi
9494
end
9595
rescue ::OAuth2::Error, CallbackError => e
9696
fail!(:invalid_credentials, e)
97-
rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
97+
rescue ::Timeout::Error, ::Errno::ETIMEDOUT, ::OAuth2::TimeoutError, ::OAuth2::ConnectionError => e
9898
fail!(:timeout, e)
9999
rescue ::SocketError => e
100100
fail!(:failed_to_connect, e)

omniauth-oauth2.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
33
require "omniauth-oauth2/version"
44

55
Gem::Specification.new do |gem|
6-
gem.add_dependency "oauth2", [">= 1.4", "< 3"]
7-
gem.add_dependency "omniauth", "~> 2.0"
6+
gem.add_dependency "oauth2", [">= 2.0.2", "< 3"]
7+
gem.add_dependency "omniauth", "~> 2.0"
88

99
gem.add_development_dependency "bundler", "~> 2.0"
1010

spec/omniauth/strategies/oauth2_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,33 @@ def app
140140
expect(instance).to receive(:fail!).with(:csrf_detected, anything)
141141
instance.callback_phase
142142
end
143+
144+
describe 'exception handlings' do
145+
let(:params) do
146+
{"code" => "code", "state" => state}
147+
end
148+
149+
before do
150+
allow_any_instance_of(OmniAuth::Strategies::OAuth2).to receive(:build_access_token).and_raise(exception)
151+
end
152+
153+
{
154+
:invalid_credentials => [OAuth2::Error, OmniAuth::Strategies::OAuth2::CallbackError],
155+
:timeout => [Timeout::Error, Errno::ETIMEDOUT, OAuth2::TimeoutError, OAuth2::ConnectionError],
156+
:failed_to_connect => [SocketError]
157+
}.each do |error_type, exceptions|
158+
exceptions.each do |klass|
159+
context "when #{klass}" do
160+
let(:exception) { klass.new 'error' }
161+
162+
it do
163+
expect(instance).to receive(:fail!).with(error_type, exception)
164+
instance.callback_phase
165+
end
166+
end
167+
end
168+
end
169+
end
143170
end
144171
end
145172

0 commit comments

Comments
 (0)