Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: third_party/gsutil/gslib/tests/test_defacl.py

Issue 1380943003: Roll version of gsutil to 4.15. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/gsutil/gslib/tests/test_cp.py ('k') | third_party/gsutil/gslib/tests/test_hash.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # Copyright 2013 Google Inc. All Rights Reserved. 2 # Copyright 2013 Google Inc. All Rights Reserved.
3 # 3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License. 5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at 6 # You may obtain a copy of the License at
7 # 7 #
8 # http://www.apache.org/licenses/LICENSE-2.0 8 # http://www.apache.org/licenses/LICENSE-2.0
9 # 9 #
10 # Unless required by applicable law or agreed to in writing, software 10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, 11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and 13 # See the License for the specific language governing permissions and
14 # limitations under the License. 14 # limitations under the License.
15 """Integration tests for the defacl command.""" 15 """Integration tests for the defacl command."""
16 16
17 from __future__ import absolute_import 17 from __future__ import absolute_import
18 18
19 import os
20 import re 19 import re
20
21 from gslib.cs_api_map import ApiSelector
21 import gslib.tests.testcase as case 22 import gslib.tests.testcase as case
22 from gslib.tests.testcase.integration_testcase import SkipForS3 23 from gslib.tests.testcase.integration_testcase import SkipForS3
23 from gslib.tests.util import ObjectToURI as suri 24 from gslib.tests.util import ObjectToURI as suri
24 25
25 PUBLIC_READ_JSON_ACL_TEXT = '"entity":"allUsers","role":"READER"' 26 PUBLIC_READ_JSON_ACL_TEXT = '"entity":"allUsers","role":"READER"'
26 27
27 28
28 @SkipForS3('S3 does not support default object ACLs.') 29 @SkipForS3('S3 does not support default object ACLs.')
29 class TestDefacl(case.GsUtilIntegrationTestCase): 30 class TestDefacl(case.GsUtilIntegrationTestCase):
30 """Integration tests for the defacl command.""" 31 """Integration tests for the defacl command."""
(...skipping 30 matching lines...) Expand all
61 json_text3 = self.RunGsUtil(self._defacl_get_prefix + 62 json_text3 = self.RunGsUtil(self._defacl_get_prefix +
62 [suri(bucket)], return_stdout=True) 63 [suri(bucket)], return_stdout=True)
63 self.assertRegexpMatches(json_text3, test_regex2) 64 self.assertRegexpMatches(json_text3, test_regex2)
64 65
65 stderr = self.RunGsUtil(self._defacl_ch_prefix + 66 stderr = self.RunGsUtil(self._defacl_ch_prefix +
66 ['-g', self.GROUP_TEST_ADDRESS+':WRITE', 67 ['-g', self.GROUP_TEST_ADDRESS+':WRITE',
67 suri(bucket)], 68 suri(bucket)],
68 return_stderr=True, expected_status=1) 69 return_stderr=True, expected_status=1)
69 self.assertIn('WRITER cannot be set as a default object ACL', stderr) 70 self.assertIn('WRITER cannot be set as a default object ACL', stderr)
70 71
71 def testChangeDefaultAclPrivate(self): 72 def testChangeDefaultAclEmpty(self):
73 """Tests adding and removing an entry from an empty default object ACL."""
74
72 bucket = self.CreateBucket() 75 bucket = self.CreateBucket()
73 test_regex = self._MakeScopeRegex( 76
74 'READER', 'group', self.GROUP_TEST_ADDRESS) 77 # First, clear out the default object ACL on the bucket.
75 self.RunGsUtil(self._defacl_set_prefix + ['private', suri(bucket)]) 78 self.RunGsUtil(self._defacl_set_prefix + ['private', suri(bucket)])
76 json_text = self.RunGsUtil(self._defacl_get_prefix + 79 json_text = self.RunGsUtil(self._defacl_get_prefix +
77 [suri(bucket)], return_stdout=True) 80 [suri(bucket)], return_stdout=True)
78 self.assertRegexpMatches(json_text, r'\[\]\s*') 81 empty_regex = r'\[\]\s*'
82 self.assertRegexpMatches(json_text, empty_regex)
79 83
84 group_regex = self._MakeScopeRegex(
85 'READER', 'group', self.GROUP_TEST_ADDRESS)
80 self.RunGsUtil(self._defacl_ch_prefix + 86 self.RunGsUtil(self._defacl_ch_prefix +
81 ['-g', self.GROUP_TEST_ADDRESS+':READ', suri(bucket)]) 87 ['-g', self.GROUP_TEST_ADDRESS+':READ', suri(bucket)])
82 json_text2 = self.RunGsUtil(self._defacl_get_prefix + 88 json_text2 = self.RunGsUtil(self._defacl_get_prefix +
83 [suri(bucket)], return_stdout=True) 89 [suri(bucket)], return_stdout=True)
84 self.assertRegexpMatches(json_text2, test_regex) 90 self.assertRegexpMatches(json_text2, group_regex)
91
92 if self.test_api == ApiSelector.JSON:
93 # TODO: Enable when JSON service respects creating a private (no entries)
94 # default object ACL via PATCH. For now, only supported in XML.
95 return
96
97 # After adding and removing a group, the default object ACL should be empty.
98 self.RunGsUtil(self._defacl_ch_prefix +
99 ['-d', self.GROUP_TEST_ADDRESS, suri(bucket)])
100 json_text3 = self.RunGsUtil(self._defacl_get_prefix +
101 [suri(bucket)], return_stdout=True)
102 self.assertRegexpMatches(json_text3, empty_regex)
85 103
86 def testChangeMultipleBuckets(self): 104 def testChangeMultipleBuckets(self):
87 """Tests defacl ch on multiple buckets.""" 105 """Tests defacl ch on multiple buckets."""
88 bucket1 = self.CreateBucket() 106 bucket1 = self.CreateBucket()
89 bucket2 = self.CreateBucket() 107 bucket2 = self.CreateBucket()
90 108
91 test_regex = self._MakeScopeRegex( 109 test_regex = self._MakeScopeRegex(
92 'READER', 'group', self.GROUP_TEST_ADDRESS) 110 'READER', 'group', self.GROUP_TEST_ADDRESS)
93 json_text = self.RunGsUtil(self._defacl_get_prefix + [suri(bucket1)], 111 json_text = self.RunGsUtil(self._defacl_get_prefix + [suri(bucket1)],
94 return_stdout=True) 112 return_stdout=True)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 196
179 # Neither arguments nor subcommand. 197 # Neither arguments nor subcommand.
180 stderr = self.RunGsUtil(['defacl'], return_stderr=True, expected_status=1) 198 stderr = self.RunGsUtil(['defacl'], return_stderr=True, expected_status=1)
181 self.assertIn('command requires at least', stderr) 199 self.assertIn('command requires at least', stderr)
182 200
183 201
184 class TestDefaclOldAlias(TestDefacl): 202 class TestDefaclOldAlias(TestDefacl):
185 _defacl_ch_prefix = ['chdefacl'] 203 _defacl_ch_prefix = ['chdefacl']
186 _defacl_get_prefix = ['getdefacl'] 204 _defacl_get_prefix = ['getdefacl']
187 _defacl_set_prefix = ['setdefacl'] 205 _defacl_set_prefix = ['setdefacl']
OLDNEW
« no previous file with comments | « third_party/gsutil/gslib/tests/test_cp.py ('k') | third_party/gsutil/gslib/tests/test_hash.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698