From 0345664d2acf153acb24b14ce30ce89b82207577 Mon Sep 17 00:00:00 2001 From: zhangtingwei998 Date: Thu, 4 Jan 2024 20:52:41 +0800 Subject: [PATCH] update 3.23.12 --- src/obs/__init__.py | 1 + src/obs/client.py | 7 +++--- src/obs/const.py | 2 +- src/obs/convertor.py | 2 +- src/obs/crypto_client.py | 14 ++++++++++- src/obs/obs_cipher_suite.py | 15 ++++++++++- src/obs/posix_transfer.py | 11 ++++++++ src/obs/transfer.py | 5 ++-- src/obs/workflow.py | 1 + src/setup.py | 4 +-- src/tests/__init__.py | 14 ++++++++++- src/tests/conftest.py | 15 ++++++++++- src/tests/test_crypto_obs_client.py | 15 ++++++++++- src/tests/test_ctr_crypto_client.py | 14 ++++++++++- src/tests/test_obs_client.py | 39 ++++++++++++++++++++++++++++- src/tests/test_rsa_crypto_client.py | 15 ++++++++++- src/tests/test_util.py | 15 ++++++++++- 17 files changed, 170 insertions(+), 19 deletions(-) diff --git a/src/obs/__init__.py b/src/obs/__init__.py index ed7c25e..3fc9f7c 100644 --- a/src/obs/__init__.py +++ b/src/obs/__init__.py @@ -1,3 +1,4 @@ +#!/usr/bin/python # -*- coding:utf-8 -*- # Copyright 2019 Huawei Technologies Co.,Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use diff --git a/src/obs/client.py b/src/obs/client.py index 62f1487..9867502 100644 --- a/src/obs/client.py +++ b/src/obs/client.py @@ -1759,12 +1759,11 @@ def putFile(self, bucketName, objectKey, file_path, metadata=None, headers=None, metadata = dict() if _flag: - headers['contentLength'] = None - headers['md5'] = None - headers['contentType'] = None - results = [] for f in os.listdir(file_path): + headers['contentLength'] = None + headers['md5'] = None + headers['contentType'] = None f = util.safe_encode(f) __file_path = os.path.join(file_path, f) if not const.IS_PYTHON2: diff --git a/src/obs/const.py b/src/obs/const.py index d0682da..012ce77 100644 --- a/src/obs/const.py +++ b/src/obs/const.py @@ -96,7 +96,7 @@ DEFAULT_TASK_NUM = 8 DEFAULT_TASK_QUEUE_SIZE = 20000 -OBS_SDK_VERSION = '3.23.9' +OBS_SDK_VERSION = '3.23.12' V2_META_HEADER_PREFIX = 'x-amz-meta-' V2_HEADER_PREFIX = 'x-amz-' diff --git a/src/obs/convertor.py b/src/obs/convertor.py index 05feac0..8948569 100644 --- a/src/obs/convertor.py +++ b/src/obs/convertor.py @@ -54,7 +54,7 @@ class Adapter(object): OBS_ALLOWED_STORAGE_CLASS = ['STANDARD', 'WARM', 'COLD'] V2_ALLOWED_STORAGE_CLASS = ['STANDARD', 'STANDARD_IA', 'GLACIER'] - OBS_ALLOWED_GROUP = ['Everyone'] + OBS_ALLOWED_GROUP = ['Everyone','AuthenticatedUsers','LogDelivery'] V2_ALLOWED_GROUP = ['http://acs.amazonaws.com/groups/global/AllUsers', 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers', 'http://acs.amazonaws.com/groups/s3/LogDelivery'] diff --git a/src/obs/crypto_client.py b/src/obs/crypto_client.py index 89f5a47..308a0a0 100644 --- a/src/obs/crypto_client.py +++ b/src/obs/crypto_client.py @@ -1,4 +1,16 @@ -# coding:utf-8 +#!/usr/bin/python +# -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. import io diff --git a/src/obs/obs_cipher_suite.py b/src/obs/obs_cipher_suite.py index 9b39869..c4532ef 100644 --- a/src/obs/obs_cipher_suite.py +++ b/src/obs/obs_cipher_suite.py @@ -1,4 +1,17 @@ -# coding:utf-8 +#!/usr/bin/python +# -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + import binascii import hashlib import os diff --git a/src/obs/posix_transfer.py b/src/obs/posix_transfer.py index e297bf4..2e0cf70 100644 --- a/src/obs/posix_transfer.py +++ b/src/obs/posix_transfer.py @@ -1,5 +1,16 @@ #!/usr/bin/python # -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. from obs.ilog import DEBUG, ERROR, INFO from obs.model import DeleteObjectsRequest, Object diff --git a/src/obs/transfer.py b/src/obs/transfer.py index d69ad4d..076465b 100644 --- a/src/obs/transfer.py +++ b/src/obs/transfer.py @@ -7,12 +7,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 -import functools -import json # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. + +import functools +import json import math import operator import os diff --git a/src/obs/workflow.py b/src/obs/workflow.py index d9d1867..5d593d1 100644 --- a/src/obs/workflow.py +++ b/src/obs/workflow.py @@ -1,3 +1,4 @@ +#!/usr/bin/python # -*- coding:utf-8 -*- # Copyright 2019 Huawei Technologies Co.,Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use diff --git a/src/setup.py b/src/setup.py index d90a07f..a30c78c 100644 --- a/src/setup.py +++ b/src/setup.py @@ -21,7 +21,7 @@ setup( name='esdk-obs-python', - version='3.23.9', + version='3.23.12', packages=find_packages(exclude=['tests']), zip_safe=False, description='OBS Python SDK', @@ -29,7 +29,7 @@ license='Apache-2.0', keywords=('obs', 'python'), install_requires=[ - 'pycryptodome==3.10.1' + 'pycryptodome>=3.10.1' ], platforms='Independant', url='', diff --git a/src/tests/__init__.py b/src/tests/__init__.py index f512dea..487ad6f 100644 --- a/src/tests/__init__.py +++ b/src/tests/__init__.py @@ -1 +1,13 @@ -# coding:utf-8 +#!/usr/bin/python +# -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. \ No newline at end of file diff --git a/src/tests/conftest.py b/src/tests/conftest.py index aebc579..730ac47 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -1,4 +1,17 @@ -# coding:utf-8 +#!/usr/bin/python +# -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + import hashlib import json import os diff --git a/src/tests/test_crypto_obs_client.py b/src/tests/test_crypto_obs_client.py index 24971c3..21fc4be 100644 --- a/src/tests/test_crypto_obs_client.py +++ b/src/tests/test_crypto_obs_client.py @@ -1,4 +1,17 @@ -# coding:utf-8 +#!/usr/bin/python +# -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + import hashlib import io import os diff --git a/src/tests/test_ctr_crypto_client.py b/src/tests/test_ctr_crypto_client.py index 530e849..7c21e53 100644 --- a/src/tests/test_ctr_crypto_client.py +++ b/src/tests/test_ctr_crypto_client.py @@ -1,4 +1,16 @@ -# coding:utf-8 +#!/usr/bin/python +# -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. import pytest diff --git a/src/tests/test_obs_client.py b/src/tests/test_obs_client.py index 5b3bb5e..9861441 100644 --- a/src/tests/test_obs_client.py +++ b/src/tests/test_obs_client.py @@ -1,4 +1,17 @@ -# coding:utf-8 +#!/usr/bin/python +# -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + import io import os import random @@ -386,6 +399,30 @@ def test_uploadFile_with_metadata(self): assert meta_dict["meta_key1"] == "value1" assert meta_dict["meta_key-2"] == "value-2" + def test_putFile_with_content_type(self): + # 测试使用putFile上传文件夹content-Type是否前后一致 + client_type, uploadClient, downloadClient = self.get_client() + object_list = ['test.pdf', 'test.png', 'test.txt'] + old_content_list = ['application/pdf', 'image/png', 'text/plain'] + new_content_list = [] + folder_name = "test_putFile_with_content_type" + folder = test_config["path_prefix"] + folder_name + if not os.path.exists(folder): + os.makedirs(folder) + for f in object_list: + object_name = folder_name + '/' + f + conftest.gen_random_file(object_name, 1024) + + put_result = uploadClient.putFile(test_config["bucketName"], folder_name, folder) + for res in put_result: + assert res[1].status == 200 + object_metadata = uploadClient.getObjectMetadata(test_config["bucketName"], res[0]) + new_content_list.append(object_metadata.body.contentType) + + assert new_content_list == old_content_list + + + def test_setBucketLifecycle_and_getBucketLifecycle_success(self): client_type, bucketLifecycleClient, obsClient = self.get_client() rule1 = Rule(id='rule1', prefix='prefix1', status='Enabled', expiration=Expiration(days=60), diff --git a/src/tests/test_rsa_crypto_client.py b/src/tests/test_rsa_crypto_client.py index 04c2fb7..c18b82c 100644 --- a/src/tests/test_rsa_crypto_client.py +++ b/src/tests/test_rsa_crypto_client.py @@ -1,4 +1,17 @@ -# coding:utf-8 +#!/usr/bin/python +# -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + import pytest from obs import CryptoObsClient, CtrRSACipherGenerator diff --git a/src/tests/test_util.py b/src/tests/test_util.py index 2a966cc..ed0b1ed 100644 --- a/src/tests/test_util.py +++ b/src/tests/test_util.py @@ -1,4 +1,17 @@ -# coding:utf-8 +#!/usr/bin/python +# -*- coding:utf-8 -*- +# Copyright 2019 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + import os import random import unittest