omniauth-google-oauth2 1.1.3 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eb54f22683d8785746e4da71576b5f84cf2f654961879dc10c2585b61ac27e6
4
- data.tar.gz: 32dd7cb7faaece80dd26f9675f2cd46fc20d39531a2230d24709296fa53cf1bc
3
+ metadata.gz: 45ce2b17155396ac41a875e3bcadfd9827cf45b30d2c64309992b84d3ef0088d
4
+ data.tar.gz: d9f9e89a3526a81b19a66a222b3534848c66914a34960500a6ed57fe23e40fdd
5
5
  SHA512:
6
- metadata.gz: aebca15a4956422c94af941328c51007a4bf0d461fe109586ae90b4dddcfdc0acd8cc7a6abade1589986866040962be3457ab3ab4c27ebfbe3a390d15e1f0a38
7
- data.tar.gz: 8d2a97f39e08ee8f8ccb00e6b9d7bdb6d9d96d26097ad36ca7486ba9f41a2671fa77c3b19628c83aa475a939c01331539df468d1280bc990927fc0e5475a3fe7
6
+ metadata.gz: 543ac7161867df4ec9826c29ccebe89ae70348b3038095b747b2160f2988c2cdcfccb418d4afaaff6b564e8df4aafa5dd704f8632cbd755ef5d222b7a6e63697
7
+ data.tar.gz: 2585a702d4595b4986c6406fc8121e4f61ff4fc4558372fc689e28cc87ce21ba8a387b8999a2cc1c53bcfa96df6e68457777f493675c71a511f9e0d5adae12e6
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', truffleruby-head]
10
+ ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', truffleruby-head]
11
11
 
12
12
  steps:
13
13
  - uses: actions/checkout@v2
data/.rubocop.yml CHANGED
@@ -28,3 +28,5 @@ Style/HashTransformKeys:
28
28
  Enabled: false
29
29
  Style/HashTransformValues:
30
30
  Enabled: false
31
+ AllCops:
32
+ NewCops: enable
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 1.2.0 - 2024-09-15
5
+
6
+ ### Added
7
+ - jwt 2.9.0 support for their updated claims code.
8
+
9
+ ### Deprecated
10
+ - Nothing.
11
+
12
+ ### Removed
13
+ - Ruby 2.3 and 2.4 support.
14
+ - Support for jwt < 2.9.0.
15
+
16
+ ### Fixed
17
+ - Fixed image sizing code.
18
+ - Rubocop configuration updates.
19
+
4
20
  ## 1.1.3 - 2024-08-29
5
21
 
6
22
  ### Added
data/README.md CHANGED
@@ -64,6 +64,7 @@ You can configure several options, which you pass in to the `provider` method vi
64
64
  * `image_aspect_ratio`: The shape of the user's profile picture. Possible values are:
65
65
  * `original`: Picture maintains its original aspect ratio.
66
66
  * `square`: Picture presents equal width and height.
67
+ * `smart`: Picture presents equal width and height with smart cropping.
67
68
 
68
69
  Defaults to `original`.
69
70
 
data/examples/Gemfile CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'omniauth-google-oauth2', '~> 1.1.3'
5
+ gem 'omniauth-google-oauth2', '~> 1.2.0'
6
6
  gem 'rubocop'
7
7
  gem 'sinatra', '~> 1.4'
8
8
  gem 'webrick'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module GoogleOauth2
5
- VERSION = '1.1.3'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
@@ -76,17 +76,17 @@ module OmniAuth
76
76
 
77
77
  # We have to manually verify the claims because the third parameter to
78
78
  # JWT.decode is false since no verification key is provided.
79
- ::JWT::Verify.verify_claims(decoded,
80
- verify_iss: true,
81
- iss: ALLOWED_ISSUERS,
82
- verify_aud: true,
83
- aud: options.client_id,
84
- verify_sub: false,
85
- verify_expiration: true,
86
- verify_not_before: true,
87
- verify_iat: false,
88
- verify_jti: false,
89
- leeway: options[:jwt_leeway])
79
+ ::JWT::Claims.verify!(decoded,
80
+ verify_iss: true,
81
+ iss: ALLOWED_ISSUERS,
82
+ verify_aud: true,
83
+ aud: options.client_id,
84
+ verify_sub: false,
85
+ verify_expiration: true,
86
+ verify_not_before: true,
87
+ verify_iat: false,
88
+ verify_jti: false,
89
+ leeway: options[:jwt_leeway])
90
90
 
