Fix usage of multiple accounts in functional tests
Some tests make use of multiple accounts without checking of they have been set up. This commit tries to fix some of these situations. Change-Id: I461679e78e19ce0866c7618c581a8cb573cca7f5
This commit is contained in:
@@ -64,6 +64,7 @@ class TestSloEnv(BaseEnv):
|
|||||||
|
|
||||||
super(TestSloEnv, cls).setUp()
|
super(TestSloEnv, cls).setUp()
|
||||||
|
|
||||||
|
if not tf.skip2:
|
||||||
config2 = deepcopy(tf.config)
|
config2 = deepcopy(tf.config)
|
||||||
config2['account'] = tf.config['account2']
|
config2['account'] = tf.config['account2']
|
||||||
config2['username'] = tf.config['username2']
|
config2['username'] = tf.config['username2']
|
||||||
@@ -72,6 +73,7 @@ class TestSloEnv(BaseEnv):
|
|||||||
cls.conn2.authenticate()
|
cls.conn2.authenticate()
|
||||||
cls.account2 = cls.conn2.get_account()
|
cls.account2 = cls.conn2.get_account()
|
||||||
cls.account2.delete_containers()
|
cls.account2.delete_containers()
|
||||||
|
if not tf.skip3:
|
||||||
config3 = tf.config.copy()
|
config3 = tf.config.copy()
|
||||||
config3['username'] = tf.config['username3']
|
config3['username'] = tf.config['username3']
|
||||||
config3['password'] = tf.config['password3']
|
config3['password'] = tf.config['password3']
|
||||||
@@ -651,6 +653,7 @@ class TestSlo(Base):
|
|||||||
copied_contents = copied.read(parms={'multipart-manifest': 'get'})
|
copied_contents = copied.read(parms={'multipart-manifest': 'get'})
|
||||||
self.assertEqual(4 * 1024 * 1024 + 1, len(copied_contents))
|
self.assertEqual(4 * 1024 * 1024 + 1, len(copied_contents))
|
||||||
|
|
||||||
|
if not tf.skip2:
|
||||||
# copy to different account
|
# copy to different account
|
||||||
acct = self.env.conn2.account_name
|
acct = self.env.conn2.account_name
|
||||||
dest_cont = self.env.account2.container(Utils.create_name())
|
dest_cont = self.env.account2.container(Utils.create_name())
|
||||||
@@ -797,6 +800,8 @@ class TestSlo(Base):
|
|||||||
self.assertEqual(slo_etag, actual['slo_etag'])
|
self.assertEqual(slo_etag, actual['slo_etag'])
|
||||||
|
|
||||||
def test_slo_copy_the_manifest_account(self):
|
def test_slo_copy_the_manifest_account(self):
|
||||||
|
if tf.skip2:
|
||||||
|
raise SkipTest('Account2 not set')
|
||||||
acct = self.env.conn.account_name
|
acct = self.env.conn.account_name
|
||||||
# same account
|
# same account
|
||||||
file_item = self.env.container.file("manifest-abcde")
|
file_item = self.env.container.file("manifest-abcde")
|
||||||
@@ -1148,6 +1153,8 @@ class TestSlo(Base):
|
|||||||
self.assert_status(200)
|
self.assert_status(200)
|
||||||
|
|
||||||
def test_slo_referer_on_segment_container(self):
|
def test_slo_referer_on_segment_container(self):
|
||||||
|
if tf.skip3:
|
||||||
|
raise SkipTest('Username3 not set')
|
||||||
# First the account2 (test3) should fail
|
# First the account2 (test3) should fail
|
||||||
headers = {'X-Auth-Token': self.env.conn3.storage_token,
|
headers = {'X-Auth-Token': self.env.conn3.storage_token,
|
||||||
'Referer': 'http://blah.example.com'}
|
'Referer': 'http://blah.example.com'}
|
||||||
|
|||||||
@@ -122,6 +122,8 @@ class TestSymlinkEnv(BaseEnv):
|
|||||||
enumerate([cls.containers(), [cls.link_cont]], 1)]
|
enumerate([cls.containers(), [cls.link_cont]], 1)]
|
||||||
# delete objects inside container
|
# delete objects inside container
|
||||||
for use_account, containers in delete_containers:
|
for use_account, containers in delete_containers:
|
||||||
|
if use_account == 2 and tf.skip2:
|
||||||
|
continue
|
||||||
for container in containers:
|
for container in containers:
|
||||||
while True:
|
while True:
|
||||||
cont = container
|
cont = container
|
||||||
@@ -144,6 +146,8 @@ class TestSymlinkEnv(BaseEnv):
|
|||||||
|
|
||||||
# delete the containers
|
# delete the containers
|
||||||
for use_account, containers in delete_containers:
|
for use_account, containers in delete_containers:
|
||||||
|
if use_account == 2 and tf.skip2:
|
||||||
|
continue
|
||||||
for container in containers:
|
for container in containers:
|
||||||
resp = retry(cls._make_request, method='DELETE',
|
resp = retry(cls._make_request, method='DELETE',
|
||||||
container=container,
|
container=container,
|
||||||
|
|||||||
@@ -410,6 +410,7 @@ class TestContainerTempurlEnv(BaseEnv):
|
|||||||
cls.tempurl_key = Utils.create_name()
|
cls.tempurl_key = Utils.create_name()
|
||||||
cls.tempurl_key2 = Utils.create_name()
|
cls.tempurl_key2 = Utils.create_name()
|
||||||
|
|
||||||
|
if not tf.skip2:
|
||||||
# creating another account and connection
|
# creating another account and connection
|
||||||
# for ACL tests
|
# for ACL tests
|
||||||
config2 = deepcopy(tf.config)
|
config2 = deepcopy(tf.config)
|
||||||
@@ -423,11 +424,17 @@ class TestContainerTempurlEnv(BaseEnv):
|
|||||||
cls.account2 = cls.conn2.get_account()
|
cls.account2 = cls.conn2.get_account()
|
||||||
|
|
||||||
cls.container = cls.account.container(Utils.create_name())
|
cls.container = cls.account.container(Utils.create_name())
|
||||||
|
if not tf.skip2:
|
||||||
if not cls.container.create({
|
if not cls.container.create({
|
||||||
'x-container-meta-temp-url-key': cls.tempurl_key,
|
'x-container-meta-temp-url-key': cls.tempurl_key,
|
||||||
'x-container-meta-temp-url-key-2': cls.tempurl_key2,
|
'x-container-meta-temp-url-key-2': cls.tempurl_key2,
|
||||||
'x-container-read': cls.account2.name}):
|
'x-container-read': cls.account2.name}):
|
||||||
raise ResponseError(cls.conn.response)
|
raise ResponseError(cls.conn.response)
|
||||||
|
else:
|
||||||
|
if not cls.container.create({
|
||||||
|
'x-container-meta-temp-url-key': cls.tempurl_key,
|
||||||
|
'x-container-meta-temp-url-key-2': cls.tempurl_key2}):
|
||||||
|
raise ResponseError(cls.conn.response)
|
||||||
|
|
||||||
cls.obj = cls.container.file(Utils.create_name())
|
cls.obj = cls.container.file(Utils.create_name())
|
||||||
cls.obj.write("obj contents")
|
cls.obj.write("obj contents")
|
||||||
@@ -583,6 +590,8 @@ class TestContainerTempurl(Base):
|
|||||||
|
|
||||||
@requires_acls
|
@requires_acls
|
||||||
def test_tempurl_keys_hidden_from_acl_readonly(self):
|
def test_tempurl_keys_hidden_from_acl_readonly(self):
|
||||||
|
if tf.skip2:
|
||||||
|
raise SkipTest('Account2 not set')
|
||||||
metadata = self.env.container.info(cfg={
|
metadata = self.env.container.info(cfg={
|
||||||
'use_token': self.env.conn2.storage_token})
|
'use_token': self.env.conn2.storage_token})
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class TestObjectVersioningEnv(BaseEnv):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUp(cls):
|
def setUp(cls):
|
||||||
super(TestObjectVersioningEnv, cls).setUp()
|
super(TestObjectVersioningEnv, cls).setUp()
|
||||||
|
if not tf.skip2:
|
||||||
# Second connection for ACL tests
|
# Second connection for ACL tests
|
||||||
config2 = deepcopy(tf.config)
|
config2 = deepcopy(tf.config)
|
||||||
config2['account'] = tf.config['account2']
|
config2['account'] = tf.config['account2']
|
||||||
@@ -74,6 +75,7 @@ class TestObjectVersioningEnv(BaseEnv):
|
|||||||
# if versioning is off, then cls.location_header_key won't persist
|
# if versioning is off, then cls.location_header_key won't persist
|
||||||
cls.versioning_enabled = 'versions' in container_info
|
cls.versioning_enabled = 'versions' in container_info
|
||||||
|
|
||||||
|
if not tf.skip2:
|
||||||
# setup another account to test ACLs
|
# setup another account to test ACLs
|
||||||
config2 = deepcopy(tf.config)
|
config2 = deepcopy(tf.config)
|
||||||
config2['account'] = tf.config['account2']
|
config2['account'] = tf.config['account2']
|
||||||
@@ -84,6 +86,7 @@ class TestObjectVersioningEnv(BaseEnv):
|
|||||||
cls.account2 = cls.conn2.get_account()
|
cls.account2 = cls.conn2.get_account()
|
||||||
cls.account2.delete_containers()
|
cls.account2.delete_containers()
|
||||||
|
|
||||||
|
if not tf.skip3:
|
||||||
# setup another account with no access to anything to test ACLs
|
# setup another account with no access to anything to test ACLs
|
||||||
config3 = deepcopy(tf.config)
|
config3 = deepcopy(tf.config)
|
||||||
config3['account'] = tf.config['account']
|
config3['account'] = tf.config['account']
|
||||||
@@ -131,6 +134,7 @@ class TestCrossPolicyObjectVersioningEnv(BaseEnv):
|
|||||||
policy = cls.policies.select()
|
policy = cls.policies.select()
|
||||||
version_policy = cls.policies.exclude(name=policy['name']).select()
|
version_policy = cls.policies.exclude(name=policy['name']).select()
|
||||||
|
|
||||||
|
if not tf.skip2:
|
||||||
# Second connection for ACL tests
|
# Second connection for ACL tests
|
||||||
config2 = deepcopy(tf.config)
|
config2 = deepcopy(tf.config)
|
||||||
config2['account'] = tf.config['account2']
|
config2['account'] = tf.config['account2']
|
||||||
@@ -161,6 +165,7 @@ class TestCrossPolicyObjectVersioningEnv(BaseEnv):
|
|||||||
# if versioning is off, then X-Versions-Location won't persist
|
# if versioning is off, then X-Versions-Location won't persist
|
||||||
cls.versioning_enabled = 'versions' in container_info
|
cls.versioning_enabled = 'versions' in container_info
|
||||||
|
|
||||||
|
if not tf.skip2:
|
||||||
# setup another account to test ACLs
|
# setup another account to test ACLs
|
||||||
config2 = deepcopy(tf.config)
|
config2 = deepcopy(tf.config)
|
||||||
config2['account'] = tf.config['account2']
|
config2['account'] = tf.config['account2']
|
||||||
@@ -171,6 +176,7 @@ class TestCrossPolicyObjectVersioningEnv(BaseEnv):
|
|||||||
cls.account2 = cls.conn2.get_account()
|
cls.account2 = cls.conn2.get_account()
|
||||||
cls.account2.delete_containers()
|
cls.account2.delete_containers()
|
||||||
|
|
||||||
|
if not tf.skip3:
|
||||||
# setup another account with no access to anything to test ACLs
|
# setup another account with no access to anything to test ACLs
|
||||||
config3 = deepcopy(tf.config)
|
config3 = deepcopy(tf.config)
|
||||||
config3['account'] = tf.config['account']
|
config3['account'] = tf.config['account']
|
||||||
@@ -485,6 +491,8 @@ class TestObjectVersioning(Base):
|
|||||||
self.assertEqual("old content", man_file.read())
|
self.assertEqual("old content", man_file.read())
|
||||||
|
|
||||||
def test_versioning_container_acl(self):
|
def test_versioning_container_acl(self):
|
||||||
|
if tf.skip2:
|
||||||
|
raise SkipTest('Account2 not set')
|
||||||
# create versions container and DO NOT give write access to account2
|
# create versions container and DO NOT give write access to account2
|
||||||
versions_container = self.env.account.container(Utils.create_name())
|
versions_container = self.env.account.container(Utils.create_name())
|
||||||
location_header_val = quote(str(versions_container))
|
location_header_val = quote(str(versions_container))
|
||||||
@@ -623,6 +631,8 @@ class TestObjectVersioning(Base):
|
|||||||
return versioned_obj
|
return versioned_obj
|
||||||
|
|
||||||
def test_versioning_check_acl(self):
|
def test_versioning_check_acl(self):
|
||||||
|
if tf.skip2:
|
||||||
|
raise SkipTest('Account2 not set')
|
||||||
versioned_obj = self._test_versioning_check_acl_setup()
|
versioned_obj = self._test_versioning_check_acl_setup()
|
||||||
versioned_obj.delete()
|
versioned_obj.delete()
|
||||||
self.assertEqual("aaaaa", versioned_obj.read())
|
self.assertEqual("aaaaa", versioned_obj.read())
|
||||||
@@ -896,6 +906,8 @@ class TestObjectVersioningHistoryMode(TestObjectVersioning):
|
|||||||
self.assertEqual(expected, bodies)
|
self.assertEqual(expected, bodies)
|
||||||
|
|
||||||
def test_versioning_check_acl(self):
|
def test_versioning_check_acl(self):
|
||||||
|
if tf.skip2:
|
||||||
|
raise SkipTest('Account2 not set')
|
||||||
versioned_obj = self._test_versioning_check_acl_setup()
|
versioned_obj = self._test_versioning_check_acl_setup()
|
||||||
versioned_obj.delete()
|
versioned_obj.delete()
|
||||||
with self.assertRaises(ResponseError) as cm:
|
with self.assertRaises(ResponseError) as cm:
|
||||||
|
|||||||
@@ -1189,6 +1189,7 @@ class TestFileEnv(BaseEnv):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUp(cls):
|
def setUp(cls):
|
||||||
super(TestFileEnv, cls).setUp()
|
super(TestFileEnv, cls).setUp()
|
||||||
|
if not tf.skip2:
|
||||||
# creating another account and connection
|
# creating another account and connection
|
||||||
# for account to account copy tests
|
# for account to account copy tests
|
||||||
config2 = deepcopy(tf.config)
|
config2 = deepcopy(tf.config)
|
||||||
@@ -1214,6 +1215,7 @@ class TestFileEnv(BaseEnv):
|
|||||||
# not have been known. So we ensure that the project domain id is
|
# not have been known. So we ensure that the project domain id is
|
||||||
# in sysmeta by making a POST to the accounts using an admin role.
|
# in sysmeta by making a POST to the accounts using an admin role.
|
||||||
cls.account.update_metadata()
|
cls.account.update_metadata()
|
||||||
|
if not tf.skip2:
|
||||||
cls.account2.update_metadata()
|
cls.account2.update_metadata()
|
||||||
|
|
||||||
|
|
||||||
@@ -1495,6 +1497,7 @@ class TestFile(Base):
|
|||||||
self.assertTrue(file_item.initialize())
|
self.assertTrue(file_item.initialize())
|
||||||
self.assertEqual(metadata, file_item.metadata)
|
self.assertEqual(metadata, file_item.metadata)
|
||||||
|
|
||||||
|
if not tf.skip2:
|
||||||
dest_cont = self.env.account2.container(Utils.create_name())
|
dest_cont = self.env.account2.container(Utils.create_name())
|
||||||
self.assertTrue(dest_cont.create(hdrs={
|
self.assertTrue(dest_cont.create(hdrs={
|
||||||
'X-Container-Write': self.env.conn.user_acl
|
'X-Container-Write': self.env.conn.user_acl
|
||||||
@@ -1559,6 +1562,8 @@ class TestFile(Base):
|
|||||||
Utils.create_name())
|
Utils.create_name())
|
||||||
|
|
||||||
def testCopyAccount404s(self):
|
def testCopyAccount404s(self):
|
||||||
|
if tf.skip2:
|
||||||
|
raise SkipTest('Account2 not set')
|
||||||
acct = self.env.conn.account_name
|
acct = self.env.conn.account_name
|
||||||
acct2 = self.env.conn2.account_name
|
acct2 = self.env.conn2.account_name
|
||||||
source_filename = Utils.create_name()
|
source_filename = Utils.create_name()
|
||||||
@@ -1686,6 +1691,8 @@ class TestFile(Base):
|
|||||||
self.assertEqual(metadata, file_item.metadata)
|
self.assertEqual(metadata, file_item.metadata)
|
||||||
|
|
||||||
def testCopyFromAccountHeader(self):
|
def testCopyFromAccountHeader(self):
|
||||||
|
if tf.skip2:
|
||||||
|
raise SkipTest('Account2 not set')
|
||||||
acct = self.env.conn.account_name
|
acct = self.env.conn.account_name
|
||||||
src_cont = self.env.account.container(Utils.create_name())
|
src_cont = self.env.account.container(Utils.create_name())
|
||||||
self.assertTrue(src_cont.create(hdrs={
|
self.assertTrue(src_cont.create(hdrs={
|
||||||
@@ -1761,6 +1768,8 @@ class TestFile(Base):
|
|||||||
self.assert_status(404)
|
self.assert_status(404)
|
||||||
|
|
||||||
def testCopyFromAccountHeader404s(self):
|
def testCopyFromAccountHeader404s(self):
|
||||||
|
if tf.skip2:
|
||||||
|
raise SkipTest('Account2 not set')
|
||||||
acct = self.env.conn2.account_name
|
acct = self.env.conn2.account_name
|
||||||
src_cont = self.env.account2.container(Utils.create_name())
|
src_cont = self.env.account2.container(Utils.create_name())
|
||||||
self.assertTrue(src_cont.create(hdrs={
|
self.assertTrue(src_cont.create(hdrs={
|
||||||
@@ -1805,6 +1814,8 @@ class TestFile(Base):
|
|||||||
self.assert_status(404)
|
self.assert_status(404)
|
||||||
|
|
||||||
def testCopyFromAccountHeader403s(self):
|
def testCopyFromAccountHeader403s(self):
|
||||||
|
if tf.skip2:
|
||||||
|
raise SkipTest('Account2 not set')
|
||||||
acct = self.env.conn2.account_name
|
acct = self.env.conn2.account_name
|
||||||
src_cont = self.env.account2.container(Utils.create_name())
|
src_cont = self.env.account2.container(Utils.create_name())
|
||||||
self.assertTrue(src_cont.create()) # Primary user has no access
|
self.assertTrue(src_cont.create()) # Primary user has no access
|
||||||
|
|||||||
Reference in New Issue
Block a user