glogin 0.16.1 → 0.16.3
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/Gemfile +1 -1
- data/lib/glogin/auth.rb +4 -1
- data/lib/glogin/cookie.rb +3 -3
- data/lib/glogin/version.rb +1 -1
- data/test/glogin/test_auth.rb +14 -0
- data/test/glogin/test_cookie.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eda8e66e30f5f90d9a125ca84f104c5bddaf38f9b0ac2381935ee9dac92aff70
|
4
|
+
data.tar.gz: 74d58b5818dbd3f0809336de8895866aa8d9f1a01aa326ba1f1d73fc1383ebab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63ec19df364df3d7db038e71798dff21713df174ecbddb3ef8e26de8a0a76d2c39efaed520809252bf42f0bbf077fd3628f65e006126a56e64ba8fe19700233d
|
7
|
+
data.tar.gz: 280d55cd553045833c0fb23e58918db97659a7f270efa1837223f2d02b781a5e9a60b7db5b96f86aaf9eb4b6fa897d147de5f258c0ecf55c9e4b545fd40a235f
|
data/Gemfile
CHANGED
@@ -29,6 +29,6 @@ gem 'rake', '13.2.1', require: false
|
|
29
29
|
gem 'rdoc', '6.7.0', require: false
|
30
30
|
gem 'rspec-rails', '6.1.3', require: false
|
31
31
|
gem 'rubocop', '1.65.0', require: false
|
32
|
-
gem 'rubocop-rspec', '3.0.
|
32
|
+
gem 'rubocop-rspec', '3.0.3', require: false
|
33
33
|
gem 'simplecov', '0.22.0', require: false
|
34
34
|
gem 'webmock', '3.23.1', require: false
|
data/lib/glogin/auth.rb
CHANGED
@@ -94,7 +94,10 @@ module GLogin
|
|
94
94
|
req['Accept'] = 'application/json'
|
95
95
|
res = http.request(req)
|
96
96
|
raise "HTTP error ##{res.code} with code #{escape(code)}: #{res.body}" unless res.code == '200'
|
97
|
-
JSON.parse(res.body)
|
97
|
+
json = JSON.parse(res.body)
|
98
|
+
token = json['access_token']
|
99
|
+
raise "There is no 'access_token' in JSON response from GitHub: #{res.body}" if token.nil?
|
100
|
+
token
|
98
101
|
end
|
99
102
|
|
100
103
|
def escape(txt)
|
data/lib/glogin/cookie.rb
CHANGED
@@ -92,9 +92,9 @@ module GLogin
|
|
92
92
|
raise 'JSON can\'t be nil' if json.nil?
|
93
93
|
raise 'JSON must contain "id" key' if json['id'].nil?
|
94
94
|
json.each do |k, v|
|
95
|
-
raise "
|
96
|
-
raise "
|
97
|
-
raise "
|
95
|
+
raise "The key #{k} is not a string" unless k.is_a?(String)
|
96
|
+
raise "The key #{k} is not allowed" unless %w[id login avatar_url bearer].include?(k)
|
97
|
+
raise "The value '#{v}' of #{k} is not String or Integer" unless v.is_a?(String) || v.is_a?(Integer)
|
98
98
|
end
|
99
99
|
@id = json['id']
|
100
100
|
@login = json['login'] || ''
|
data/lib/glogin/version.rb
CHANGED
data/test/glogin/test_auth.rb
CHANGED
@@ -65,4 +65,18 @@ class TestAuth < Minitest::Test
|
|
65
65
|
e = assert_raises { auth.user('437849732894732') }
|
66
66
|
assert(e.message.include?('with code "43784***'))
|
67
67
|
end
|
68
|
+
|
69
|
+
def test_broken_json
|
70
|
+
auth = GLogin::Auth.new('1234', '4433', 'https://example.org')
|
71
|
+
stub_request(:post, 'https://github.com/login/oauth/access_token').to_return(body: 'Hello!')
|
72
|
+
e = assert_raises { auth.user('47839893') }
|
73
|
+
assert(e.message.include?('unexpected token'), e)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_no_token_in_json
|
77
|
+
auth = GLogin::Auth.new('1234', '4433', 'https://example.org')
|
78
|
+
stub_request(:post, 'https://github.com/login/oauth/access_token').to_return(body: '{}')
|
79
|
+
e = assert_raises { auth.user('47839893') }
|
80
|
+
assert(e.message.include?('There is no \'access_token\''), e)
|
81
|
+
end
|
68
82
|
end
|
data/test/glogin/test_cookie.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glogin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base58
|