-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
Users.authenticate_with_password()
(#197)
* Add `Users.authenticate_with_password()` * Fix method * Update comment * Update test
- Loading branch information
1 parent
b6c626f
commit 94eb707
Showing
2 changed files
with
83 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,10 +214,42 @@ def test_authenticate_with_magic_auth( | |
assert request["json"]["code"] == code | ||
assert request["json"]["user_agent"] == user_agent | ||
assert request["json"]["expires_in"] == expires_in | ||
assert request["json"]["magic_auth_challenge_id"] == magic_auth_challenge_id | ||
assert request["json"]["ip_address"] == ip_address | ||
assert request["json"]["client_id"] == "client_b27needthisforssotemxo" | ||
assert request["json"]["client_secret"] == "sk_abdsomecharactersm284" | ||
assert ( | ||
request["json"]["grant_type"] | ||
== "urn:workos:oauth:grant-type:magic-auth:code" | ||
) | ||
|
||
def test_authenticate_with_password( | ||
self, capture_and_mock_request, mock_auth_response | ||
): | ||
email = "[email protected]" | ||
password = "test123" | ||
expires_in = 3600 | ||
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" | ||
ip_address = "192.0.0.1" | ||
|
||
url, request = capture_and_mock_request("post", mock_auth_response, 200) | ||
|
||
response = self.users.authenticate_with_password( | ||
email=email, | ||
password=password, | ||
expires_in=expires_in, | ||
user_agent=user_agent, | ||
ip_address=ip_address, | ||
) | ||
|
||
assert url[0].endswith("users/session/token") | ||
assert response["user"]["id"] == "user_01H7ZGXFP5C6BBQY6Z7277ZCT0" | ||
assert response["session"]["id"] == "session_01E4ZCR3C56J083X43JQXF3JK5" | ||
assert request["json"]["email"] == email | ||
assert request["json"]["password"] == password | ||
assert request["json"]["user_agent"] == user_agent | ||
assert request["json"]["expires_in"] == expires_in | ||
assert request["json"]["ip_address"] == ip_address | ||
assert request["json"]["client_id"] == "client_b27needthisforssotemxo" | ||
assert request["json"]["client_secret"] == "sk_abdsomecharactersm284" | ||
assert request["json"]["grant_type"] == "password" |
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