octoauth 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +3 -3
- data/circle.yml +13 -0
- data/lib/octoauth/auth.rb +14 -12
- data/octoauth.gemspec +7 -7
- data/spec/examples/existing_token.yml +2 -0
- data/spec/examples/write_first_test.yml +2 -0
- data/spec/fixtures/cassettes/alternate_endpoints.yml +193 -0
- data/spec/fixtures/cassettes/autosaving_config_file.yml +145 -15
- data/spec/fixtures/cassettes/create_token.yml +193 -0
- data/spec/fixtures/cassettes/handle_two_factor.yml +209 -11
- data/spec/fixtures/cassettes/recreate_token.yml +383 -0
- data/spec/fixtures/cassettes/requesting_scopes.yml +145 -15
- data/spec/fixtures/cassettes/write_to_first_file.yml +193 -0
- data/spec/octoauth/auth_spec.rb +62 -87
- data/spec/octoauth/configfile_spec.rb +7 -7
- data/spec/spec_helper.rb +12 -8
- metadata +28 -26
- data/.travis.yml +0 -17
- data/spec/examples/conf_a.yml +0 -3
- data/spec/fixtures/cassettes/Write_to_first_file.yml +0 -63
- data/spec/fixtures/cassettes/creates_new_token.yml +0 -63
- data/spec/fixtures/cassettes/request_user_input.yml +0 -63
- data/spec/fixtures/cassettes/save_to_disk.yml +0 -63
@@ -1,43 +1,173 @@
|
|
1
1
|
---
|
2
2
|
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<USER>:<PASSWORD>@api.github.com/authorizations
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/vnd.github.v3+json
|
12
|
+
User-Agent:
|
13
|
+
- Octokit Ruby Gem 4.1.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- GitHub.com
|
25
|
+
Date:
|
26
|
+
- Mon, 26 Oct 2015 02:45:37 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Status:
|
32
|
+
- 200 OK
|
33
|
+
X-Ratelimit-Limit:
|
34
|
+
- '5000'
|
35
|
+
X-Ratelimit-Remaining:
|
36
|
+
- '4984'
|
37
|
+
X-Ratelimit-Reset:
|
38
|
+
- '1445829724'
|
39
|
+
Cache-Control:
|
40
|
+
- private, max-age=60, s-maxage=60
|
41
|
+
Vary:
|
42
|
+
- Accept, Authorization, Cookie, X-GitHub-OTP
|
43
|
+
- Accept-Encoding
|
44
|
+
X-Github-Media-Type:
|
45
|
+
- github.v3; format=json
|
46
|
+
X-Xss-Protection:
|
47
|
+
- 1; mode=block
|
48
|
+
X-Frame-Options:
|
49
|
+
- deny
|
50
|
+
Content-Security-Policy:
|
51
|
+
- default-src 'none'
|
52
|
+
Access-Control-Allow-Credentials:
|
53
|
+
- 'true'
|
54
|
+
Access-Control-Expose-Headers:
|
55
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
56
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
57
|
+
Access-Control-Allow-Origin:
|
58
|
+
- "*"
|
59
|
+
Strict-Transport-Security:
|
60
|
+
- max-age=31536000; includeSubdomains; preload
|
61
|
+
X-Content-Type-Options:
|
62
|
+
- nosniff
|
63
|
+
body:
|
64
|
+
encoding: ASCII-8BIT
|
65
|
+
string: '[{"id":23673434,"url":"https://api.github.com/authorizations/23673434","app":{"name":"requesting_scopes/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"7873c3c9471702e93416139dec20bc4c6c35e93e91776bbe284e3c08e49020f0","token_last_eight":"07112afc","note":"requesting_scopes/bean","note_url":null,"created_at":"2015-10-26T02:22:04Z","updated_at":"2015-10-26T02:22:04Z","scopes":["gist","delete_repo"],"fingerprint":null},{"id":23673435,"url":"https://api.github.com/authorizations/23673435","app":{"name":"autosave_test/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"d04e11d46f3358c2ccc9ff61a10af5e4bc9de0c468404f6821e6ca3342c6477f","token_last_eight":"4c625306","note":"autosave_test/bean","note_url":null,"created_at":"2015-10-26T02:22:04Z","updated_at":"2015-10-26T02:22:04Z","scopes":[],"fingerprint":null},{"id":23673463,"url":"https://api.github.com/authorizations/23673463","app":{"name":"existing_token/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"81058c676b8a2de95487b5ad9ed1090f74efa8a581ba69487f274c4552b4716a","token_last_eight":"f9a2fcda","note":"existing_token/bean","note_url":null,"created_at":"2015-10-26T02:23:05Z","updated_at":"2015-10-26T02:23:05Z","scopes":[],"fingerprint":null},{"id":23673464,"url":"https://api.github.com/authorizations/23673464","app":{"name":"create_token/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"5296cd63dbc0add3fb40fd96e5c6bf2346464e15a6400183930c6765d8894899","token_last_eight":"f1c8d660","note":"create_token/bean","note_url":null,"created_at":"2015-10-26T02:23:06Z","updated_at":"2015-10-26T02:23:06Z","scopes":[],"fingerprint":null},{"id":23673465,"url":"https://api.github.com/authorizations/23673465","app":{"name":"two_factor_token/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"cf1ef3274bbd1cb0f25cf3c0ae62bba97fb19d6d1278da37c87b60bbbbfd58e9","token_last_eight":"6f534ee7","note":"two_factor_token/bean","note_url":null,"created_at":"2015-10-26T02:23:06Z","updated_at":"2015-10-26T02:23:06Z","scopes":[],"fingerprint":null},{"id":23673471,"url":"https://api.github.com/authorizations/23673471","app":{"name":"write_first_test/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"e1ffd7c1465879b3c776c7be6fe7777f64f2dddb6d09da06f264e563e7c49fa7","token_last_eight":"49a5dcbd","note":"write_first_test/bean","note_url":null,"created_at":"2015-10-26T02:23:24Z","updated_at":"2015-10-26T02:23:24Z","scopes":[],"fingerprint":null}]'
|
66
|
+
http_version:
|
67
|
+
recorded_at: Mon, 26 Oct 2015 02:45:38 GMT
|
68
|
+
- request:
|
69
|
+
method: delete
|
70
|
+
uri: https://<USER>:<PASSWORD>@api.github.com/authorizations/23673434
|
71
|
+
body:
|
72
|
+
encoding: UTF-8
|
73
|
+
string: "{}"
|
74
|
+
headers:
|
75
|
+
Accept:
|
76
|
+
- application/vnd.github.v3+json
|
77
|
+
User-Agent:
|
78
|
+
- Octokit Ruby Gem 4.1.1
|
79
|
+
Content-Type:
|
80
|
+
- application/json
|
81
|
+
Accept-Encoding:
|
82
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
83
|
+
response:
|
84
|
+
status:
|
85
|
+
code: 204
|
86
|
+
message: No Content
|
87
|
+
headers:
|
88
|
+
Server:
|
89
|
+
- GitHub.com
|
90
|
+
Date:
|
91
|
+
- Mon, 26 Oct 2015 02:45:38 GMT
|
92
|
+
Status:
|
93
|
+
- 204 No Content
|
94
|
+
X-Ratelimit-Limit:
|
95
|
+
- '5000'
|
96
|
+
X-Ratelimit-Remaining:
|
97
|
+
- '4983'
|
98
|
+
X-Ratelimit-Reset:
|
99
|
+
- '1445829724'
|
100
|
+
X-Github-Media-Type:
|
101
|
+
- github.v3; format=json
|
102
|
+
X-Xss-Protection:
|
103
|
+
- 1; mode=block
|
104
|
+
X-Frame-Options:
|
105
|
+
- deny
|
106
|
+
Content-Security-Policy:
|
107
|
+
- default-src 'none'
|
108
|
+
Access-Control-Allow-Credentials:
|
109
|
+
- 'true'
|
110
|
+
Access-Control-Expose-Headers:
|
111
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
112
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
113
|
+
Access-Control-Allow-Origin:
|
114
|
+
- "*"
|
115
|
+
Strict-Transport-Security:
|
116
|
+
- max-age=31536000; includeSubdomains; preload
|
117
|
+
X-Content-Type-Options:
|
118
|
+
- nosniff
|
119
|
+
Vary:
|
120
|
+
- Accept-Encoding
|
121
|
+
body:
|
122
|
+
encoding: UTF-8
|
123
|
+
string: ''
|
124
|
+
http_version:
|
125
|
+
recorded_at: Mon, 26 Oct 2015 02:45:38 GMT
|
3
126
|
- request:
|
4
127
|
method: post
|
5
|
-
uri: https
|
128
|
+
uri: https://<USER>:<PASSWORD>@api.github.com/authorizations
|
6
129
|
body:
|
7
130
|
encoding: UTF-8
|
8
|
-
string: '{"note":"
|
131
|
+
string: '{"note":"requesting_scopes/bean","scopes":["gist","delete_repo"]}'
|
9
132
|
headers:
|
10
133
|
Accept:
|
11
134
|
- application/vnd.github.v3+json
|
12
135
|
User-Agent:
|
13
|
-
- Octokit Ruby Gem 4.
|
136
|
+
- Octokit Ruby Gem 4.1.1
|
14
137
|
Content-Type:
|
15
138
|
- application/json
|
16
139
|
Accept-Encoding:
|
17
140
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
141
|
response:
|
19
142
|
status:
|
20
|
-
code:
|
21
|
-
message:
|
143
|
+
code: 201
|
144
|
+
message: Created
|
22
145
|
headers:
|
23
146
|
Server:
|
24
147
|
- GitHub.com
|
25
148
|
Date:
|
26
|
-
-
|
149
|
+
- Mon, 26 Oct 2015 02:45:38 GMT
|
27
150
|
Content-Type:
|
28
151
|
- application/json; charset=utf-8
|
29
152
|
Content-Length:
|
30
|
-
- '
|
153
|
+
- '541'
|
31
154
|
Status:
|
32
|
-
-
|
33
|
-
X-Github-Media-Type:
|
34
|
-
- github.v3; format=json
|
155
|
+
- 201 Created
|
35
156
|
X-Ratelimit-Limit:
|
36
|
-
- '
|
157
|
+
- '5000'
|
37
158
|
X-Ratelimit-Remaining:
|
38
|
-
- '
|
159
|
+
- '4982'
|
39
160
|
X-Ratelimit-Reset:
|
40
|
-
- '
|
161
|
+
- '1445829724'
|
162
|
+
Cache-Control:
|
163
|
+
- private, max-age=60, s-maxage=60
|
164
|
+
Location:
|
165
|
+
- https://api.github.com/authorizations/23673992
|
166
|
+
Vary:
|
167
|
+
- Accept, Authorization, Cookie, X-GitHub-OTP
|
168
|
+
- Accept-Encoding
|
169
|
+
X-Github-Media-Type:
|
170
|
+
- github.v3; format=json
|
41
171
|
X-Xss-Protection:
|
42
172
|
- 1; mode=block
|
43
173
|
X-Frame-Options:
|
@@ -57,7 +187,7 @@ http_interactions:
|
|
57
187
|
- nosniff
|
58
188
|
body:
|
59
189
|
encoding: UTF-8
|
60
|
-
string: '{"
|
190
|
+
string: '{"id":23673992,"url":"https://api.github.com/authorizations/23673992","app":{"name":"requesting_scopes/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"token_with_scopes","hashed_token":"e41f77be9fe2994e5505437dce25574472b2d64f512305ccb25af6ec36cc9fc5","token_last_eight":"fc1217c4","note":"requesting_scopes/bean","note_url":null,"created_at":"2015-10-26T02:45:38Z","updated_at":"2015-10-26T02:45:38Z","scopes":["gist","delete_repo"],"fingerprint":null}'
|
61
191
|
http_version:
|
62
|
-
recorded_at:
|
192
|
+
recorded_at: Mon, 26 Oct 2015 02:45:38 GMT
|
63
193
|
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,193 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<USER>:<PASSWORD>@api.github.com/authorizations
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/vnd.github.v3+json
|
12
|
+
User-Agent:
|
13
|
+
- Octokit Ruby Gem 4.1.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- GitHub.com
|
25
|
+
Date:
|
26
|
+
- Mon, 26 Oct 2015 02:45:40 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Status:
|
32
|
+
- 200 OK
|
33
|
+
X-Ratelimit-Limit:
|
34
|
+
- '5000'
|
35
|
+
X-Ratelimit-Remaining:
|
36
|
+
- '4966'
|
37
|
+
X-Ratelimit-Reset:
|
38
|
+
- '1445829724'
|
39
|
+
Cache-Control:
|
40
|
+
- private, max-age=60, s-maxage=60
|
41
|
+
Vary:
|
42
|
+
- Accept, Authorization, Cookie, X-GitHub-OTP
|
43
|
+
- Accept-Encoding
|
44
|
+
X-Github-Media-Type:
|
45
|
+
- github.v3; format=json
|
46
|
+
X-Xss-Protection:
|
47
|
+
- 1; mode=block
|
48
|
+
X-Frame-Options:
|
49
|
+
- deny
|
50
|
+
Content-Security-Policy:
|
51
|
+
- default-src 'none'
|
52
|
+
Access-Control-Allow-Credentials:
|
53
|
+
- 'true'
|
54
|
+
Access-Control-Expose-Headers:
|
55
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
56
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
57
|
+
Access-Control-Allow-Origin:
|
58
|
+
- "*"
|
59
|
+
Strict-Transport-Security:
|
60
|
+
- max-age=31536000; includeSubdomains; preload
|
61
|
+
X-Content-Type-Options:
|
62
|
+
- nosniff
|
63
|
+
body:
|
64
|
+
encoding: ASCII-8BIT
|
65
|
+
string: '[{"id":23673471,"url":"https://api.github.com/authorizations/23673471","app":{"name":"write_first_test/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"e1ffd7c1465879b3c776c7be6fe7777f64f2dddb6d09da06f264e563e7c49fa7","token_last_eight":"49a5dcbd","note":"write_first_test/bean","note_url":null,"created_at":"2015-10-26T02:23:24Z","updated_at":"2015-10-26T02:23:24Z","scopes":[],"fingerprint":null},{"id":23673992,"url":"https://api.github.com/authorizations/23673992","app":{"name":"requesting_scopes/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"e41f77be9fe2994e5505437dce25574472b2d64f512305ccb25af6ec36cc9fc5","token_last_eight":"fc1217c4","note":"requesting_scopes/bean","note_url":null,"created_at":"2015-10-26T02:45:38Z","updated_at":"2015-10-26T02:45:38Z","scopes":["gist","delete_repo"],"fingerprint":null},{"id":23673993,"url":"https://api.github.com/authorizations/23673993","app":{"name":"autosave_test/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"db9bfd126cdb10eca25a06df972099ef8f1ff85014a982755efc2f0ef07bc975","token_last_eight":"da02795d","note":"autosave_test/bean","note_url":null,"created_at":"2015-10-26T02:45:38Z","updated_at":"2015-10-26T02:45:38Z","scopes":[],"fingerprint":null},{"id":23673996,"url":"https://api.github.com/authorizations/23673996","app":{"name":"existing_token/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"55a64a37a4d738582ec4d054ce00591588a04ee8ec55a4dda4d53aaf8057a98f","token_last_eight":"c1e9e2ec","note":"existing_token/bean","note_url":null,"created_at":"2015-10-26T02:45:39Z","updated_at":"2015-10-26T02:45:39Z","scopes":[],"fingerprint":null},{"id":23673997,"url":"https://api.github.com/authorizations/23673997","app":{"name":"create_token/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"9be225308ddbc5da3152e399ca3937f5bd19c784dc85f9975015eb5e775c7a00","token_last_eight":"dde1fdd1","note":"create_token/bean","note_url":null,"created_at":"2015-10-26T02:45:40Z","updated_at":"2015-10-26T02:45:40Z","scopes":[],"fingerprint":null},{"id":23673998,"url":"https://api.github.com/authorizations/23673998","app":{"name":"two_factor_token/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"","hashed_token":"343a80905d4861145447d5d965051ae2e4d181d01240e070bf26b8e79eb5e85b","token_last_eight":"982feb05","note":"two_factor_token/bean","note_url":null,"created_at":"2015-10-26T02:45:40Z","updated_at":"2015-10-26T02:45:40Z","scopes":[],"fingerprint":null}]'
|
66
|
+
http_version:
|
67
|
+
recorded_at: Mon, 26 Oct 2015 02:45:40 GMT
|
68
|
+
- request:
|
69
|
+
method: delete
|
70
|
+
uri: https://<USER>:<PASSWORD>@api.github.com/authorizations/23673471
|
71
|
+
body:
|
72
|
+
encoding: UTF-8
|
73
|
+
string: "{}"
|
74
|
+
headers:
|
75
|
+
Accept:
|
76
|
+
- application/vnd.github.v3+json
|
77
|
+
User-Agent:
|
78
|
+
- Octokit Ruby Gem 4.1.1
|
79
|
+
Content-Type:
|
80
|
+
- application/json
|
81
|
+
Accept-Encoding:
|
82
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
83
|
+
response:
|
84
|
+
status:
|
85
|
+
code: 204
|
86
|
+
message: No Content
|
87
|
+
headers:
|
88
|
+
Server:
|
89
|
+
- GitHub.com
|
90
|
+
Date:
|
91
|
+
- Mon, 26 Oct 2015 02:45:40 GMT
|
92
|
+
Status:
|
93
|
+
- 204 No Content
|
94
|
+
X-Ratelimit-Limit:
|
95
|
+
- '5000'
|
96
|
+
X-Ratelimit-Remaining:
|
97
|
+
- '4965'
|
98
|
+
X-Ratelimit-Reset:
|
99
|
+
- '1445829724'
|
100
|
+
X-Github-Media-Type:
|
101
|
+
- github.v3; format=json
|
102
|
+
X-Xss-Protection:
|
103
|
+
- 1; mode=block
|
104
|
+
X-Frame-Options:
|
105
|
+
- deny
|
106
|
+
Content-Security-Policy:
|
107
|
+
- default-src 'none'
|
108
|
+
Access-Control-Allow-Credentials:
|
109
|
+
- 'true'
|
110
|
+
Access-Control-Expose-Headers:
|
111
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
112
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
113
|
+
Access-Control-Allow-Origin:
|
114
|
+
- "*"
|
115
|
+
Strict-Transport-Security:
|
116
|
+
- max-age=31536000; includeSubdomains; preload
|
117
|
+
X-Content-Type-Options:
|
118
|
+
- nosniff
|
119
|
+
Vary:
|
120
|
+
- Accept-Encoding
|
121
|
+
body:
|
122
|
+
encoding: UTF-8
|
123
|
+
string: ''
|
124
|
+
http_version:
|
125
|
+
recorded_at: Mon, 26 Oct 2015 02:45:41 GMT
|
126
|
+
- request:
|
127
|
+
method: post
|
128
|
+
uri: https://<USER>:<PASSWORD>@api.github.com/authorizations
|
129
|
+
body:
|
130
|
+
encoding: UTF-8
|
131
|
+
string: '{"note":"write_first_test/bean","scopes":[]}'
|
132
|
+
headers:
|
133
|
+
Accept:
|
134
|
+
- application/vnd.github.v3+json
|
135
|
+
User-Agent:
|
136
|
+
- Octokit Ruby Gem 4.1.1
|
137
|
+
Content-Type:
|
138
|
+
- application/json
|
139
|
+
Accept-Encoding:
|
140
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
141
|
+
response:
|
142
|
+
status:
|
143
|
+
code: 201
|
144
|
+
message: Created
|
145
|
+
headers:
|
146
|
+
Server:
|
147
|
+
- GitHub.com
|
148
|
+
Date:
|
149
|
+
- Mon, 26 Oct 2015 02:45:41 GMT
|
150
|
+
Content-Type:
|
151
|
+
- application/json; charset=utf-8
|
152
|
+
Content-Length:
|
153
|
+
- '519'
|
154
|
+
Status:
|
155
|
+
- 201 Created
|
156
|
+
X-Ratelimit-Limit:
|
157
|
+
- '5000'
|
158
|
+
X-Ratelimit-Remaining:
|
159
|
+
- '4964'
|
160
|
+
X-Ratelimit-Reset:
|
161
|
+
- '1445829724'
|
162
|
+
Cache-Control:
|
163
|
+
- private, max-age=60, s-maxage=60
|
164
|
+
Location:
|
165
|
+
- https://api.github.com/authorizations/23674000
|
166
|
+
Vary:
|
167
|
+
- Accept, Authorization, Cookie, X-GitHub-OTP
|
168
|
+
- Accept-Encoding
|
169
|
+
X-Github-Media-Type:
|
170
|
+
- github.v3; format=json
|
171
|
+
X-Xss-Protection:
|
172
|
+
- 1; mode=block
|
173
|
+
X-Frame-Options:
|
174
|
+
- deny
|
175
|
+
Content-Security-Policy:
|
176
|
+
- default-src 'none'
|
177
|
+
Access-Control-Allow-Credentials:
|
178
|
+
- 'true'
|
179
|
+
Access-Control-Expose-Headers:
|
180
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
181
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
182
|
+
Access-Control-Allow-Origin:
|
183
|
+
- "*"
|
184
|
+
Strict-Transport-Security:
|
185
|
+
- max-age=31536000; includeSubdomains; preload
|
186
|
+
X-Content-Type-Options:
|
187
|
+
- nosniff
|
188
|
+
body:
|
189
|
+
encoding: UTF-8
|
190
|
+
string: '{"id":23674000,"url":"https://api.github.com/authorizations/23674000","app":{"name":"write_first_test/bean","url":"https://developer.github.com/v3/oauth_authorizations/","client_id":"00000000000000000000"},"token":"write_first_test_token","hashed_token":"e636e08ef6d6a5fed226e42d69a9a7885324337d313eea93727ab79c19b3d81b","token_last_eight":"1f6e7bdf","note":"write_first_test/bean","note_url":null,"created_at":"2015-10-26T02:45:41Z","updated_at":"2015-10-26T02:45:41Z","scopes":[],"fingerprint":null}'
|
191
|
+
http_version:
|
192
|
+
recorded_at: Mon, 26 Oct 2015 02:45:41 GMT
|
193
|
+
recorded_with: VCR 2.9.3
|
data/spec/octoauth/auth_spec.rb
CHANGED
@@ -1,22 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
|
+
##
|
5
|
+
# Grab creds for setting up VCR
|
6
|
+
LOGIN = ENV['OCTOAUTH_LOGIN'] || 'user'
|
7
|
+
PASSWORD = ENV['OCTOAUTH_PASSWORD'] || 'pw'
|
8
|
+
TWOFACTOR = ENV['OCTOAUTH_TFA'] || '123456'
|
9
|
+
|
4
10
|
##
|
5
11
|
# Shim object for mocking auth resources
|
6
12
|
AuthShim = Struct.new(:note, :token)
|
7
13
|
|
8
|
-
module UserInput
|
9
|
-
##
|
10
|
-
# Mask prints from UserInput
|
11
|
-
class Prompt
|
12
|
-
def print(*)
|
13
|
-
end
|
14
|
-
|
15
|
-
def puts(*)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
14
|
describe Octoauth do
|
21
15
|
describe Octoauth::Auth do
|
22
16
|
describe '#initialize' do
|
@@ -24,82 +18,87 @@ describe Octoauth do
|
|
24
18
|
it 'loads the existing token' do
|
25
19
|
VCR.use_cassette('load_existing_token') do
|
26
20
|
auth = Octoauth::Auth.new(
|
27
|
-
note: '
|
28
|
-
file: 'spec/examples/
|
21
|
+
note: 'existing_token',
|
22
|
+
file: 'spec/examples/existing_token.yml'
|
29
23
|
)
|
30
|
-
expect(auth.token).to eql '
|
24
|
+
expect(auth.token).to eql 'an_existing_token'
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
34
28
|
context 'if there is a note conflict' do
|
35
|
-
it '
|
36
|
-
VCR.use_cassette('
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
29
|
+
it 'recreates the token' do
|
30
|
+
VCR.use_cassette('recreate_token') do
|
31
|
+
tokens = (1..2).map do
|
32
|
+
Octoauth::Auth.new(
|
33
|
+
note: 'existing_token',
|
34
|
+
login: LOGIN,
|
35
|
+
password: PASSWORD
|
36
|
+
).token
|
37
|
+
end
|
38
|
+
expect(tokens.first).not_to eql tokens.last
|
43
39
|
end
|
44
40
|
end
|
45
41
|
end
|
46
42
|
context 'if the file does not exist' do
|
47
|
-
it '
|
48
|
-
VCR.use_cassette('
|
43
|
+
it 'use user input to create token' do
|
44
|
+
VCR.use_cassette('create_token') do
|
49
45
|
auth = Octoauth::Auth.new(
|
50
|
-
note: '
|
51
|
-
login:
|
52
|
-
password:
|
46
|
+
note: 'create_token',
|
47
|
+
login: LOGIN,
|
48
|
+
password: PASSWORD
|
53
49
|
)
|
54
|
-
expect(auth.token).to eql '
|
50
|
+
expect(auth.token).to eql 'created_token'
|
55
51
|
end
|
56
52
|
end
|
57
53
|
it 'handles users with 2 factor auth enabled' do
|
58
54
|
VCR.use_cassette('handle_two_factor') do
|
59
|
-
|
60
|
-
|
61
|
-
|
55
|
+
auth = Octoauth::Auth.new(
|
56
|
+
note: 'two_factor_token',
|
57
|
+
login: LOGIN,
|
58
|
+
password: PASSWORD,
|
59
|
+
twofactor: TWOFACTOR
|
60
|
+
)
|
61
|
+
expect(auth.token).to eql '2fa_required_token'
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
65
65
|
it 'supports alternate endpoints' do
|
66
66
|
VCR.use_cassette('alternate_endpoints') do
|
67
67
|
auth = Octoauth::Auth.new(
|
68
|
-
note: '
|
69
|
-
login:
|
70
|
-
password:
|
71
|
-
api_endpoint: 'https://
|
68
|
+
note: 'alternate_endpoint',
|
69
|
+
login: LOGIN,
|
70
|
+
password: PASSWORD,
|
71
|
+
api_endpoint: 'https://example.org/api/v3/'
|
72
72
|
)
|
73
|
-
expect(auth.token).to eql '
|
73
|
+
expect(auth.token).to eql 'created_token'
|
74
74
|
end
|
75
75
|
end
|
76
76
|
it 'supports requesting scopes' do
|
77
77
|
VCR.use_cassette('requesting_scopes') do
|
78
78
|
auth = Octoauth::Auth.new(
|
79
|
-
note: '
|
80
|
-
login:
|
81
|
-
password:
|
79
|
+
note: 'requesting_scopes',
|
80
|
+
login: LOGIN,
|
81
|
+
password: PASSWORD,
|
82
82
|
scopes: %w(gist delete_repo)
|
83
83
|
)
|
84
|
-
expect(auth.token).to eql '
|
84
|
+
expect(auth.token).to eql 'token_with_scopes'
|
85
85
|
end
|
86
86
|
end
|
87
87
|
it 'supports autosaving the config file' do
|
88
88
|
VCR.use_cassette('autosaving_config_file') do
|
89
|
-
random = rand(36**30).to_s(30)
|
90
89
|
FileUtils.rm_f 'spec/examples/autosave.yml'
|
91
90
|
Octoauth::Auth.new(
|
92
91
|
note: 'autosave_test',
|
93
92
|
file: 'spec/examples/autosave.yml',
|
94
|
-
login:
|
95
|
-
password:
|
93
|
+
login: LOGIN,
|
94
|
+
password: PASSWORD,
|
96
95
|
autosave: true
|
97
96
|
)
|
98
97
|
new_auth = Octoauth::Auth.new(
|
99
98
|
note: 'autosave_test',
|
100
99
|
file: 'spec/examples/autosave.yml'
|
101
100
|
)
|
102
|
-
expect(new_auth.token).to eql
|
101
|
+
expect(new_auth.token).to eql 'autosaved_token'
|
103
102
|
end
|
104
103
|
end
|
105
104
|
end
|
@@ -107,73 +106,49 @@ describe Octoauth do
|
|
107
106
|
context 'when the first file exists' do
|
108
107
|
it 'reads the first file' do
|
109
108
|
auth = Octoauth::Auth.new(
|
110
|
-
note: '
|
111
|
-
files: ['spec/examples/
|
109
|
+
note: 'existing_token',
|
110
|
+
files: ['spec/examples/existing_token.yml', 'bogus.yml']
|
112
111
|
)
|
113
|
-
expect(auth.token).to eql '
|
112
|
+
expect(auth.token).to eql 'an_existing_token'
|
114
113
|
end
|
115
114
|
end
|
116
115
|
context 'when the first file does not exist' do
|
117
116
|
context 'when the second file exists' do
|
118
117
|
it 'reads the second file' do
|
119
|
-
FileUtils.rm_f 'spec/examples/nil.yml'
|
120
118
|
auth = Octoauth::Auth.new(
|
121
|
-
note: '
|
122
|
-
files: ['
|
119
|
+
note: 'existing_token',
|
120
|
+
files: ['bogus.yml', 'spec/examples/existing_token.yml']
|
123
121
|
)
|
124
|
-
expect(auth.token).to eql '
|
122
|
+
expect(auth.token).to eql 'an_existing_token'
|
125
123
|
end
|
126
124
|
end
|
127
125
|
context 'when the second file does not exist' do
|
128
|
-
it 'reads nil' do
|
129
|
-
FileUtils.rm_f ['spec/examples/nil.yml', 'spec/examples/nil2.yml']
|
126
|
+
it 'reads nil from the first file' do
|
130
127
|
auth = Octoauth::Auth.new(
|
131
|
-
note: '
|
132
|
-
files: ['
|
128
|
+
note: 'nonexistent_token',
|
129
|
+
files: ['nil.yml', 'nil2.yml']
|
133
130
|
)
|
134
131
|
expect(auth.send(:config).token).to be_nil
|
135
132
|
end
|
136
133
|
it 'writes to the first file' do
|
137
|
-
VCR.use_cassette('
|
138
|
-
|
139
|
-
FileUtils.rm_f ['spec/examples/nil.yml', 'spec/examples/nil2.yml']
|
134
|
+
VCR.use_cassette('write_to_first_file') do
|
135
|
+
FileUtils.rm_f 'spec/examples/write_first_test.yml'
|
140
136
|
auth = Octoauth::Auth.new(
|
141
|
-
note: '
|
142
|
-
files: ['spec/examples/
|
143
|
-
login:
|
144
|
-
password:
|
137
|
+
note: 'write_first_test',
|
138
|
+
files: ['spec/examples/write_first_test.yml', 'bogus.yml'],
|
139
|
+
login: LOGIN,
|
140
|
+
password: PASSWORD
|
145
141
|
)
|
146
142
|
auth.save
|
147
143
|
new_auth = Octoauth::Auth.new(
|
148
|
-
note: '
|
149
|
-
file: 'spec/examples/
|
144
|
+
note: 'write_first_test',
|
145
|
+
file: 'spec/examples/write_first_test.yml'
|
150
146
|
)
|
151
|
-
expect(new_auth.token).to eql
|
147
|
+
expect(new_auth.token).to eql 'write_first_test_token'
|
152
148
|
end
|
153
149
|
end
|
154
150
|
end
|
155
151
|
end
|
156
152
|
end
|
157
|
-
|
158
|
-
describe '#save' do
|
159
|
-
it 'saves the config to disk' do
|
160
|
-
VCR.use_cassette('save_to_disk') do
|
161
|
-
random = rand(36**30).to_s(30)
|
162
|
-
FileUtils.rm_f 'spec/examples/tmp.yml'
|
163
|
-
auth = Octoauth::Auth.new(
|
164
|
-
note: 'write_test',
|
165
|
-
file: 'spec/examples/tmp.yml',
|
166
|
-
login: 'user',
|
167
|
-
password: 'pw'
|
168
|
-
)
|
169
|
-
auth.save
|
170
|
-
new_auth = Octoauth::Auth.new(
|
171
|
-
note: 'write_test',
|
172
|
-
file: 'spec/examples/tmp.yml'
|
173
|
-
)
|
174
|
-
expect(new_auth.token).to eql random
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
153
|
end
|
179
154
|
end
|