Skip some tests for vault plugin

Vault secretstore plugin doesn't support asymmetric key generation for
now, so disable the related functional tests.

With this patch, the following functional tests sould be skipped:

api.v1.functional.test_orders.OrdersTestCase.test_encryption_using_generated_key
api.v1.functional.test_rsa.RSATestCase.test_rsa_order_certificate_from_ordered_container
api.v1.functional.test_rsa.RSATestCase.test_rsa_order_certificate_from_ordered_container_with_pass
api.v1.functional.test_rsa.RSATestCase.test_rsa_order_container
api.v1.functional.test_rsa.RSATestCase.test_rsa_order_container_with_passphrase

Change-Id: If416f38cb87bdb279a05263b99b5f2af916c1229
This commit is contained in:
Lingxian Kong 2018-07-27 14:46:38 +12:00
parent 51ad51477b
commit 809ae5c5d0
5 changed files with 17 additions and 16 deletions

View File

@ -610,20 +610,6 @@ def get_tomorrow_timestamp():
return tomorrow.isoformat()
def string_to_datetime(datetimestring, date_formats=None):
date_formats = date_formats or [
'%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%dT%H:%M:%S.%fZ',
'%Y-%m-%dT%H:%M:%S.%f', "%Y-%m-%dT%H:%M:%SZ", "%Y-%m-%dT%H:%M:%S"]
for dateformat in date_formats:
try:
return datetime.datetime.strptime(datetimestring, dateformat)
except ValueError:
continue
else:
raise
def get_id_from_ref(ref):
"""Returns id from reference."""
ref_id = None
@ -676,5 +662,9 @@ def is_kmip_enabled():
return os.environ.get('KMIP_PLUGIN_ENABLED') is not None
def is_vault_enabled():
return os.environ.get('VAULT_PLUGIN_ENABLED') is not None
class DummyClassForTesting(object):
pass

View File

@ -16,6 +16,7 @@ from oslo_serialization import jsonutils
import sys
import time
import testtools
from testtools import testcase
from barbican.tests import utils
@ -567,6 +568,8 @@ class OrdersTestCase(base.TestCase):
self.assertRegex(order_resp.model.order_ref, regex)
@testcase.attr('positive')
@testtools.skipIf(utils.is_vault_enabled(),
"Vault does not support this operation")
def test_encryption_using_generated_key(self):
"""Tests functionality of a generated asymmetric key pair."""
test_model = order_models.OrderModel(**self.asymmetric_data)

View File

@ -236,6 +236,8 @@ class RSATestCase(base.TestCase):
self.verify_container_keys_equal(secrets, with_passphrase=True)
@testcase.attr('positive')
@testtools.skipIf(utils.is_vault_enabled(),
"Vault does not support this operation")
def test_rsa_order_container(self):
"""Post an order for a container"""
order_ref = self.order_container()
@ -244,7 +246,7 @@ class RSATestCase(base.TestCase):
self.verify_container_keys_valid(secrets)
@testcase.attr('positive')
@testtools.skipIf(utils.is_kmip_enabled(),
@testtools.skipIf(utils.is_kmip_enabled() or utils.is_vault_enabled(),
"PyKMIP does not support this operation")
def test_rsa_order_container_with_passphrase(self):
"""Post an order for a container with a passphrase"""
@ -265,6 +267,8 @@ class RSATestCase(base.TestCase):
self.verify_container_keys_equal(secrets)
@testcase.attr('positive')
@testtools.skipIf(utils.is_vault_enabled(),
"Vault does not support this operation")
def test_rsa_order_certificate_from_ordered_container(self):
"""Post an order for a certificate"""
order_ref = self.order_container()
@ -276,7 +280,7 @@ class RSATestCase(base.TestCase):
self.verify_certificate_order_status(order_status)
@testcase.attr('positive')
@testtools.skipIf(utils.is_kmip_enabled(),
@testtools.skipIf(utils.is_kmip_enabled() or utils.is_vault_enabled(),
"PyKMIP does not support this operation")
def test_rsa_order_certificate_from_ordered_container_with_pass(self):
"""Post an order for a certificate"""

View File

@ -26,6 +26,8 @@ plugin=$1
if [[ "$plugin" == "kmip" ]]; then
export KMIP_PLUGIN_ENABLED=1
elif [[ "$plugin" == "vault" ]]; then
export VAULT_PLUGIN_ENABLED=1
fi
# run the tests sequentially

View File

@ -113,6 +113,7 @@ commands =
coverage html -d cover
coverage xml -o cover/coverage.xml
passenv = KMIP_PLUGIN_ENABLED
VAULT_PLUGIN_ENABLED
[testenv:py35functional]
basepython = python3
@ -126,6 +127,7 @@ commands =
coverage html -d cover
coverage xml -o cover/coverage.xml
passenv = KMIP_PLUGIN_ENABLED
VAULT_PLUGIN_ENABLED
[testenv:cmd]
basepython = python3