@@ -26,6 +26,24 @@ def test_valid_server_config(self):
26
26
assert not hasattr (result , "errors" ) or len (result .errors ) == 0
27
27
assert result .warnings == []
28
28
29
+ def test_valid_server_config_no_grant_types (self ):
30
+ config = AuthServerConfig (
31
+ type = AuthServerType .OAUTH ,
32
+ metadata = AuthorizationServerMetadata (
33
+ issuer = "https://example.com" ,
34
+ authorization_endpoint = "https://example.com/oauth/authorize" ,
35
+ token_endpoint = "https://example.com/oauth/token" ,
36
+ response_types_supported = ["code" ],
37
+ code_challenge_methods_supported = ["S256" ],
38
+ registration_endpoint = "https://example.com/register" ,
39
+ ),
40
+ )
41
+
42
+ result = validate_server_config (config )
43
+ assert result .is_valid is True
44
+ assert not hasattr (result , "errors" ) or len (result .errors ) == 0
45
+ assert result .warnings == []
46
+
29
47
def test_invalid_server_config (self ):
30
48
config = AuthServerConfig (
31
49
type = AuthServerType .OAUTH ,
@@ -42,10 +60,6 @@ def test_invalid_server_config(self):
42
60
43
61
error_codes = [error .code for error in result .errors ]
44
62
assert AuthServerConfigErrorCode .CODE_RESPONSE_TYPE_NOT_SUPPORTED in error_codes
45
- assert (
46
- AuthServerConfigErrorCode .AUTHORIZATION_CODE_GRANT_NOT_SUPPORTED
47
- in error_codes
48
- )
49
63
assert AuthServerConfigErrorCode .PKCE_NOT_SUPPORTED in error_codes
50
64
51
65
warning_codes = [warning .code for warning in result .warnings ]
@@ -78,7 +92,7 @@ def test_warning_for_missing_dynamic_registration(self):
78
92
)
79
93
assert len (result .warnings ) == 1
80
94
81
- def test_code_challenge_methods (self ):
95
+ def test_invalid_code_challenge_methods (self ):
82
96
config = AuthServerConfig (
83
97
type = AuthServerType .OAUTH ,
84
98
metadata = AuthorizationServerMetadata (
@@ -99,3 +113,25 @@ def test_code_challenge_methods(self):
99
113
AuthServerConfigErrorCode .S256_CODE_CHALLENGE_METHOD_NOT_SUPPORTED
100
114
in error_codes
101
115
)
116
+
117
+ def test_invalid_grant_type (self ):
118
+ config = AuthServerConfig (
119
+ type = AuthServerType .OAUTH ,
120
+ metadata = AuthorizationServerMetadata (
121
+ issuer = "https://example.com" ,
122
+ authorization_endpoint = "https://example.com/oauth/authorize" ,
123
+ token_endpoint = "https://example.com/oauth/token" ,
124
+ response_types_supported = ["code" ],
125
+ grant_types_supported = [], # Use empty list on purpose to ensure it should be treated correctly
126
+ code_challenge_methods_supported = ["S256" ],
127
+ ),
128
+ )
129
+
130
+ result = validate_server_config (config )
131
+ assert result .is_valid is False
132
+
133
+ error_codes = [error .code for error in result .errors ]
134
+ assert (
135
+ AuthServerConfigErrorCode .AUTHORIZATION_CODE_GRANT_NOT_SUPPORTED
136
+ in error_codes
137
+ )
0 commit comments