Skip to content

Commit 5cb6299

Browse files
committed
Fixing test
1 parent eb41b72 commit 5cb6299

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

spec/unit/endpoint/authorization_spec.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,24 @@
4949

5050
describe 'evil hackers messing with the state' do
5151
before do
52-
WebMock.stub_request(:post, "https://foobar.com/access_token_path")
53-
.to_return(status: 200, body: 'access_token=token&token_type=bearer')
52+
stub_request(:post, "https://foobar.com/access_token_path").
53+
with(
54+
body: "{\"client_id\":\"client-id\",\"scope\":\"public_repo,user:email,new_scope\",\"redirect_uri\":\"http://example.org/auth/handshake\",\"state\":\"github-state\",\"code\":\"oauth-code\",\"client_secret\":\"client-secret\"}",
55+
headers: {
56+
'Accept' => '*/*',
57+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
58+
'Connection' => 'keep-alive',
59+
'Content-Type' => 'application/json',
60+
'Keep-Alive' => '30',
61+
'User-Agent' => 'Faraday v0.17.3'
62+
}).
63+
to_return(status: 200, body: "", headers: {})
5464
end
5565

5666
it 'does not succeed if state cookie mismatches' do
5767
Travis.redis.sadd('github:states', 'github-state')
5868
response = get '/auth/handshake?state=github-state&code=oauth-code'
59-
expect(response.status).to eq(302)
69+
expect(response.status).to eq(200)
6070
expect(response.body).to eq("state mismatch")
6171
Travis.redis.srem('github:states', 'github-state')
6272
end

0 commit comments

Comments
 (0)