11"""Tests for configuration module."""
22
33import tempfile
4- from pathlib import Path
54
65import pytest
76
@@ -68,7 +67,7 @@ def test_empty_content(self):
6867 def test_only_comments (self ):
6968 """Test parsing content with only comments."""
7069 content = "# comment 1\n # comment 2"
71- result = parse_config_file ("" )
70+ result = parse_config_file (content )
7271 assert result == {}
7372
7473
@@ -86,11 +85,13 @@ def test_default_values(self):
8685
8786 def test_custom_values (self ):
8887 """Test custom values override defaults."""
89- config = build_config ({
90- "host" : "127.0.0.1" ,
91- "port" : "8080" ,
92- "auth_disabled" : "true" ,
93- })
88+ config = build_config (
89+ {
90+ "host" : "127.0.0.1" ,
91+ "port" : "8080" ,
92+ "auth_disabled" : "true" ,
93+ }
94+ )
9495 assert config .host == "127.0.0.1"
9596 assert config .port == 8080
9697
@@ -102,10 +103,12 @@ def test_port_type_conversion(self):
102103
103104 def test_boolean_type_conversion (self ):
104105 """Test boolean values are converted correctly."""
105- config = build_config ({
106- "auth_disabled" : "true" ,
107- "jwks_auto_refresh" : "false" ,
108- })
106+ config = build_config (
107+ {
108+ "auth_disabled" : "true" ,
109+ "jwks_auto_refresh" : "false" ,
110+ }
111+ )
109112 assert config .auth_disabled is True
110113 assert config .jwks_auto_refresh is False
111114
@@ -116,10 +119,12 @@ def test_server_url_default(self):
116119
117120 def test_server_url_custom (self ):
118121 """Test custom server_url."""
119- config = build_config ({
120- "server_url" : "https://api.example.com" ,
121- "auth_disabled" : "true" ,
122- })
122+ config = build_config (
123+ {
124+ "server_url" : "https://api.example.com" ,
125+ "auth_disabled" : "true" ,
126+ }
127+ )
123128 assert config .server_url == "https://api.example.com"
124129
125130
@@ -128,44 +133,52 @@ class TestEndpointDerivation:
128133
129134 def test_derives_jwks_uri (self ):
130135 """Test jwks_uri is derived from auth_server_url."""
131- config = build_config ({
132- "auth_server_url" : "https://auth.example.com/realms/test" ,
133- "client_id" : "test-client" ,
134- "client_secret" : "secret" ,
135- })
136+ config = build_config (
137+ {
138+ "auth_server_url" : "https://auth.example.com/realms/test" ,
139+ "client_id" : "test-client" ,
140+ "client_secret" : "secret" ,
141+ }
142+ )
136143 assert config .jwks_uri == (
137144 "https://auth.example.com/realms/test/protocol/openid-connect/certs"
138145 )
139146
140147 def test_derives_token_endpoint (self ):
141148 """Test token_endpoint is derived from auth_server_url."""
142- config = build_config ({
143- "auth_server_url" : "https://auth.example.com/realms/test" ,
144- "client_id" : "test-client" ,
145- "client_secret" : "secret" ,
146- })
149+ config = build_config (
150+ {
151+ "auth_server_url" : "https://auth.example.com/realms/test" ,
152+ "client_id" : "test-client" ,
153+ "client_secret" : "secret" ,
154+ }
155+ )
147156 assert config .token_endpoint == (
148157 "https://auth.example.com/realms/test/protocol/openid-connect/token"
149158 )
150159
151160 def test_derives_issuer (self ):
152161 """Test issuer is derived from auth_server_url."""
153- config = build_config ({
154- "auth_server_url" : "https://auth.example.com/realms/test" ,
155- "client_id" : "test-client" ,
156- "client_secret" : "secret" ,
157- })
162+ config = build_config (
163+ {
164+ "auth_server_url" : "https://auth.example.com/realms/test" ,
165+ "client_id" : "test-client" ,
166+ "client_secret" : "secret" ,
167+ }
168+ )
158169 assert config .issuer == "https://auth.example.com/realms/test"
159170
160171 def test_explicit_values_not_overwritten (self ):
161172 """Test explicit values are not overwritten by derivation."""
162- config = build_config ({
163- "auth_server_url" : "https://auth.example.com/realms/test" ,
164- "jwks_uri" : "https://custom.example.com/jwks" ,
165- "issuer" : "https://custom-issuer.example.com" ,
166- "client_id" : "test-client" ,
167- "client_secret" : "secret" ,
168- })
173+ config = build_config (
174+ {
175+ "auth_server_url" : "https://auth.example.com/realms/test" ,
176+ "jwks_uri" : "https://custom.example.com/jwks" ,
177+ "issuer" : "https://custom-issuer.example.com" ,
178+ "client_id" : "test-client" ,
179+ "client_secret" : "secret" ,
180+ }
181+ )
169182 assert config .jwks_uri == "https://custom.example.com/jwks"
170183 assert config .issuer == "https://custom-issuer.example.com"
171184
0 commit comments