-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from unb-mds/test/google-oauth2
test(users): testes de caso para rota de registro de usuários com oauth2
- Loading branch information
Showing
9 changed files
with
254 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
all: copy-env setup-env config-mock entrypoint-chmod | ||
copy-env: | ||
cp ./api/.env.example ./api/.env | ||
|
||
setup-env: | ||
bash scripts/env.sh | ||
|
||
config-mock: | ||
bash scripts/config.sh | ||
|
||
entrypoint-chmod: | ||
chmod +x ./api/entrypoint.sh |
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 |
---|---|---|
|
@@ -21,3 +21,6 @@ POSTGRES_PASSWORD="suagradeunb" | |
ADMIN_NAME="admin" | ||
ADMIN_PASS="admin" | ||
ADMIN_EMAIL="[email protected]" | ||
|
||
# Google OAuth2 Mock | ||
GOOGLE_OAUTH2_MOCK_TOKEN="your_google_oauth2_mock_token" |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import requests | ||
from users.models import User | ||
from decouple import config | ||
|
||
|
||
class GoogleOAuth2: | ||
|
@@ -12,8 +13,16 @@ def get_user_data(cls, access_token: str) -> dict | None: | |
|
||
user_info_url = cls.GOOGLE_OAUTH2_PROVIDER + '/userinfo' | ||
params = {'access_token': access_token} | ||
|
||
try: | ||
if access_token == config('GOOGLE_OAUTH2_MOCK_TOKEN'): | ||
mock_user_data = { | ||
'given_name': 'given_name', | ||
'family_name': 'family_name', | ||
'email': '[email protected]' | ||
} | ||
return mock_user_data | ||
|
||
response = requests.get(user_info_url, params=params) | ||
if response.status_code == 200: | ||
user_data = response.json() | ||
|
Oops, something went wrong.