@@ -628,7 +628,7 @@ def two_active_api_key_ids(
628628 request_session_http : requests .Session ,
629629 base_url : str ,
630630 ocp_token_for_actor : str ,
631- ) -> list [str ]:
631+ ) -> Generator [ list [str ], Any , Any ]:
632632 """
633633 Create two active API keys and return their IDs for list tests.
634634 """
@@ -642,15 +642,23 @@ def two_active_api_key_ids(
642642 for i in range (1 , 3 )
643643 ]
644644 LOGGER .info (f"two_active_api_key_ids: created keys { ids } " )
645- return ids
645+ yield ids
646+ for key_id in ids :
647+ LOGGER .info (f"Fixture teardown: revoking key { key_id } " )
648+ revoke_api_key (
649+ request_session_http = request_session_http ,
650+ base_url = base_url ,
651+ key_id = key_id ,
652+ ocp_user_token = ocp_token_for_actor ,
653+ )
646654
647655
648656@pytest .fixture (scope = "function" )
649657def active_api_key_id (
650658 request_session_http : requests .Session ,
651659 base_url : str ,
652660 ocp_token_for_actor : str ,
653- ) -> str :
661+ ) -> Generator [ str , Any , Any ] :
654662 """
655663 Create a single active API key and return its ID for revoke tests.
656664 """
@@ -662,7 +670,14 @@ def active_api_key_id(
662670 api_key_name = key_name ,
663671 )
664672 LOGGER .info (f"active_api_key_id: created key id={ body ['id' ]} " )
665- return body ["id" ]
673+ yield body ["id" ]
674+ LOGGER .info (f"Fixture teardown: revoking key { body ['id' ]} " )
675+ revoke_api_key (
676+ request_session_http = request_session_http ,
677+ base_url = base_url ,
678+ key_id = body ["id" ],
679+ ocp_user_token = ocp_token_for_actor ,
680+ )
666681
667682
668683@pytest .fixture (scope = "function" )
@@ -691,4 +706,3 @@ def revoked_api_key_id(
691706 assert revoke_body .get ("status" ) == "revoked" , f"Expected status='revoked' in DELETE response, got: { revoke_body } "
692707 LOGGER .info (f"revoked_api_key_id: revoked key id={ active_api_key_id } " )
693708 return active_api_key_id
694-
0 commit comments