tests: Let func tests run with test users 1 and 2 but not 3

Change-Id: Ia564f2ee70f5d04acab1c38e17d1936642a01447
This commit is contained in:
Tim Burke 2023-03-10 13:56:34 -08:00
parent 049ffd5a89
commit 78f13be75c

View File

@ -561,44 +561,46 @@ class TestObjectVersioning(Base):
break break
self.assertEqual(backup_file.read(), b"never argue with the data") self.assertEqual(backup_file.read(), b"never argue with the data")
# user3 (some random user with no access to any of account1) if not tf.skip3:
# tries to read from versioned container # user3 (some random user with no access to any of account1)
self.assertRaises(ResponseError, backup_file.read, # tries to read from versioned container
cfg={'use_token': self.env.storage_token3}) self.assertRaises(ResponseError, backup_file.read,
cfg={'use_token': self.env.storage_token3})
# create an object user3 can try to copy # create an object user3 can try to copy
a2_container = self.env.account2.container(Utils.create_name()) a2_container = self.env.account2.container(Utils.create_name())
a2_container.create( a2_container.create(
hdrs={'X-Container-Read': self.env.conn3.user_acl}, hdrs={'X-Container-Read': self.env.conn3.user_acl},
cfg={'use_token': self.env.storage_token2}) cfg={'use_token': self.env.storage_token2})
a2_obj = a2_container.file(Utils.create_name()) a2_obj = a2_container.file(Utils.create_name())
self.assertTrue(a2_obj.write(b"unused", self.assertTrue(a2_obj.write(b"unused",
cfg={'use_token': self.env.storage_token2})) cfg={'use_token': self.env.storage_token2}))
# user3 cannot write, delete, or copy to/from source container either # user3 also cannot write, delete, or copy to/from source container
number_of_versions = versions_container.info()['object_count'] number_of_versions = versions_container.info()['object_count']
self.assertRaises(ResponseError, versioned_obj.write, self.assertRaises(ResponseError, versioned_obj.write,
b"some random user trying to write data", b"some random user trying to write data",
cfg={'use_token': self.env.storage_token3}) cfg={'use_token': self.env.storage_token3})
self.assertEqual(number_of_versions, self.assertEqual(number_of_versions,
versions_container.info()['object_count']) versions_container.info()['object_count'])
self.assertRaises(ResponseError, versioned_obj.delete, self.assertRaises(ResponseError, versioned_obj.delete,
cfg={'use_token': self.env.storage_token3}) cfg={'use_token': self.env.storage_token3})
self.assertEqual(number_of_versions, self.assertEqual(number_of_versions,
versions_container.info()['object_count']) versions_container.info()['object_count'])
self.assertRaises( self.assertRaises(
ResponseError, versioned_obj.write, ResponseError, versioned_obj.write,
hdrs={'X-Copy-From': '%s/%s' % (a2_container.name, a2_obj.name), hdrs={
'X-Copy-From-Account': self.env.conn2.account_name}, 'X-Copy-From': '%s/%s' % (a2_container.name, a2_obj.name),
cfg={'use_token': self.env.storage_token3}) 'X-Copy-From-Account': self.env.conn2.account_name},
self.assertEqual(number_of_versions, cfg={'use_token': self.env.storage_token3})
versions_container.info()['object_count']) self.assertEqual(number_of_versions,
self.assertRaises( versions_container.info()['object_count'])
ResponseError, a2_obj.copy_account, self.assertRaises(
self.env.conn.account_name, container.name, obj_name, ResponseError, a2_obj.copy_account,
cfg={'use_token': self.env.storage_token3}) self.env.conn.account_name, container.name, obj_name,
self.assertEqual(number_of_versions, cfg={'use_token': self.env.storage_token3})
versions_container.info()['object_count']) self.assertEqual(number_of_versions,
versions_container.info()['object_count'])
# user2 can't read or delete from versions-location # user2 can't read or delete from versions-location
self.assertRaises(ResponseError, backup_file.read, self.assertRaises(ResponseError, backup_file.read,
@ -615,7 +617,8 @@ class TestObjectVersioning(Base):
# tear-down since we create these containers here # tear-down since we create these containers here
# and not in self.env # and not in self.env
a2_container.delete_recursive() if not tf.skip3:
a2_container.delete_recursive()
versions_container.delete_recursive() versions_container.delete_recursive()
container.delete_recursive() container.delete_recursive()