@@ -551,3 +551,64 @@ def _finalize():
551551 request .addfinalizer (lambda : host .execute (f'podman rmi { cv_path } ' ))
552552 res = host .execute ('podman images' )
553553 assert cv_path in res .stdout
554+
555+ def test_positive_revoke_registry_token_prevents_access (
556+ self , request , target_sat , function_product
557+ ):
558+ """Verify that revoking a registry access token prevents client access to registry.
559+
560+ :id: 8b4e5c2a-1f3d-4a7e-9c8b-2d6f4e5a3b1c
561+
562+ :steps:
563+ 1. Sync a small container repo (quay/busybox from quay.io)
564+ 2. Login to Satellite registry
565+ 3. Pull the synced image - should succeed
566+ 4. Revoke the registry personal access token via CLI
567+ 5. Try to pull again - should fail with authentication error
568+
569+ :expectedresults:
570+ After revoking the authentication token, podman pull fails with
571+ authentication error.
572+
573+ :Verifies: SAT-38785
574+ """
575+ # 1. Sync a small container repo (quay/busybox from quay.io)
576+ repo = _repo (
577+ target_sat , function_product .id , upstream_name = 'quay/busybox' , url = 'https://quay.io'
578+ )
579+ target_sat .cli .Repository .synchronize ({'id' : repo ['id' ]})
580+
581+ # Build the registry path for the synced image
582+ repo_info = target_sat .cli .Repository .info ({'id' : repo ['id' ]})
583+ registry_path = repo_info ['published-at' ]
584+
585+ @request .addfinalizer
586+ def _cleanup ():
587+ target_sat .execute (f'podman logout { target_sat .hostname } ' )
588+ target_sat .execute (f'podman rmi { registry_path } ' )
589+
590+ # 2. Login to Satellite registry
591+ result = target_sat .execute (
592+ f'podman login -u { settings .server .admin_username } '
593+ f' -p { settings .server .admin_password } { target_sat .hostname } '
594+ )
595+ assert result .status == 0 , f'Failed to login to registry: { result .stderr } '
596+
597+ # 3. Pull the synced image - should succeed
598+ result = target_sat .execute (f'podman pull { registry_path } ' )
599+ assert result .status == 0 , f'Failed to pull synced image: { result .stderr } '
600+
601+ # 4. Revoke the registry personal access token via CLI
602+ admin_user = target_sat .cli .User .info ({'login' : settings .server .admin_username })
603+ target_sat .cli .User .access_token (
604+ action = 'revoke' ,
605+ options = {'name' : 'registry' , 'user-id' : admin_user ['id' ]},
606+ )
607+
608+ # 5. Try to pull again - should fail with authentication error
609+ result = target_sat .execute (f'podman pull { registry_path } ' )
610+ assert result .status != 0 , 'Pull should have failed after token revocation'
611+ assert (
612+ 'authentication required' in result .stderr .lower ()
613+ or 'unauthorized' in result .stderr .lower ()
614+ ), f'Expected authentication error, got: { result .stderr } '
0 commit comments