@@ -133,8 +133,24 @@ def test_client_settings_without_schema_path_or_remote_schema_url_raises_excepti
133
133
ClientSettings (queries_path = queries_path )
134
134
135
135
136
+ @pytest .mark .parametrize (
137
+ "configured_header, expected_header" ,
138
+ [
139
+ ("$TEST_VAR" , "test_value" ),
140
+ ("Bearer: $TEST_VAR" , "Bearer: test_value" ),
141
+ ("Bearer: ${TEST_VAR}" , "Bearer: test_value" ),
142
+ pytest .param (
143
+ "$NOT_SET_VAR" ,
144
+ "" ,
145
+ marks = pytest .mark .xfail (raises = InvalidConfiguration ),
146
+ ),
147
+ ],
148
+ )
136
149
def test_client_settings_resolves_env_variable_for_remote_schema_header_with_prefix (
137
- tmp_path , mocker
150
+ tmp_path ,
151
+ mocker ,
152
+ configured_header ,
153
+ expected_header ,
138
154
):
139
155
queries_path = tmp_path / "queries.graphql"
140
156
queries_path .touch ()
@@ -143,10 +159,42 @@ def test_client_settings_resolves_env_variable_for_remote_schema_header_with_pre
143
159
settings = ClientSettings (
144
160
queries_path = queries_path ,
145
161
remote_schema_url = "https://test" ,
146
- remote_schema_headers = {"Authorization" : "$TEST_VAR" },
162
+ remote_schema_headers = {"Authorization" : configured_header },
163
+ )
164
+
165
+ assert settings .remote_schema_headers ["Authorization" ] == expected_header
166
+
167
+
168
+ @pytest .mark .parametrize (
169
+ "configured_url, expected_url" ,
170
+ [
171
+ ("$TEST_VAR" , "test_value" ),
172
+ ("https://${TEST_VAR}/graphql" , "https://test_value/graphql" ),
173
+ ("https://$TEST_VAR/graphql" , "https://test_value/graphql" ),
174
+ ("https://TEST_VAR/graphql" , "https://TEST_VAR/graphql" ),
175
+ pytest .param (
176
+ "https://${NOT_SET_VAR}/graphql" ,
177
+ "" ,
178
+ marks = pytest .mark .xfail (raises = InvalidConfiguration ),
179
+ ),
180
+ ],
181
+ )
182
+ def test_client_settings_resolves_env_variable_for_remote_schema (
183
+ tmp_path ,
184
+ mocker ,
185
+ configured_url ,
186
+ expected_url ,
187
+ ):
188
+ queries_path = tmp_path / "queries.graphql"
189
+ queries_path .touch ()
190
+ mocker .patch .dict (os .environ , {"TEST_VAR" : "test_value" })
191
+
192
+ settings = ClientSettings (
193
+ queries_path = queries_path ,
194
+ remote_schema_url = configured_url ,
147
195
)
148
196
149
- assert settings .remote_schema_headers [ "Authorization" ] == "test_value"
197
+ assert settings .remote_schema_url == expected_url
150
198
151
199
152
200
def test_client_settings_doesnt_resolve_remote_schema_header_without_prefix (tmp_path ):
0 commit comments