91
91
  hash[:id_info] = decoded
92
92
  end
@@ -178,17 +178,16 @@ module OmniAuth
178
178
  def image_url
179
179
  return nil unless raw_info['picture']
180
180
 
181
- u = URI.parse(raw_info['picture'].gsub('https:https', 'https'))
181
+ u = URI.parse(raw_info['picture'])
182
182
 
183
- path_index = u.path.to_s.index('/photo.jpg')
183
+ md = u.path.to_s.match(/(.*)(=((w[0-9]*|h[0-9]*|s[0-9]*|c|p)-?)*)$/)
184
184
 
185
- if path_index && image_size_opts_passed?
186
- u.path.insert(path_index, image_params)
187
- u.path = u.path.gsub('//', '/')
185
+ # Check for sizing, remove if present.
186
+ u.path = md[1] if md && !md[1].nil? && !md[2].nil?
188
187
 
189
- # Check if the image is already sized!
190
- split_path = u.path.split('/')
191
- u.path = u.path.sub("/#{split_path[-3]}", '') if split_path[-3] =~ IMAGE_SIZE_REGEXP
188
+ if image_size_opts_passed?
189
+ u.path += image_params
190
+ u.path = u.path.gsub('//', '/')
192
191
  end
193
192
 
194
193
  u.query = strip_unnecessary_query_parameters(u.query)
@@ -202,15 +201,17 @@ module OmniAuth
202
201
 
203
202
  def image_params
204
203
  image_params = []
205
- if options[:image_size].is_a?(Integer)
204
+ case options[:image_size]
205
+ when Integer
206
206
  image_params << "s#{options[:image_size]}"
207
- elsif options[:image_size].is_a?(Hash)
207
+ when Hash
208
208
  image_params << "w#{options[:image_size][:width]}" if options[:image_size][:width]
209
209
  image_params << "h#{options[:image_size][:height]}" if options[:image_size][:height]
210
210
  end
211
211
  image_params << 'c' if options[:image_aspect_ratio] == 'square'
212
+ image_params << 'p' if options[:image_aspect_ratio] == 'smart'
212
213
 
213
- '/' + image_params.join('-')
214
+ "=#{image_params.join('-')}"
214
215
  end
215
216
 
216
217
  def strip_unnecessary_query_parameters(query_parameters)
@@ -18,9 +18,9 @@ Gem::Specification.new do |gem|
18
18
  gem.files = `git ls-files`.split("\n")
19
19
  gem.require_paths = ['lib']
20
20
 
21
- gem.required_ruby_version = '>= 2.2'
21
+ gem.required_ruby_version = '>= 2.5'
22
22
 
23
- gem.add_runtime_dependency 'jwt', '>= 2.0'
23
+ gem.add_runtime_dependency 'jwt', '>= 2.9'
24
24
  gem.add_runtime_dependency 'oauth2', '~> 2.0'
25
25
  gem.add_runtime_dependency 'omniauth', '~> 2.0'
26
26
  gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.8'
@@ -324,20 +324,20 @@ describe OmniAuth::Strategies::GoogleOauth2 do
324
324
  it 'has the correct default callback path' do
325
325
  allow(subject).to receive(:full_host) { base_url }
326
326
  allow(subject).to receive(:script_name) { '' }
327
- expect(subject.send(:callback_url)).to eq(base_url + '/auth/google_oauth2/callback')
327
+ expect(subject.send(:callback_url)).to eq("#{base_url}/auth/google_oauth2/callback")
328
328
  end
329
329
 
330
330
  it 'should set the callback path with script_name if present' do
331
331
  allow(subject).to receive(:full_host) { base_url }
332
332
  allow(subject).to receive(:script_name) { '/v1' }
333
- expect(subject.send(:callback_url)).to eq(base_url + '/v1/auth/google_oauth2/callback')
333
+ expect(subject.send(:callback_url)).to eq("#{base_url}/v1/auth/google_oauth2/callback")
334
334
  end
335
335
 
336
336
  it 'should set the callback_path parameter if present' do
337
337
  @options = { callback_path: '/auth/foo/callback' }
