def test_repository_show(self, mock_requests_get, mock_get_access_credentials, mock_get_registry_by_name): cmd = mock.MagicMock() cmd.cli_ctx = DummyCli() encoded_manifests = json.dumps({ 'registry': 'testregistry.azurecr.io', 'imageName': 'testrepository' }).encode() response = mock.MagicMock() response.headers = {} response.status_code = 200 response.content = encoded_manifests mock_requests_get.return_value = response mock_get_registry_by_name.return_value = Registry( location='westus', sku=Sku(name='Standard')), 'testrg' mock_get_access_credentials.return_value = 'testregistry.azurecr.io', 'username', 'password' # Show attributes for a repository acr_repository_show(cmd, registry_name='testregistry', repository='testrepository') mock_requests_get.assert_called_with( method='get', url='https://testregistry.azurecr.io/acr/v1/testrepository', headers=get_authorization_header('username', 'password'), params=None, json=None, verify=mock.ANY) # Show attributes for an image by tag acr_repository_show(cmd, registry_name='testregistry', image='testrepository:testtag') mock_requests_get.assert_called_with( method='get', url= 'https://testregistry.azurecr.io/acr/v1/testrepository/_tags/testtag', headers=get_authorization_header('username', 'password'), params=None, json=None, verify=mock.ANY) # Show attributes for an image by manifest digest acr_repository_show( cmd, registry_name='testregistry', image= 'testrepository@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7' ) mock_requests_get.assert_called_with( method='get', url= 'https://testregistry.azurecr.io/acr/v1/testrepository/_manifests/sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7', headers=get_authorization_header('username', 'password'), params=None, json=None, verify=mock.ANY)
def test_repository_show(self, mock_requests_get, mock_get_access_credentials, mock_get_registry_by_name): cmd = mock.MagicMock() cmd.cli_ctx = DummyCli() encoded_manifests = json.dumps({ 'registry': 'testregistry.azurecr.io', 'imageName': 'testrepository' }).encode() response = mock.MagicMock() response.headers = {} response.status_code = 200 response.content = encoded_manifests mock_requests_get.return_value = response mock_get_registry_by_name.return_value = Registry(location='westus', sku=Sku(name='Standard')), 'testrg' mock_get_access_credentials.return_value = 'testregistry.azurecr.io', 'username', 'password' # Show attributes for a repository acr_repository_show(cmd, registry_name='testregistry', repository='testrepository') mock_requests_get.assert_called_with( method='get', url='https://testregistry.azurecr.io/acr/v1/testrepository', headers=get_authorization_header('username', 'password'), params=None, json=None, data=None, verify=mock.ANY) # Show attributes for an image by tag acr_repository_show(cmd, registry_name='testregistry', image='testrepository:testtag') mock_requests_get.assert_called_with( method='get', url='https://testregistry.azurecr.io/acr/v1/testrepository/_tags/testtag', headers=get_authorization_header('username', 'password'), params=None, json=None, data=None, verify=mock.ANY) # Show attributes for an image by manifest digest acr_repository_show(cmd, registry_name='testregistry', image='testrepository@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7') mock_requests_get.assert_called_with( method='get', url='https://testregistry.azurecr.io/acr/v1/testrepository/_manifests/sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7', headers=get_authorization_header('username', 'password'), params=None, json=None, data=None, verify=mock.ANY)