Skip functional tests when test account4 is unauthorized

Five functional tests rely on swift test account4 being
properly configured in keystone (the tests are already
skipped with tempauth). A regression in devstack appears
to have caused account4 to not be correctly set up which
causes those five tests to fail.

This is a tactical change to skip those tests when the auth
for account4 fails, pending devstack being fixed. Note:

- we do not just skip the tests unconditionally; on a test
  system with correctly setup keystone accounts the tests
  are still run.

- the tests only skip if the auth fails with keystone for
  account4.

Change-Id: Iffef6d54554d1eb71524589cb58a06f874a6afc6
Related-Bug: 1508860
This commit is contained in:
Alistair Coles 2015-10-22 11:22:24 +01:00
parent 4ab06a73be
commit ed35e1fbee
3 changed files with 22 additions and 3 deletions

View File

@ -66,7 +66,7 @@ eventlet.hubs.use_hub(utils.get_hub())
eventlet.patcher.monkey_patch(all=False, socket=True)
eventlet.debug.hub_exceptions(False)
from swiftclient import get_auth, http_connection
from swiftclient import get_auth, http_connection, ClientException
has_insecure = False
try:
@ -897,6 +897,20 @@ def requires_acls(f):
return wrapper
def skip_if_unauthorized(use_account):
def wrap(f=lambda *args, **kwargs: None):
def test_wrapper(*args, **kwargs):
try:
retry(lambda *args, **kwargs: None, use_account=use_account)
except ClientException as e:
if 'Unauthorized' in e.message:
raise SkipTest(e)
raise
f(*args, **kwargs)
return test_wrapper
return wrap
class FunctionalStoragePolicyCollection(object):
def __init__(self, policies):

View File

@ -24,7 +24,7 @@ from string import letters
from swift.common.middleware.acl import format_acl
from test.functional import check_response, retry, requires_acls, \
load_constraint
load_constraint, skip_if_unauthorized
import test.functional as tf
@ -839,6 +839,7 @@ class TestAccountInNonDefaultDomain(unittest.TestCase):
if tf.skip or tf.skip2 or tf.skip_if_not_v3:
raise SkipTest('AUTH VERSION 3 SPECIFIC TEST')
@skip_if_unauthorized(use_account=4)
def test_project_domain_id_header(self):
# make sure account exists (assumes account auto create)
def post(url, token, parsed, conn):

View File

@ -21,7 +21,7 @@ from nose import SkipTest
from uuid import uuid4
from test.functional import check_response, retry, requires_acls, \
load_constraint, requires_policies
load_constraint, requires_policies, skip_if_unauthorized
import test.functional as tf
@ -1546,6 +1546,7 @@ class BaseTestContainerACLs(unittest.TestCase):
def setUp(self):
if tf.skip or tf.skip2 or tf.skip_if_not_v3:
raise SkipTest('AUTH VERSION 3 SPECIFIC TEST')
skip_if_unauthorized(use_account=self.account)()()
self.name = uuid4().hex
def put(url, token, parsed, conn):
@ -1665,11 +1666,14 @@ class BaseTestContainerACLs(unittest.TestCase):
class TestContainerACLsAccount1(BaseTestContainerACLs):
@skip_if_unauthorized(use_account=4)
def test_cross_account_acl_names_with_user_in_non_default_domain(self):
# names in acls are disallowed when grantee is in a non-default domain
skip_if_unauthorized(use_account=4)
acl = '%s:%s' % (tf.swift_test_tenant[3], tf.swift_test_user[3])
self._assert_cross_account_acl_granted(False, 4, acl)
@skip_if_unauthorized(use_account=4)
def test_cross_account_acl_ids_with_user_in_non_default_domain(self):
# ids are allowed in acls when grantee is in a non-default domain
tenant_id = retry(self._get_tenant_id, use_account=4)