338
338
  allow(subject).to receive(:full_host) { base_url }
339
339
  allow(subject).to receive(:script_name) { '' }
340
- expect(subject.send(:callback_url)).to eq(base_url + '/auth/foo/callback')
340
+ expect(subject.send(:callback_url)).to eq("#{base_url}/auth/foo/callback")
341
341
  end
342
342
  end
343
343
 
@@ -544,103 +544,146 @@ describe OmniAuth::Strategies::GoogleOauth2 do
544
544
  describe 'when a picture is returned from google' do
545
545
  it 'should return the image with size specified in the `image_size` option' do
546
546
  @options = { image_size: 50 }
547
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
548
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg')
547
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
548
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
549
549
  end
550
550
 
551
551
  it 'should return the image with size specified in the `image_size` option when sizing is in the picture' do
552
552
  @options = { image_size: 50 }
553
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh4.googleusercontent.com/url/s96-c/photo.jpg' } }
554
- expect(subject.info[:image]).to eq('https://lh4.googleusercontent.com/url/s50/photo.jpg')
553
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s96' } }
554
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
555
555
  end
556
556
 
557
- it 'should handle a picture with too many slashes correctly' do
557
+ it 'should return the image with size specified in the `image_size` option when sizing is in the picture and cropped' do
558
558
  @options = { image_size: 50 }
559
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url//photo.jpg' } }
560
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg')
559
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s96-c' } }
560
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
561
561
  end
562
562
 
563
- it 'should handle a picture with a size query parameter correctly' do
563
+ it 'should handle a picture with too many slashes' do
564
564
  @options = { image_size: 50 }
565
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg?sz=50' } }
566
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg')
565
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a//ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
566
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
567
+ end
568
+
569
+ it 'should handle a picture with a size query parameter' do
570
+ @options = { image_size: 50 }
571
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0?sz=96' } }
572
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
573
+ end
574
+
575
+ it 'should handle a picture with a size query parameter and sizing is in the picture' do
576
+ @options = { image_size: 50 }
577
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s96-c?sz=96' } }
578
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
567
579
  end
568
580
 
569
581
  it 'should handle a picture with a size query parameter and other valid query parameters correctly' do
570
582
  @options = { image_size: 50 }
571
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg?sz=50&hello=true&life=42' } }
572
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg?hello=true&life=42')
583
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0?sz=50&hello=true&life=42' } }
584
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50?hello=true&life=42')
585
+ end
586
+
587
+ it 'should handle a picture with a size query parameter, other valid query parameters and sizing is in the picture correctly' do
588
+ @options = { image_size: 50 }
589
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s96-c?sz=50&hello=true&life=42' } }
590
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50?hello=true&life=42')
573
591
  end
574
592
 
575
593
  it 'should handle a picture with other valid query parameters correctly' do
576
594
  @options = { image_size: 50 }
577
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg?hello=true&life=42' } }
578
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg?hello=true&life=42')
595
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0?hello=true&life=42' } }
596
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50?hello=true&life=42')
579
597
  end
580
598
 
581
599
  it 'should return the image with width and height specified in the `image_size` option' do
582
600
  @options = { image_size: { width: 50, height: 40 } }
583
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
584
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40/photo.jpg')
601
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
602
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40')
585
603
  end
586
604
 
587
605
  it 'should return the image with width and height specified in the `image_size` option when sizing is in the picture' do
588
606
  @options = { image_size: { width: 50, height: 40 } }
589
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/w100-h80-c/photo.jpg' } }
590
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40/photo.jpg')
607
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w100-h80-c' } }
608
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40')
591
609
  end
592
610
 
593
- it 'should return square image when `image_aspect_ratio` is specified' do
611
+ it 'should return square image when square `image_aspect_ratio` is specified' do
594
612
  @options = { image_aspect_ratio: 'square' }
595
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
596
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/c/photo.jpg')
613
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
614
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=c')
597
615
  end
598
616
 
599
- it 'should return square image when `image_aspect_ratio` is specified and sizing is in the picture' do
617
+ it 'should return square image when square `image_aspect_ratio` is specified and sizing is in the picture' do
600
618
  @options = { image_aspect_ratio: 'square' }
