# check that object not exists in destination bucket
e = assert_raises(ClientError, dest.s3_client.get_object, Bucket=dest_bucket.name, Key=objname)
assert e.response['Error']['Code'] == 'NoSuchKey'
-
-@allow_bucket_replication
-def test_bucket_replication_lock_enabled_to_lock_disabled():
- zonegroup = realm.master_zonegroup()
- zonegroup_conns = ZonegroupConns(zonegroup)
-
- source = zonegroup_conns.non_account_rw_zones[0]
- dest = zonegroup_conns.non_account_rw_zones[1]
-
- source_bucket_name = gen_bucket_name()
- source.create_bucket(source_bucket_name)
- # enabled versioning
- source.s3_client.put_bucket_versioning(
- Bucket=source_bucket_name,
- VersioningConfiguration={'Status': 'Enabled'}
- )
- dest_bucket = dest.create_bucket(gen_bucket_name())
- # enabled versioning
- dest.s3_client.put_bucket_versioning(
- Bucket=dest_bucket.name,
- VersioningConfiguration={'Status': 'Enabled'}
- )
- zonegroup_meta_checkpoint(zonegroup)
-
- # create replication configuration
- source.s3_client.put_bucket_replication(
- Bucket=source_bucket_name,
- ReplicationConfiguration={
- 'Role': '',
- 'Rules': [{
- 'ID': 'rule1',
- 'Status': 'Enabled',
- 'Destination': {
- 'Bucket': f'arn:aws:s3:::{dest_bucket.name}',
- }
- }]
- }
- )
- zonegroup_meta_checkpoint(zonegroup)
-
- # enable object lock on source bucket
- source.s3_client.put_object_lock_configuration(
- Bucket=source_bucket_name,
- ObjectLockConfiguration={
- 'ObjectLockEnabled': 'Enabled',
- 'Rule': {
- 'DefaultRetention': {
- 'Mode': 'GOVERNANCE',
- 'Days': 1
- }
- }
- }
- )
- zonegroup_meta_checkpoint(zonegroup)
-
- # upload an object and wait for sync.
- objname = 'dummy'
- k = new_key(source, source_bucket_name, objname)
- k.set_contents_from_string('foo')
- zone_data_checkpoint(dest.zone, source.zone)
-
- # check that object does not exist in destination bucket
- e = assert_raises(ClientError, dest.s3_client.get_object, Bucket=dest_bucket.name, Key=objname)
- assert e.response['Error']['Code'] == 'NoSuchKey'
-
-@allow_bucket_replication
-def test_bucket_replication_lock_disabled_to_lock_enabled():
- zonegroup = realm.master_zonegroup()
- zonegroup_conns = ZonegroupConns(zonegroup)
-
- source = zonegroup_conns.non_account_rw_zones[0]
- dest = zonegroup_conns.non_account_rw_zones[1]
-
- source_bucket = source.create_bucket(gen_bucket_name())
- # enabled versioning
- source.s3_client.put_bucket_versioning(
- Bucket=source_bucket.name,
- VersioningConfiguration={'Status': 'Enabled'}
- )
- dest_bucket_name = gen_bucket_name()
- dest.create_bucket(dest_bucket_name)
- # enabled versioning
- dest.s3_client.put_bucket_versioning(
- Bucket=dest_bucket_name,
- VersioningConfiguration={'Status': 'Enabled'}
- )
- zonegroup_meta_checkpoint(zonegroup)
-
- # create replication configuration
- source.s3_client.put_bucket_replication(
- Bucket=source_bucket.name,
- ReplicationConfiguration={
- 'Role': '',
- 'Rules': [{
- 'ID': 'rule1',
- 'Status': 'Enabled',
- 'Destination': {
- 'Bucket': f'arn:aws:s3:::{dest_bucket_name}',
- }
- }]
- }
- )
- zonegroup_meta_checkpoint(zonegroup)
-
- # enable object lock on destination bucket
- dest.s3_client.put_object_lock_configuration(
- Bucket=dest_bucket_name,
- ObjectLockConfiguration={
- 'ObjectLockEnabled': 'Enabled',
- 'Rule': {
- 'DefaultRetention': {
- 'Mode': 'GOVERNANCE',
- 'Days': 1
- }
- }
- }
- )
- zonegroup_meta_checkpoint(zonegroup)
-
- # upload an object and wait for sync.
- objname = 'dummy'
- k = new_key(source, source_bucket.name, objname)
- k.set_contents_from_string('foo')
- zone_data_checkpoint(dest.zone, source.zone)
-
- # check that object does not exist in destination bucket
- e = assert_raises(ClientError, dest.s3_client.get_object, Bucket=dest_bucket_name, Key=objname)
- assert e.response['Error']['Code'] == 'NoSuchKey'