mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-29 11:47:15 +00:00
🧪(backend) add failing test for client_id enumeration issue
Currently the inactive status is revealed before verifying the secret, creating an authentication state oracle. Introduce a failing test to capture the issue before applying the fix.
This commit is contained in:
@@ -122,6 +122,28 @@ def test_api_applications_generate_token_inactive_application():
|
|||||||
assert "Application is inactive" in str(response.data)
|
assert "Application is inactive" in str(response.data)
|
||||||
|
|
||||||
|
|
||||||
|
def test_api_applications_generate_token_inactive_application_wrong_secret():
|
||||||
|
"""An inactive application with a wrong secret should return 401."""
|
||||||
|
user = UserFactory(email="user@example.com")
|
||||||
|
application = ApplicationFactory(is_active=False)
|
||||||
|
|
||||||
|
client = APIClient()
|
||||||
|
response = client.post(
|
||||||
|
"/external-api/v1.0/application/token/",
|
||||||
|
{
|
||||||
|
"client_id": application.client_id,
|
||||||
|
"client_secret": "wrong-secret",
|
||||||
|
"grant_type": "client_credentials",
|
||||||
|
"scope": user.email,
|
||||||
|
},
|
||||||
|
format="json",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 401
|
||||||
|
assert "Invalid credentials" in str(response.data)
|
||||||
|
assert "inactive" not in str(response.data).lower()
|
||||||
|
|
||||||
|
|
||||||
def test_api_applications_generate_token_invalid_email_format():
|
def test_api_applications_generate_token_invalid_email_format():
|
||||||
"""Invalid email format should return 400."""
|
"""Invalid email format should return 400."""
|
||||||
application = ApplicationFactory(is_active=True)
|
application = ApplicationFactory(is_active=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user