OAuth 2 ROPC Grant test (#5237)
This commit is contained in:
parent
ed8a8dabd3
commit
9e2f161f3e
1 changed files with 21 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ class TestOAuth20(unittest.TestCase):
|
|||
frappe_login_key = frappe.new_doc("Social Login Key")
|
||||
frappe_login_key.get_social_login_provider("Frappe", initialize=True)
|
||||
frappe_login_key.base_url = "http://localhost:8000"
|
||||
frappe_login_key.enable_social_login = 0
|
||||
frappe_login_key.save()
|
||||
|
||||
def test_invalid_login(self):
|
||||
|
|
@ -88,6 +89,26 @@ class TestOAuth20(unittest.TestCase):
|
|||
# Check revoked token
|
||||
self.assertFalse(check_valid_openid_response(bearer_token.get("access_token")))
|
||||
|
||||
def test_resource_owner_password_credentials_grant(self):
|
||||
# Set payload
|
||||
payload = "grant_type=password"
|
||||
payload += "&username=test@example.com"
|
||||
payload += "&password=Eastern_43A1W"
|
||||
payload += "&client_id=" + self.client_id
|
||||
payload += "&scope=openid%20all"
|
||||
|
||||
headers = {'content-type':'application/x-www-form-urlencoded'}
|
||||
|
||||
# Request for bearer token
|
||||
token_response = requests.post( frappe.get_site_config().host_name +
|
||||
"/api/method/frappe.integrations.oauth2.get_token", data=payload, headers=headers)
|
||||
|
||||
# Parse bearer token json
|
||||
bearer_token = token_response.json()
|
||||
|
||||
# Check token for valid response
|
||||
self.assertTrue(check_valid_openid_response(bearer_token.get("access_token")))
|
||||
|
||||
def test_login_using_implicit_token(self):
|
||||
|
||||
oauth_client = frappe.get_doc("OAuth Client", self.client_id)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue