Skip to content
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Commit 674eee2

Browse files
authored
Merge pull request #13 from koshilife/develop
release 0.2.1
2 parents a71dfff + 084297c commit 674eee2

File tree

7 files changed

+77
-67
lines changed

7 files changed

+77
-67
lines changed

.rubocop.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ Metrics/BlockNesting:
2323
Max: 2
2424

2525
Layout/LineLength:
26-
AllowURI: true
27-
Enabled: false
26+
Max: 120
2827

2928
Metrics/MethodLength:
3029
CountComments: false
31-
Max: 15
30+
Max: 20
3231

3332
Metrics/ParameterLists:
3433
Max: 4
@@ -39,10 +38,10 @@ Metrics/AbcSize:
3938

4039
Style/CollectionMethods:
4140
PreferredMethods:
42-
map: 'collect'
43-
reduce: 'inject'
44-
find: 'detect'
45-
find_all: 'select'
41+
map: "collect"
42+
reduce: "inject"
43+
find: "detect"
44+
find_all: "select"
4645

4746
Style/Documentation:
4847
Enabled: false
@@ -60,10 +59,13 @@ Style/ExpandPathArguments:
6059
Enabled: false
6160

6261
Style/HashSyntax:
63-
EnforcedStyle: hash_rockets
62+
EnforcedStyle: ruby19
6463

6564
Style/Lambda:
6665
Enabled: false
6766

6867
Style/RaiseArgs:
69-
EnforcedStyle: compact
68+
EnforcedStyle: compact
69+
70+
Style/AsciiComments:
71+
Enabled: false

CHANGELOG.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
# 0.2.0
1+
# CHANGELOG
2+
3+
## 0.2.1
4+
5+
- fix rubocop warnings.
6+
7+
## 0.2.0
28

39
- refs #11 fix library dependencies.
410
- remove minitest-reporter.
511

6-
# 0.1.2
12+
## 0.1.2
713

814
- make the error handling when missing scope for reading user info better.
915

10-
# 0.1.1
16+
## 0.1.1
1117

1218
- refs #4 Add tests and make code coverage 100%.
1319

14-
# 0.1.0
20+
## 0.1.0
1521

1622
- Initial release

Rakefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
require "bundler/gem_tasks"
2-
require "rake/testtask"
1+
# frozen_string_literal: true
2+
3+
require 'bundler/gem_tasks'
4+
require 'rake/testtask'
35

46
Rake::TestTask.new(:test) do |t|
5-
t.libs << "test"
6-
t.libs << "lib"
7-
t.test_files = FileList["test/**/*_test.rb"]
7+
t.libs << 'test'
8+
t.libs << 'lib'
9+
t.test_files = FileList['test/**/*_test.rb']
810
end
911

10-
task :default => :test
12+
task default: :test

lib/omniauth-zoom/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module OmniAuth
44
module Zoom
5-
VERSION = '0.2.0'
5+
VERSION = '0.2.1'
66
end
77
end

lib/omniauth/strategies/zoom.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ module Strategies
99
# OmniAuth strategy for zoom.us
1010
class Zoom < OmniAuth::Strategies::OAuth2
1111
option :name, 'zoom'
12-
option :client_options, :site => 'https://zoom.us'
12+
option :client_options, site: 'https://zoom.us'
1313

1414
uid { raw_info['id'] }
15-
extra { {:raw_info => raw_info} }
15+
extra { {raw_info: raw_info} }
1616

1717
protected
1818

1919
def build_access_token
2020
params = {
21-
:grant_type => 'authorization_code',
22-
:code => request.params['code'],
23-
:redirect_uri => callback_url
21+
grant_type: 'authorization_code',
22+
code: request.params['code'],
23+
redirect_uri: callback_url
2424
}
2525
path = "#{client.options[:token_url]}?#{URI.encode_www_form(params)}"
2626
headers_secret = Base64.strict_encode64("#{client.id}:#{client.secret}")
27-
opts = {:headers => {:Authorization => "Basic #{headers_secret}"}}
27+
opts = {headers: {Authorization: "Basic #{headers_secret}"}}
2828

2929
res = client.request(:post, path, opts)
3030
::OAuth2::AccessToken.from_hash(client, res.parsed)

