Skip to content

Commit

Permalink
[Key Vault] Skip tests when vault SKU is incompatible (Azure#25270)
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoyp authored and wonder6845 committed Aug 22, 2022
1 parent f5c6596 commit f8ded61
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 20 deletions.
41 changes: 27 additions & 14 deletions sdk/keyvault/azure-keyvault-keys/tests/test_key_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -626,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 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.")

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)
Expand All @@ -643,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 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.")

set_bodiless_matcher()
key_name = self.get_resource_name("rotation-key")
self._create_rsa_key(client, key_name)

Expand Down
18 changes: 14 additions & 4 deletions sdk/keyvault/azure-keyvault-keys/tests/test_keys_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -635,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 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.")

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)
Expand All @@ -653,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 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.")

set_bodiless_matcher()
key_name = self.get_resource_name("rotation-key")
await self._create_rsa_key(client, key_name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit f8ded61

Please sign in to comment.