Skip to content

Commit 113a6a1

Browse files
committed
Add support for anonymous gcs file source access
1 parent 6894b63 commit 113a6a1

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

lib/galaxy/files/sources/googlecloudstorage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ def _open_fs(self, user_context):
1919
root_path = props.pop('root_path', None)
2020
project = props.pop('project', None)
2121
args = {}
22-
if props.get('token'):
22+
if props.get('anonymous'):
23+
args['client'] = Client.create_anonymous_client()
24+
elif props.get('token'):
2325
args['client'] = Client(project=project, credentials=Credentials(**props))
2426
handle = GCSFS(bucket_name, root_path=root_path, retry=0, **args)
2527
return handle
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pytest
2+
fs-gcsfs

test/unit/files/gcsfs_file_sources_conf.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
id: test1
33
doc: Test access to Google Cloud Storage.
44
project: ${user.preferences['googlecloudstorage|project']}
5-
bucket_name: ${user.preferences['googlecloudstorage|bucket_name']}
5+
bucket_name: 'genomics-public-data'
66
token_uri: "https://www.googleapis.com/oauth2/v4/token"
77
client_id: ${user.preferences['googlecloudstorage|client_id']}
88
client_secret: ${user.preferences['googlecloudstorage|client_secret']}
99
token: ${user.preferences['googlecloudstorage|access_token']}
1010
refresh_token: ${user.preferences['googlecloudstorage|refresh_token']}
11+
anonymous: true

test/unit/files/test_gcsfs.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import os
22

3-
import pytest
4-
53
from galaxy.files import ConfiguredFileSources, ConfiguredFileSourcesConfig
64
from ._util import (
75
assert_realizes_contains,
@@ -11,16 +9,7 @@
119
SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
1210
FILE_SOURCES_CONF = os.path.join(SCRIPT_DIRECTORY, "gcsfs_file_sources_conf.yml")
1311

14-
skip_if_no_gcs_access_token = pytest.mark.skipif(
15-
not os.environ.get('GALAXY_TEST_GCS_PROJECT')
16-
or not os.environ.get('GALAXY_TEST_GCS_BUCKET')
17-
or not os.environ.get('GALAXY_TEST_GCS_ACCESS_TOKEN')
18-
or not os.environ.get('GALAXY_TEST_GCS_REFRESH_TOKEN'),
19-
reason="GALAXY_TEST_GCS_ACCESS_TOKEN and related vars not set"
20-
)
21-
2212

23-
@skip_if_no_gcs_access_token
2413
def test_file_source():
2514
user_context = user_context_fixture()
2615
file_sources = _configured_file_sources()

0 commit comments

Comments
 (0)