Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
406 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use Mix.Config | ||
|
||
config :ueberauth, Ueberauth, | ||
json_library: Jason, | ||
providers: [ | ||
auth0: {Ueberauth.Strategy.Auth0, []} | ||
] | ||
|
||
config :ueberauth, Ueberauth.Strategy.Auth0.OAuth, | ||
domain: "example-app.auth0.com", | ||
client_id: "clientidsomethingrandom", | ||
client_secret: "clientsecret-somethingsecret" | ||
|
||
config :exvcr, | ||
vcr_cassette_library_dir: "test/fixtures/vcr_cassettes" | ||
|
||
config :plug, :validate_header_keys_during_test, true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"email": "testuser@example.com", | ||
"email_verified": false, | ||
"name": "testuser@example.com", | ||
"nickname": "testuser", | ||
"picture": "https://s.gravatar.com/avatar/7ec7606c46a14a7ef514d1f1f9038823?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Ftu.png", | ||
"sub": "auth0|lyy5vutbn9qfmihil7pvpo66", | ||
"updated_at": "2020-02-19T12:34:56.784Z" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><body>You are being <a href="https://example-app.auth0.com/authorize?client_id=clientidsomethingrandom&redirect_uri=http%3A%2F%2Fwww.example.com%2Fauth%2Fauth0%2Fcallback&response_type=code&scope=openid+profile+email">redirected</a>.</body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[ | ||
{ | ||
"request": { | ||
"body": "client_id=clientidKFpqmR7aO1iVUOQR1LMKbZvk&client_secret=clientsecrethzqAhvWpJhAehfkzupWelgut-hRh7ZYOBOmaXsCRryhy7bqWzOCx&code=invalid_code&grant_type=authorization_code&redirect_uri=http%3A%2F%2Fwww.example.com%2Fauth%2Fauth0%2Fcallback", | ||
"headers": { | ||
"content-type": "application/x-www-form-urlencoded", | ||
"accept": "application/json", | ||
"authorization": "Basic Y2xpZW50aWRLRnBxbVI3YU8xaVZVT1FSMUxNS2Jadms6Y2xpZW50c2VjcmV0aHpxQWh2V3BKaEFlaGZrenVwV2VsZ3V0LWhSaDdaWU9CT21hWHNDUnJ5aHk3YnFXek9DeA==" | ||
}, | ||
"method": "post", | ||
"options": [], | ||
"request_body": "", | ||
"url": "https://example-app.auth0.com/oauth/token" | ||
}, | ||
"response": { | ||
"binary": false, | ||
"body": "{\"error\":\"invalid_grant\",\"error_description\":\"Invalid authorization code\"}", | ||
"headers": { | ||
"Date": "Thu, 18 Jun 2020 07:03:26 GMT", | ||
"Content-Type": "application/json", | ||
"Content-Length": "74", | ||
"Connection": "keep-alive", | ||
"Server": "nginx", | ||
"Vary": "Accept-Encoding", | ||
"ot-tracer-spanid": "5f4018ed528710ca", | ||
"ot-tracer-traceid": "1e9ed8bd1011f221", | ||
"ot-tracer-sampled": "true", | ||
"ot-baggage-auth0-request-id": "b105f9bcbad6f804b763ee88", | ||
"X-Auth0-RequestId": "aedc633e5adea3be8f49", | ||
"Set-Cookie": "did=s%3Av0%3Ace5ff350-b131-11ea-be83-892b118656b2.%2B9lyU8P6x2BabrexQ7tK2sK19C2RkOlnda890p8d9Z0; Max-Age=31557600; Path=/; Expires=Fri, 18 Jun 2021 13:03:26 GMT; HttpOnly; Secure; SameSite=None", | ||
"X-RateLimit-Limit": "30", | ||
"X-RateLimit-Remaining": "29", | ||
"X-RateLimit-Reset": "1592463807", | ||
"cache-control": "private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-transform" | ||
}, | ||
"status_code": 403, | ||
"type": "ok" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[ | ||
{ | ||
"request": { | ||
"body": "client_id=clientidKFpqmR7aO1iVUOQR1LMKbZvk&client_secret=clientsecrethzqAhvWpJhAehfkzupWelgut-hRh7ZYOBOmaXsCRryhy7bqWzOCx&code=code_abc&grant_type=authorization_code&redirect_uri=http%3A%2F%2Fwww.example.com%2Fauth%2Fauth0%2Fcallback", | ||
"headers": { | ||
"content-type": "application/x-www-form-urlencoded", | ||
"accept": "application/json", | ||
"authorization": "Basic Y2xpZW50aWRLRnBxbVI3YU8xaVZVT1FSMUxNS2Jadms6Y2xpZW50c2VjcmV0aHpxQWh2V3BKaEFlaGZrenVwV2VsZ3V0LWhSaDdaWU9CT21hWHNDUnJ5aHk3YnFXek9DeA==" | ||
}, | ||
"method": "post", | ||
"options": [], | ||
"request_body": "", | ||
"url": "https://example-app.auth0.com/oauth/token" | ||
}, | ||
"response": { | ||
"binary": false, | ||
"body": "{\"error\":\"something_wrong\",\"error_description\":\"Something went wrong\"}", | ||
"headers": { | ||
"Date": "Wed, 17 Jun 2020 23:39:36 GMT", | ||
"Content-Type": "application/json", | ||
"Content-Length": "69", | ||
"Connection": "keep-alive", | ||
"Server": "nginx", | ||
"ot-tracer-spanid": "3085123a49690f22", | ||
"ot-tracer-traceid": "2611213f15e78af3", | ||
"ot-tracer-sampled": "true", | ||
"ot-baggage-auth0-request-id": "d8916634ed436afe36744f6e", | ||
"X-Auth0-RequestId": "1dd455670d641d81c4c8", | ||
"Set-Cookie": "did=s%3Av0%3Acd966af0-b0e3-11ea-85ed-0d9365a06bc5.25colYvrl8qxIpnLc4gibEDFW5BvUQ6ryaj0zR1P7zc; Max-Age=31557600; Path=/; Expires=Fri, 18 Jun 2021 05:39:36 GMT; HttpOnly; Secure; SameSite=None", | ||
"X-RateLimit-Limit": "30", | ||
"X-RateLimit-Remaining": "29", | ||
"X-RateLimit-Reset": "1592437177", | ||
"cache-control": "private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-transform" | ||
}, | ||
"status_code": 200, | ||
"type": "ok" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[ | ||
{ | ||
"request": { | ||
"body": "client_id=clientidKFpqmR7aO1iVUOQR1LMKbZvk&client_secret=clientsecrethzqAhvWpJhAehfkzupWelgut-hRh7ZYOBOmaXsCRryhy7bqWzOCx&code=code_abc&grant_type=authorization_code&redirect_uri=http%3A%2F%2Fwww.example.com%2Fauth%2Fauth0%2Fcallback", | ||
"headers": { | ||
"content-type": "application/x-www-form-urlencoded", | ||
"accept": "application/json", | ||
"authorization": "Basic Y2xpZW50aWRLRnBxbVI3YU8xaVZVT1FSMUxNS2Jadms6Y2xpZW50c2VjcmV0aHpxQWh2V3BKaEFlaGZrenVwV2VsZ3V0LWhSaDdaWU9CT21hWHNDUnJ5aHk3YnFXek9DeA==" | ||
}, | ||
"method": "post", | ||
"options": [], | ||
"request_body": "", | ||
"url": "https://example-app.auth0.com/oauth/token" | ||
}, | ||
"response": { | ||
"binary": false, | ||
"body": "{\"access_token\":\"eyJz93alolk4laUWw\",\"refresh_token\":\"GEbRxBNkitedjnXbL\",\"id_token\":\"eyJ0XAipop4faeEoQ\",\"token_type\":\"Bearer\",\"expires_in\":86400}", | ||
"headers": { | ||
"Date": "Wed, 17 Jun 2020 23:39:36 GMT", | ||
"Content-Type": "application/json", | ||
"Content-Length": "144", | ||
"Connection": "keep-alive", | ||
"X-Auth0-RequestId": "1dd41235665d641d81c4c8", | ||
}, | ||
"status_code": 200, | ||
"type": "ok" | ||
} | ||
}, | ||
{ | ||
"request": { | ||
"body": "", | ||
"headers": { | ||
"accept": "application/json", | ||
"authorization": "Bearer eyJz93alolk4laUWw" | ||
}, | ||
"method": "get", | ||
"options": [], | ||
"request_body": "", | ||
"url": "https://example-app.auth0.com/userinfo" | ||
}, | ||
"response": { | ||
"binary": false, | ||
"body": "{\"email\":\"testuser@example.com\",\"email_verified\":false,\"name\":\"testuser@example.com\",\"nickname\":\"testuser\",\"picture\":\"https://s.gravatar.com/avatar/7ec7606c46a14a7ef514d1f1f9038823?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Ftu.png\",\"sub\":\"auth0|lyy5vutbn9qfmihil7pvpo66\",\"updated_at\":\"2020-02-19T12:34:56.784Z\"}", | ||
"headers": { | ||
"Date": "Wed, 17 Jun 2020 23:39:36 GMT", | ||
"Content-Type": "application/json", | ||
"Content-Length": "144", | ||
"Connection": "keep-alive", | ||
"Server": "nginx", | ||
"X-Auth0-RequestId": "1dd968479496d641d81c4c8", | ||
"cache-control": "private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-transform" | ||
}, | ||
"status_code": 200, | ||
"type": "ok" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
defmodule Ueberauth.Strategy.Auth0.OAuthTest do | ||
use ExUnit.Case | ||
|
||
import Ueberauth.Strategy.Auth0.OAuth, only: [client: 0] | ||
|
||
@test_domain "example-app.auth0.com" | ||
|
||
setup do | ||
{:ok, %{client: client()}} | ||
end | ||
|
||
test "creates correct client", %{client: client} do | ||
assert client.client_id == "clientidsomethingrandom" | ||
assert client.client_secret == "clientsecret-somethingsecret" | ||
assert client.redirect_uri == "" | ||
assert client.strategy == Ueberauth.Strategy.Auth0.OAuth | ||
assert client.authorize_url == "https://#{@test_domain}/authorize" | ||
assert client.token_url == "https://#{@test_domain}/oauth/token" | ||
assert client.site == "https://#{@test_domain}" | ||
end | ||
end |
Oops, something went wrong.