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