601
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/c/photo.jpg' } }
602
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/c/photo.jpg')
619
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-c' } }
620
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=c')
621
+ end
622
+
623
+ it 'should return smart image when smart `image_aspect_ratio` is specified' do
624
+ @options = { image_aspect_ratio: 'smart' }
625
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
626
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=p')
603
627
  end
604
628
 
605
- it 'should return square sized image when `image_aspect_ratio` and `image_size` is set' do
629
+ it 'should return smart image when smart `image_aspect_ratio` is specified and sizing is in the picture' do
630
+ @options = { image_aspect_ratio: 'smart' }
631
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-c' } }
632
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=p')
633
+ end
634
+
635
+ it 'should return square sized image when square `image_aspect_ratio` and `image_size` is set' do
606
636
  @options = { image_aspect_ratio: 'square', image_size: 50 }
607
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
608
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50-c/photo.jpg')
637
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
638
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-c')
609
639
  end
610
640
 
611
- it 'should return square sized image when `image_aspect_ratio` and `image_size` is set and sizing is in the picture' do
641
+ it 'should return square sized image when square `image_aspect_ratio` and `image_size` is set and sizing is in the picture' do
612
642
  @options = { image_aspect_ratio: 'square', image_size: 50 }
613
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/s90/photo.jpg' } }
614
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50-c/photo.jpg')
643
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s90' } }
644
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-c')
645
+ end
646
+
647
+ it 'should return smart sized image when smart `image_aspect_ratio` and `image_size` is set' do
648
+ @options = { image_aspect_ratio: 'smart', image_size: 50 }
649
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
650
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-p')
651
+ end
652
+
653
+ it 'should return smart sized image when smart `image_aspect_ratio` and `image_size` is set and sizing is in the picture' do
654
+ @options = { image_aspect_ratio: 'smart', image_size: 50 }
655
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s90' } }
656
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-p')
615
657
  end
616
658
 
617
- it 'should return square sized image when `image_aspect_ratio` and `image_size` has height and width' do
659
+ it 'should return square sized image when square `image_aspect_ratio` and `image_size` has height and width' do
618
660
  @options = { image_aspect_ratio: 'square', image_size: { width: 50, height: 40 } }
619
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
620
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40-c/photo.jpg')
661
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
662
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40-c')
621
663
  end
622
664
 
623
- it 'should return square sized image when `image_aspect_ratio` and `image_size` has height and width and sizing is in the picture' do
665
+ it 'should return square sized image when square `image_aspect_ratio` and `image_size` has height and width and sizing is in the picture' do
624
666
  @options = { image_aspect_ratio: 'square', image_size: { width: 50, height: 40 } }
625
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/w100-h80/photo.jpg' } }
626
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40-c/photo.jpg')
667
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w100-h80-c' } }
668
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40-c')
627
669
  end
628
670
 
629
- it 'should return original image if image url does not end in `photo.jpg`' do
630
- @options = { image_size: 50 }
631
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photograph.jpg' } }
632
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/photograph.jpg')
671
+ it 'should return smart sized image when smart `image_aspect_ratio` and `image_size` has height and width' do
672
+ @options = { image_aspect_ratio: 'smart', image_size: { width: 50, height: 40 } }
673
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
674
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40-p')
633
675
  end
634
- end
635
676
 
636
- it 'should return original image if no options are provided' do
637
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
638
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/photo.jpg')
677
+ it 'should return smart sized image when smart `image_aspect_ratio` and `image_size` has height and width and sizing is in the picture' do
678
+ @options = { image_aspect_ratio: 'smart', image_size: { width: 50, height: 40 } }
679
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w100-h80-c' } }
680
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40-p')
681
+ end
639
682
  end
640
683
 
641
- it 'should return correct image if google image url has double https' do
642
- allow(subject).to receive(:raw_info) { { 'picture' => 'https:https://lh3.googleusercontent.com/url/photo.jpg' } }
643
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/photo.jpg')
684
+ it 'should return original image if no options are provided' do
685
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
686
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0')
644
687
  end
645
688
  end
646
689
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-google-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Ellithorpe
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-08-30 00:00:00.000000000 Z
12
+ date: 2024-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jwt
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '2.0'
20
+ version: '2.9'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '2.0'
27
+ version: '2.9'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: oauth2
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
- version: '2.2'
150
+ version: '2.5'
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="