Skip to content

Commit

Permalink
Fixing test_bucket_acl tests. eucalyptus#377
Browse files Browse the repository at this point in the history
  • Loading branch information
Lincoln P. Thomas committed Nov 18, 2015
1 parent b373692 commit b8df7e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
3 changes: 2 additions & 1 deletion eucaops/s3ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def get_canned_acl(self, canned_acl=None, bucket_owner_id=None, bucket_owner_dis
built_acl.add_grant(Grant(permission="READ",type='Group',uri=self.s3_groups["authenticated_users"]))
elif canned_acl == "log-delivery-write":
built_acl.add_grant(Grant(permission="WRITE",type='Group',uri=self.s3_groups["log_delivery"]))
built_acl.add_grant(Grant(permission="READ_ACP",type='Group',uri=self.s3_groups["log_delivery"]))
elif canned_acl == "bucket-owner-read":
if bucket_owner_id is None:
raise Exception("No bucket_owner_id passed when trying to create bucket-owner-read canned acl ")
Expand Down Expand Up @@ -576,4 +577,4 @@ def show_buckets(self, buckets=None, format_size=True, printme=True):
if printme:
self.debug("\n{0}\n".format(str(main_table)))
else:
return main_table
return main_table
55 changes: 27 additions & 28 deletions testcases/cloud_user/s3/bucket_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,35 +160,34 @@ def test_bucket_acl(self):
owner_id = policy.acl.grants[0].id

#upload a new acl for the bucket
new_acl = policy
new_user_display_name = owner_display_name
new_user_id = owner_id
new_acl.acl.add_user_grant(permission="READ", user_id=new_user_id, display_name=new_user_display_name)
try:
acl_bucket.set_acl(new_acl)
acl_check = acl_bucket.get_acl()
except S3ResponseError:
self.fail("Failed to set or get new acl")

self.tester.info( "Got ACL: " + acl_check.acl.to_xml() )

#expected_result_base='<AccessControlList>
#<Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
#<ID>' + owner_id + '</ID><DisplayName>'+ owner_display_name + '</DisplayName></Grantee><Permission>FULL_CONTROL</Permission></Grant>
#<Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>EXPECTED_ID</ID><DisplayName>EXPECTED_NAME</DisplayName></Grantee><Permission>READ</Permission></Grant>
#</AccessControlList>'

if acl_check == None or not self.tester.check_acl_equivalence(acl1=acl_check.acl, acl2=new_acl.acl):
self.tester.s3.delete_bucket(test_bucket)
self.fail("Incorrect acl length or acl not found\n. Got bucket ACL:\n" + acl_check.acl.to_xml() + "\nExpected:" + new_acl.acl.to_xml())
else:
self.tester.info("Got expected basic ACL addition")

self.tester.info( "Grants 0 and 1: " + acl_check.acl.grants[0].to_xml() + " -- " + acl_check.acl.grants[1].to_xml() )
# Commented out this test because Euca, AWS West, and AWS East
# all update the grants differently.
# Regardless, nothing changes functionally, owner always retains full control.
# So it's not a very useful test anyway.
#new_acl = policy
#new_user_display_name = owner_display_name
#new_user_id = owner_id
#new_acl.acl.add_user_grant(permission="READ", user_id=new_user_id, display_name=new_user_display_name)
#try:
# acl_bucket.set_acl(new_acl)
# acl_check = acl_bucket.get_acl()
#except S3ResponseError:
# self.fail("Failed to set or get new acl")
#
#self.tester.info( "Got ACL: " + acl_check.acl.to_xml() )
#
#if acl_check == None or not self.tester.check_acl_equivalence(acl1=acl_check.acl, acl2=new_acl.acl):
# self.tester.s3.delete_bucket(test_bucket)
# self.fail("Incorrect acl length or acl not found\n. Got bucket ACL:\n" + acl_check.acl.to_xml() + "\nExpected:" + new_acl.acl.to_xml())
#else:
# self.tester.info("Got expected basic ACL addition")
#
#self.tester.info( "Grants 0 and 1: " + acl_check.acl.grants[0].to_xml() + " -- " + acl_check.acl.grants[1].to_xml() )

#Check each canned ACL string in boto to make sure Walrus does it right
for acl in boto.s3.acl.CannedACLStrings:
if acl == "authenticated-read":
#The bucket-owner-* canned ACLs apply only to objects, not buckets
if acl == "bucket-owner-read" or acl == "bucket-owner-full-control":
continue
self.tester.info('Testing canned acl: ' + acl)
try:
Expand Down Expand Up @@ -595,7 +594,7 @@ def clean_method(self):
testcase = BucketTestSuite()
### Either use the list of tests passed from config/command line to determine what subset of tests to run
list = testcase.args.tests or [ 'test_bucket_get_put_delete', \
#'test_bucket_acl', \ FAILING AS OF 3.3.1
'test_bucket_acl', \
'test_bucket_key_list_delim_prefix', \
'test_bucket_key_listing_paging', \
'test_bucket_location', \
Expand All @@ -607,4 +606,4 @@ def clean_method(self):
### Run the EutesterUnitTest objects

result = testcase.run_test_case_list(unit_list,clean_on_exit=True)
exit(result)
exit(result)

0 comments on commit b8df7e4

Please sign in to comment.