cubefs

Форк
0
/
test_acl.py 
58 строк · 1.8 Кб
1
# Copyright 2020 The CubeFS Authors.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
# implied. See the License for the specific language governing
13
# permissions and limitations under the License.
14

15
# -*- coding: utf-8 -*-
16
import json
17
import requests
18
import env
19
from base import S3TestCase, get_env_s3_client
20

21

22

23
class AclTest(S3TestCase):
24
    s3 = None
25

26
    def __init__(self, case):
27
        super(AclTest, self).__init__(case)
28
        self.s3 = get_env_s3_client()
29

30
    def test_bucket_acl(self):
31
        resp = requests.get(
32
            url=env.MASTER + '/client/vol?name=%s' % env.BUCKET,
33
            headers={
34
                'Skip-Owner-Validation': 'true'
35
            })
36
        content = json.loads(resp.content.decode())
37
        OWNER = content['data']['Owner']
38
        ACL = {
39
            'Grants': [
40
                {
41
                    'Grantee': {
42
                        'ID': OWNER,
43
                        'Type': 'CanonicalUser'
44
                    },
45
                    'Permission': 'FULL_CONTROL'
46
                },
47
            ],
48
            'Owner': {
49
                'DisplayName': '',
50
                'ID': OWNER
51
            }
52
        }
53
        # Put bucket acl configuration
54
        self.assert_result_status_code(
55
            result=self.s3.put_bucket_acl(Bucket=env.BUCKET, AccessControlPolicy=ACL))
56
        # Get bucket acl configuration
57
        self.assert_get_bucket_acl_result(
58
            result=self.s3.get_bucket_acl(Bucket=env.BUCKET), acl=ACL)
59

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.