Uh oh!
There was an error while loading. Please reload this page.
Enable anonymous access to blobs in public buckets - #4315
Conversation
dhermes
left a comment
There was a problem hiding this comment.
@lukesneeringer@jskeet Do we expect list_blobs() to be dependable on the gcp-public-data-landsat? (i.e. could we add a system test for that).
@tseaver Don't you need more tests for methods that do and should fail?
| 'google-cloud-core >= 0.28.0, < 0.29dev', | ||
| 'google-api-core >= 0.1.1, < 0.2.0dev', | ||
| 'google-auth >= 1.0.0', | ||
| 'google-auth >= 1.2.0', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| :rtype: :class:`google.cloud.storage.client.Client` | ||
| :returns: Instance w/ anonymous credentials and no project. | ||
| """ | ||
| client = cls(project='<none>', credentials=AnonymousCredentials()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| anonymous = storage.Client.create_anonymous_client() | ||
| bucket = anonymous.bucket(self.PUBLIC_BUCKET) | ||
| for blob in bucket.list_blobs(): | ||
| print("Downloading blob: {}".format(blob.name)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| print("Downloading blob: {}".format(blob.name)) | ||
| with tempfile.TemporaryFile() as stream: | ||
| blob.download_to_file(stream) | ||
| break # just use the first one |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| for blob in bucket.list_blobs(): | ||
| print("Downloading blob: {}".format(blob.name)) | ||
| with tempfile.TemporaryFile() as stream: | ||
| blob.download_to_file(stream) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
tseaver
commented
Nov 1, 2017
The back-end enforces the policy by raising 401s: why bother testing them? |
dhermes
commented
Nov 1, 2017
I sympathize with the sentiment, but am just weary of the cases we haven't thought about. |
| with tempfile.TemporaryFile() as stream: | ||
| blob.download_to_file(stream) | ||
| break # just use the first one | ||
| blob, = list(bucket.list_blobs(max_results=1)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| :rtype: :class:`google.cloud.storage.client.Client` | ||
| :returns: Instance w/ anonymous credentials and no project. | ||
| """ | ||
| client = cls(project='<none>', credentials=AnonymousCredentials()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| @classmethod | ||
| def create_anonymous_client(cls): | ||
| """Factory: return client w/ anonymous credentials. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self.assertIsInstance(client._connection, Connection) | ||
| self.assertIsInstance( | ||
| client._connection.credentials, AnonymousCredentials) | ||
| self.assertIsNone(client.current_batch) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
lukesneeringer
commented
Nov 6, 2017
@dhermes Apparently...
...but only on Windows. |
tseaver
commented
Nov 6, 2017
@dhermes, @lukesneeringer That spelling is correct according to PEP 440. We could try |
ed35ccc to
9c685f1Comparetseaver
commented
Nov 6, 2017
Rebased / semi-squashed to fix Appveyor, tidy up. |
dhermes
commented
Nov 6, 2017
The AppVeyor issue was fixed in #4313 (I just removed |
tseaver
commented
Nov 6, 2017
@dhermes Yup, that was why I rebased on current master. |
tseaver
commented
Nov 6, 2017
AFAIK, this PR is ready to merge once CI is green. |
/cc @jskeet
Closes#4279