test/omniauth/zoom_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_it_has_a_client_options
1919
def test_it_returns_auth_hash_in_callback_phase
2020
add_mock_exchange_token
2121
add_mock_user_info
22-
post '/auth/zoom/callback', :code => @authorization_code, :state => 'state123'
22+
post '/auth/zoom/callback', code: @authorization_code, state: 'state123'
2323

2424
actual_auth = auth_hash.to_hash
2525
assert(!actual_auth['credentials'].delete('expires_at').nil?)
@@ -38,7 +38,7 @@ def test_it_returns_auth_hash_in_callback_phase
3838
def test_it_returns_auth_hash_in_case_of_failure_of_get_user_info_in_callbach_phase
3939
add_mock_exchange_token
4040
add_mock_user_info_then_fail_because_of_missing_scope
41-
post '/auth/zoom/callback', :code => @authorization_code, :state => 'state123'
41+
post '/auth/zoom/callback', code: @authorization_code, state: 'state123'
4242

4343
actual_auth = auth_hash.to_hash
4444
assert(!actual_auth['credentials'].delete('expires_at').nil?)
@@ -55,7 +55,7 @@ def test_it_returns_auth_hash_in_case_of_failure_of_get_user_info_in_callbach_ph
5555
def test_it_does_not_return_auth_hash_in_case_of_unkonwn_failure_in_callbach_phase
5656
add_mock_exchange_token
5757
add_mock_user_info_then_fail_because_of_unknown
58-
post '/auth/zoom/callback', :code => @authorization_code, :state => 'state123'
58+
post '/auth/zoom/callback', code: @authorization_code, state: 'state123'
5959
assert_nil(auth_hash)
6060
end
6161

test/test_helper.rb

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def setup
2525
@client_id = 'DUMMY_CLIENT_ID'
2626
@client_secret = 'DUMMY_CLIENT_SECRET'
2727
@scope = 'user_profile'
28-
@options = {:scope => @scope, :provider_ignores_state => true}
28+
@options = {scope: @scope, provider_ignores_state: true}
2929
@authorization_code = 'DUMMY_AUTH_CODE'
3030
@access_token = 'DUMMY_TOKEN'
3131
@refresh_token = 'DUMMY_REFRESH_TOKEN'
@@ -43,16 +43,16 @@ def add_mock_exchange_token
4343
secret = Base64.strict_encode64("#{@client_id}:#{@client_secret}")
4444
headers = {'Authorization' => "Basic #{secret}"}
4545
res_headers = {'Content-Type' => 'application/json'}
46-
stub_request(:post, url).with(:headers => headers).to_return(:status => 200, :body => dummy_token_response.to_json, :headers => res_headers)
46+
stub_request(:post, url).with(headers: headers).to_return(status: 200, body: dummy_token_response.to_json, headers: res_headers)
4747
end
4848

4949
def dummy_token_response
5050
{
51-
:access_token => @access_token,
52-
:token_type => 'bearer',
53-
:refresh_token => @refresh_token,
54-
:expires_in => 3600,
55-
:scope => 'user_profile'
51+
access_token: @access_token,
52+
token_type: 'bearer',
53+
refresh_token: @refresh_token,
54+
expires_in: 3600,
55+
scope: 'user_profile'
5656
}
5757
end
5858

@@ -61,55 +61,55 @@ def add_mock_user_info
6161
url = 'https://zoom.us/v2/users/me'
6262
headers = {'Authorization' => "Bearer #{@access_token}"}
6363
res_headers = {'Content-Type' => 'application/json'}
64-
stub_request(:get, url).with(:headers => headers).to_return(:status => 200, :body => dummy_user_info_response.to_json, :headers => res_headers)
64+
stub_request(:get, url).with(headers: headers).to_return(status: 200, body: dummy_user_info_response.to_json, headers: res_headers)
6565
end
6666

