@@ -160,42 +160,41 @@ async def test_create_api_key_with_expiration(
160160):
161161 assert client .app
162162
163+ # test gc is actually disabled
163164 gc_prune_mock = mocker .patch (
164- "simcore_service_webserver.garbage_collector._tasks_api_keys.api_keys_service.prune_expired_api_keys " ,
165+ "simcore_service_webserver.garbage_collector._tasks_api_keys.create_background_task_to_prune_api_keys " ,
165166 spec = True ,
166167 )
167-
168168 assert not gc_prune_mock .called
169169
170- TEST_API_KEY = "foo"
170+ expected_api_key = "foo"
171171
172172 # create api-keys with expiration interval
173173 expiration_interval = timedelta (seconds = 1 )
174174 resp = await client .post (
175175 "/v0/auth/api-keys" ,
176- json = {"displayName" : TEST_API_KEY , "expiration" : expiration_interval .seconds },
176+ json = {
177+ "displayName" : expected_api_key ,
178+ "expiration" : expiration_interval .seconds ,
179+ },
177180 )
178181
179182 data , errors = await assert_status (resp , expected )
180183 if not errors :
181- assert data ["displayName" ] == TEST_API_KEY
184+ assert data ["displayName" ] == expected_api_key
182185 assert "apiKey" in data
183186 assert "apiSecret" in data
184187
185188 # list created api-key
186189 resp = await client .get ("/v0/auth/api-keys" )
187190 data , _ = await assert_status (resp , expected )
188- assert [d ["displayName" ] for d in data ] == [TEST_API_KEY ]
189-
190- assert not gc_prune_mock .called
191+ assert [d ["displayName" ] for d in data ] == [expected_api_key ]
191192
192193 # wait for api-key for it to expire and force-run scheduled task
193194 await asyncio .sleep (EXPIRATION_WAIT_FACTOR * expiration_interval .seconds )
194195
195- assert not gc_prune_mock .called
196-
197196 deleted = await api_keys_service .prune_expired_api_keys (client .app )
198- assert deleted == [TEST_API_KEY ]
197+ assert deleted == [expected_api_key ]
199198
200199 resp = await client .get ("/v0/auth/api-keys" )
201200 data , _ = await assert_status (resp , expected )
0 commit comments