-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add endpoint to start device auth (#159)
* ♻️ Close redis when request is done We also close the pool if we are running the tests, this prevents a warning. * Initial endpoint for device authorization
- Loading branch information
Showing
4 changed files
with
135 additions
and
2 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,24 @@ | ||
from fastapi.testclient import TestClient | ||
|
||
from app.core.config import settings | ||
|
||
|
||
def test_get_device_code(client: TestClient) -> None: | ||
data = {"client_id": "valid_id"} | ||
|
||
r = client.post(f"{settings.API_V1_STR}/login/device/authorization", data=data) | ||
|
||
assert r.status_code == 200 | ||
|
||
response_data = r.json() | ||
|
||
assert "device_code" in response_data | ||
assert "user_code" in response_data | ||
assert "expires_in" in response_data | ||
assert "interval" in response_data | ||
|
||
assert response_data["verification_uri"] == f"{settings.server_host}/device" | ||
assert ( | ||
response_data["verification_uri_complete"] | ||
== f"{settings.server_host}/device?code={response_data['user_code']}" | ||
) |
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