-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that incoming request to set_bucket_policy() is of type str #685
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smouli, travis failures need to be fixed
{"function": "set_bucket_policy(bucket_name, policy)", "status": "FAIL", "name": "minio-py:test_set_bucket_policy_readonly", "args": {"bucket_name": "minio-py-test-15715cb4-91e4-4707-ac7d-e92b9ee49723"}, "error": "Traceback (most recent call last):\n File \"tests/functional/tests.py\", line 1806, in main\n test_set_bucket_policy_readonly(client, log_output)\n File \"tests/functional/tests.py\", line 1527, in test_set_bucket_policy_readonly\n raise Exception(err)\nException: policy can only be of type str\n", "duration": 160, "message": "policy can only be of type str"}
minio/api.py
Outdated
@@ -382,14 +382,15 @@ def delete_bucket_policy(self, bucket_name): | |||
bucket_name=bucket_name, | |||
query={"policy": ""}) | |||
|
|||
def set_bucket_policy(self, bucket_name, policy): | |||
def set_bucket_policy(self, bucket_name, policy): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the space added by mistake at the end of the line.
minio/helpers.py
Outdated
@@ -375,6 +375,19 @@ def is_non_empty_string(input_string): | |||
|
|||
return True | |||
|
|||
def is_valid_bucket_policy_name(policy): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function name is_valid_bucket_policy_name
is misleading, since we are not validating the name of the policy.
Change the function name something like is_valid_type_bucket_policy
.
minio/helpers.py
Outdated
Validates bucket policy | ||
:param policy: S3 style Bucket policy. | ||
:return: True if input is a valid policy structure. | ||
Raise :exc: `TypeError` otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is :exc:
?
minio/helpers.py
Outdated
""" | ||
Validates bucket policy | ||
:param policy: S3 style Bucket policy. | ||
:return: True if input is a valid policy structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:return: True if input is a valid policy structure.
=>
:return: True if policy parameter is of a valid type, 'string'.
We also need to change the documentation and examples. |
81e9d51
to
aab1683
Compare
@poornas I fixed travis failures |
minio/api.py
Outdated
@@ -389,6 +389,7 @@ def set_bucket_policy(self, bucket_name, policy): | |||
:param bucket_name: Bucket name. | |||
:param policy: Access policy/ies in JSON format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON format
=> string format
minio/api.py
Outdated
@@ -389,6 +389,7 @@ def set_bucket_policy(self, bucket_name, policy): | |||
:param bucket_name: Bucket name. | |||
:param policy: Access policy/ies in JSON format. | |||
""" | |||
is_valid_bucket_type_policy(policy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_valid_bucket_policy_type would be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about is_valid_policy_type as @ebozduman suggested
aab1683
to
4d5fd71
Compare
@@ -375,6 +375,23 @@ def is_non_empty_string(input_string): | |||
|
|||
return True | |||
|
|||
def is_valid_bucket_type_policy(policy): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_valid_bucket_type_policy
=> is_valid_policy_type
Raise :exc:`TypeError` otherwise. | ||
""" | ||
if _is_py3: | ||
string_types = str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment:
string_types
=> string_type
4d5fd71
to
e64a3c2
Compare
I made a mistake and have to close this PR. The new PR is #687 |
No description provided.