From d503e16a069da60da3b75a1159c42282c1adecfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?McCoy=20Pati=C3=B1o?= Date: Mon, 18 Jul 2022 12:19:59 -0700 Subject: [PATCH 1/2] Skip tests on incompatible SKU --- .../tests/test_key_client.py | 37 +++++++++++++------ .../tests/test_keys_async.py | 14 ++++++- .../tests/test_samples_keys.py | 2 +- .../tests/test_samples_keys_async.py | 2 +- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py b/sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py index ed0caf5f9f0b..02b3dba53e60 100644 --- a/sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py +++ b/sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py @@ -6,25 +6,29 @@ import functools import json import logging +import os import time import pytest -from azure.core.exceptions import (HttpResponseError, ResourceExistsError, - ResourceNotFoundError) +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError from azure.core.pipeline.policies import SansIOHTTPPolicy -from azure.keyvault.keys import (ApiVersion, JsonWebKey, KeyClient, - KeyReleasePolicy, KeyRotationLifetimeAction, - KeyRotationPolicy, KeyRotationPolicyAction, - KeyType) -from azure.keyvault.keys._generated.v7_3.models import \ - KeyRotationPolicy as _KeyRotationPolicy +from azure.keyvault.keys import ( + ApiVersion, + JsonWebKey, + KeyClient, + KeyReleasePolicy, + KeyRotationLifetimeAction, + KeyRotationPolicy, + KeyRotationPolicyAction, + KeyType +) +from azure.keyvault.keys._generated.v7_3.models import KeyRotationPolicy as _KeyRotationPolicy from dateutil import parser as date_parse from devtools_testutils import recorded_by_proxy, set_bodiless_matcher from six import byte2int from _shared.test_case import KeyVaultTestCase -from _test_case import (KeysClientPreparer, get_attestation_token, - get_decorator, get_release_policy, is_public_cloud) +from _test_case import KeysClientPreparer, get_attestation_token, get_decorator, get_release_policy, is_public_cloud from _keys_test_case import KeysTestCase @@ -510,6 +514,9 @@ def test_get_random_bytes(self, client, **kwargs): @KeysClientPreparer() @recorded_by_proxy def test_key_release(self, client, **kwargs): + if (self.is_live and os.environ["KEYVAULT_SKU"] != "premium"): + pytest.skip("This test is not supported on standard SKU vaults. Follow up with service team") + set_bodiless_matcher() attestation_uri = self._get_attestation_uri() attestation = get_attestation_token(attestation_uri) @@ -550,6 +557,9 @@ def test_imported_key_release(self, client, **kwargs): @KeysClientPreparer() @recorded_by_proxy def test_update_release_policy(self, client, **kwargs): + if (self.is_live and os.environ["KEYVAULT_SKU"] != "premium"): + pytest.skip("This test is not supported on standard SKU vaults. Follow up with service team") + set_bodiless_matcher() attestation_uri = self._get_attestation_uri() release_policy = get_release_policy(attestation_uri) @@ -592,6 +602,9 @@ def test_update_release_policy(self, client, **kwargs): @KeysClientPreparer() @recorded_by_proxy def test_immutable_release_policy(self, client, **kwargs): + if (self.is_live and os.environ["KEYVAULT_SKU"] != "premium"): + pytest.skip("This test is not supported on standard SKU vaults. Follow up with service team") + set_bodiless_matcher() attestation_uri = self._get_attestation_uri() release_policy = get_release_policy(attestation_uri, immutable=True) @@ -628,7 +641,7 @@ def test_immutable_release_policy(self, client, **kwargs): def test_key_rotation(self, client, **kwargs): set_bodiless_matcher() if (not is_public_cloud() and self.is_live): - pytest.skip("This test not supprot in usgov/china region. Follow up with service team.") + pytest.skip("This test is not supported in usgov/china region. Follow up with service team.") key_name = self.get_resource_name("rotation-key") key = self._create_rsa_key(client, key_name) @@ -645,7 +658,7 @@ def test_key_rotation(self, client, **kwargs): def test_key_rotation_policy(self, client, **kwargs): set_bodiless_matcher() if (not is_public_cloud() and self.is_live): - pytest.skip("This test not supprot in usgov/china region. Follow up with service team.") + pytest.skip("This test is not supported in usgov/china region. Follow up with service team.") key_name = self.get_resource_name("rotation-key") self._create_rsa_key(client, key_name) diff --git a/sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py b/sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py index 666c5ed63db6..7d7b1c64eb4d 100644 --- a/sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py +++ b/sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py @@ -8,6 +8,7 @@ import functools import json import logging +import os from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError from azure.core.pipeline.policies import SansIOHTTPPolicy @@ -515,6 +516,9 @@ async def test_get_random_bytes(self, client, **kwargs): @AsyncKeysClientPreparer() @recorded_by_proxy_async async def test_key_release(self, client, **kwargs): + if (self.is_live and os.environ["KEYVAULT_SKU"] != "premium"): + pytest.skip("This test is not supported on standard SKU vaults. Follow up with service team") + set_bodiless_matcher() attestation_uri = self._get_attestation_uri() attestation = await get_attestation_token(attestation_uri) @@ -557,6 +561,9 @@ async def test_imported_key_release(self, client, **kwargs): @AsyncKeysClientPreparer() @recorded_by_proxy_async async def test_update_release_policy(self, client, **kwargs): + if (self.is_live and os.environ["KEYVAULT_SKU"] != "premium"): + pytest.skip("This test is not supported on standard SKU vaults. Follow up with service team") + set_bodiless_matcher() attestation_uri = self._get_attestation_uri() release_policy = get_release_policy(attestation_uri) @@ -600,6 +607,9 @@ async def test_update_release_policy(self, client, **kwargs): @AsyncKeysClientPreparer() @recorded_by_proxy_async async def test_immutable_release_policy(self, client, **kwargs): + if (self.is_live and os.environ["KEYVAULT_SKU"] != "premium"): + pytest.skip("This test is not supported on standard SKU vaults. Follow up with service team") + set_bodiless_matcher() attestation_uri = self._get_attestation_uri() release_policy = get_release_policy(attestation_uri, immutable=True) @@ -637,7 +647,7 @@ async def test_immutable_release_policy(self, client, **kwargs): async def test_key_rotation(self, client, **kwargs): set_bodiless_matcher() if (not is_public_cloud() and self.is_live): - pytest.skip("This test not supprot in usgov/china region. Follow up with service team.") + pytest.skip("This test is not supported in usgov/china region. Follow up with service team.") key_name = self.get_resource_name("rotation-key") key = await self._create_rsa_key(client, key_name) @@ -655,7 +665,7 @@ async def test_key_rotation(self, client, **kwargs): async def test_key_rotation_policy(self, client, **kwargs): set_bodiless_matcher() if (not is_public_cloud() and self.is_live): - pytest.skip("This test not supprot in usgov/china region. Follow up with service team.") + pytest.skip("This test is not supported in usgov/china region. Follow up with service team.") key_name = self.get_resource_name("rotation-key") await self._create_rsa_key(client, key_name) diff --git a/sdk/keyvault/azure-keyvault-keys/tests/test_samples_keys.py b/sdk/keyvault/azure-keyvault-keys/tests/test_samples_keys.py index 315e4c567b8e..f48237d31824 100644 --- a/sdk/keyvault/azure-keyvault-keys/tests/test_samples_keys.py +++ b/sdk/keyvault/azure-keyvault-keys/tests/test_samples_keys.py @@ -42,7 +42,7 @@ class TestExamplesKeyVault(KeyVaultTestCase, KeysTestCase): @recorded_by_proxy def test_example_key_crud_operations(self, key_client, **kwargs): if (self.is_live and os.environ["KEYVAULT_SKU"] != "premium"): - pytest.skip("This test not supprot in usgov/china region. Follow up with service team") + pytest.skip("This test is not supported on standard SKU vaults. Follow up with service team") key_name = self.get_resource_name("key-name") diff --git a/sdk/keyvault/azure-keyvault-keys/tests/test_samples_keys_async.py b/sdk/keyvault/azure-keyvault-keys/tests/test_samples_keys_async.py index 1e595df6ecb5..c4cc017ee476 100644 --- a/sdk/keyvault/azure-keyvault-keys/tests/test_samples_keys_async.py +++ b/sdk/keyvault/azure-keyvault-keys/tests/test_samples_keys_async.py @@ -46,7 +46,7 @@ class TestExamplesKeyVault(KeyVaultTestCase): @recorded_by_proxy_async async def test_example_key_crud_operations(self, key_client, **kwargs): if (self.is_live and os.environ["KEYVAULT_SKU"] != "premium"): - pytest.skip("This test not supprot in usgov/china region. Follow up with service team") + pytest.skip("This test is not supported on standard SKU vaults. Follow up with service team") key_name = self.get_resource_name("key-name") From f4b9cce4026d3c227b8a8ca1b9f7a6c8082bd8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?McCoy=20Pati=C3=B1o?= Date: Wed, 20 Jul 2022 10:18:50 -0700 Subject: [PATCH 2/2] Skip before setting matchers --- sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py | 4 ++-- sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py b/sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py index 02b3dba53e60..a72ba573f4d8 100644 --- a/sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py +++ b/sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py @@ -639,10 +639,10 @@ def test_immutable_release_policy(self, client, **kwargs): @KeysClientPreparer() @recorded_by_proxy def test_key_rotation(self, client, **kwargs): - set_bodiless_matcher() if (not is_public_cloud() and self.is_live): pytest.skip("This test is not supported in usgov/china region. Follow up with service team.") + set_bodiless_matcher() key_name = self.get_resource_name("rotation-key") key = self._create_rsa_key(client, key_name) rotated_key = client.rotate_key(key_name) @@ -656,10 +656,10 @@ def test_key_rotation(self, client, **kwargs): @KeysClientPreparer() @recorded_by_proxy def test_key_rotation_policy(self, client, **kwargs): - set_bodiless_matcher() if (not is_public_cloud() and self.is_live): pytest.skip("This test is not supported in usgov/china region. Follow up with service team.") + set_bodiless_matcher() key_name = self.get_resource_name("rotation-key") self._create_rsa_key(client, key_name) diff --git a/sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py b/sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py index 7d7b1c64eb4d..a06c7f550c8b 100644 --- a/sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py +++ b/sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py @@ -645,10 +645,10 @@ async def test_immutable_release_policy(self, client, **kwargs): @AsyncKeysClientPreparer() @recorded_by_proxy_async async def test_key_rotation(self, client, **kwargs): - set_bodiless_matcher() if (not is_public_cloud() and self.is_live): pytest.skip("This test is not supported in usgov/china region. Follow up with service team.") + set_bodiless_matcher() key_name = self.get_resource_name("rotation-key") key = await self._create_rsa_key(client, key_name) rotated_key = await client.rotate_key(key_name) @@ -663,10 +663,10 @@ async def test_key_rotation(self, client, **kwargs): @AsyncKeysClientPreparer() @recorded_by_proxy_async async def test_key_rotation_policy(self, client, **kwargs): - set_bodiless_matcher() if (not is_public_cloud() and self.is_live): pytest.skip("This test is not supported in usgov/china region. Follow up with service team.") + set_bodiless_matcher() key_name = self.get_resource_name("rotation-key") await self._create_rsa_key(client, key_name)