6767
def add_mock_user_info_then_fail_because_of_missing_scope
6868
WebMock.enable!
6969
url = 'https://zoom.us/v2/users/me'
70-
response = {:code => 124, :message => 'Invalid access token.'}
70+
response = {code: 124, message: 'Invalid access token.'}
7171
headers = {'Authorization' => "Bearer #{@access_token}"}
7272
res_headers = {'Content-Type' => 'application/json'}
73-
stub_request(:get, url).with(:headers => headers).to_return(:status => 400, :body => response.to_json, :headers => res_headers)
73+
stub_request(:get, url).with(headers: headers).to_return(status: 400, body: response.to_json, headers: res_headers)
7474
end
7575

7676
def add_mock_user_info_then_fail_because_of_unknown
7777
WebMock.enable!
7878
url = 'https://zoom.us/v2/users/me'
79-
response = {:code => 999, :message => 'Unknown Error'}
79+
response = {code: 999, message: 'Unknown Error'}
8080
headers = {'Authorization' => "Bearer #{@access_token}"}
8181
res_headers = {'Content-Type' => 'application/json'}
82-
stub_request(:get, url).with(:headers => headers).to_return(:status => 500, :body => response.to_json, :headers => res_headers)
82+
stub_request(:get, url).with(headers: headers).to_return(status: 500, body: response.to_json, headers: res_headers)
8383
end
8484

8585
def dummy_user_info_response
8686
{
87-
:id => 'KdYKjnimT4KPd8FFgQt9FQ',
88-
:first_name => 'Jane',
89-
:last_name => 'Dev',
90-
:email => 'jane.dev@email.com',
91-
:type => 2,
92-
:role_name => 'Owner',
93-
:pmi => 1_234_567_890,
94-
:use_pmi => false,
95-
:vanity_url => 'https://janedevinc.zoom.us/my/janedev',
96-
:personal_meeting_url => 'https://janedevinc.zoom.us/j/1234567890',
97-
:timezone => 'America/Denver',
98-
:verified => 1,
99-
:dept => '',
100-
:created_at => '2019-04-05T15:24:32Z',
101-
:last_login_time => '2019-12-16T18:02:48Z',
102-
:last_client_version => '4.6.12611.1124(mac)',
103-
:pic_url => 'https://janedev.zoom.us/p/KdYKjnimFR5Td8KKdQt9FQ/19f6430f-ca72-4154-8998-ede6be4542c7-837',
104-
:host_key => '533895',
105-
:jid => 'kdykjnimt4kpd8kkdqt9fq@xmpp.zoom.us',
106-
:group_ids => [],
107-
:im_group_ids => ['3NXCD9VFTCOUH8LD-QciGw'],
108-
:account_id => 'gVcjZnYYRLDbb_MfgHuaxg',
109-
:language => 'en-US',
110-
:phone_country => 'US',
111-
:phone_number => '+1 1234567891',
112-
:status => 'active'
87+
id: 'KdYKjnimT4KPd8FFgQt9FQ',
88+
first_name: 'Jane',
89+
last_name: 'Dev',
90+
email: 'jane.dev@email.com',
91+
type: 2,
92+
role_name: 'Owner',
93+
pmi: 1_234_567_890,
94+
use_pmi: false,
95+
vanity_url: 'https://janedevinc.zoom.us/my/janedev',
96+
personal_meeting_url: 'https://janedevinc.zoom.us/j/1234567890',
97+
timezone: 'America/Denver',
98+
verified: 1,
99+
dept: '',
100+
created_at: '2019-04-05T15:24:32Z',
101+
last_login_time: '2019-12-16T18:02:48Z',
102+
last_client_version: '4.6.12611.1124(mac)',
103+
pic_url: 'https://janedev.zoom.us/p/KdYKjnimFR5Td8KKdQt9FQ/19f6430f-ca72-4154-8998-ede6be4542c7-837',
104+
host_key: '533895',
105+
jid: 'kdykjnimt4kpd8kkdqt9fq@xmpp.zoom.us',
106+
group_ids: [],
107+
im_group_ids: ['3NXCD9VFTCOUH8LD-QciGw'],
108+
account_id: 'gVcjZnYYRLDbb_MfgHuaxg',
109+
language: 'en-US',
110+
phone_country: 'US',
111+
phone_number: '+1 1234567891',
112+
status: 'active'
113113
}
114114
end
115115
end

0 commit comments

Comments
 (0)