Skip to content
Snippets Groups Projects
Verified Commit 45ec395c authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

auth.pytest_plugin: Adjust error type according to reality

Prior to this commit, this raised a basic error message instead of a json dict bytes
encoded.

This commit fixes it.

Related to T2858
parent e1bc4f10
No related branches found
Tags v0.3.6
1 merge request!6auth.pytest_plugin: Adjust error type according to reality
......@@ -5,6 +5,7 @@
from copy import copy
from datetime import datetime, timezone
import json
from typing import Dict, List, Optional
from unittest.mock import Mock
......@@ -140,9 +141,12 @@ class KeycloackOpenIDConnectMock(KeycloakOpenIDConnect):
self.userinfo.return_value = copy(user_info)
else:
self.authorization_url = Mock() # type: ignore
exception = KeycloakError(
error_message="Authentication failed", response_code=401
)
error = {
"error": "invalid_grant",
"error_description": "Invalid user credentials",
}
error_message = json.dumps(error).encode()
exception = KeycloakError(error_message=error_message, response_code=401)
self.authorization_code.side_effect = exception
self.authorization_url.side_effect = exception
self.refresh_token.side_effect = exception
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment