|
@@ -1,7 +1,14 @@
|
|
|
import flask
|
|
|
import pytest
|
|
|
|
|
|
-from app.oauth_models import get_scopes, Scope, get_response_types, ResponseType
|
|
|
+from app.oauth_models import (
|
|
|
+ get_scopes,
|
|
|
+ Scope,
|
|
|
+ get_response_types,
|
|
|
+ ResponseType,
|
|
|
+ response_types_to_str,
|
|
|
+ get_response_types_from_str,
|
|
|
+)
|
|
|
|
|
|
|
|
|
def test_get_scopes(flask_app):
|
|
@@ -52,3 +59,21 @@ def test_get_response_types(flask_app):
|
|
|
with flask_app.test_request_context("/?response_type=abcd"):
|
|
|
with pytest.raises(ValueError):
|
|
|
get_response_types(flask.request)
|
|
|
+
|
|
|
+
|
|
|
+def test_response_types_to_str():
|
|
|
+ assert response_types_to_str([]) == ""
|
|
|
+ assert response_types_to_str([ResponseType.CODE]) == "code"
|
|
|
+ assert (
|
|
|
+ response_types_to_str([ResponseType.CODE, ResponseType.ID_TOKEN])
|
|
|
+ == "code,id_token"
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+def test_get_response_types_from_str():
|
|
|
+ assert get_response_types_from_str("") == set()
|
|
|
+ assert get_response_types_from_str("token") == {ResponseType.TOKEN}
|
|
|
+ assert get_response_types_from_str("token id_token") == {
|
|
|
+ ResponseType.TOKEN,
|
|
|
+ ResponseType.ID_TOKEN,
|
|
|
+ }
|