This is an automated email from the ASF dual-hosted git repository. akitouni pushed a commit to branch abderrahim/downloadable-auth in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 59fc571739eb48c90b1ca4fcc67e78de70d7a215 Author: Abderrahim Kitouni <[email protected]> AuthorDate: Sun Apr 7 18:41:18 2024 +0100 fixup! tests: Added test for bearer authorization in DownloadableFileSource --- tests/sources/tar.py | 6 ++++-- tests/sources/tar/fetch/sourcemirrors/bearermirror.py | 15 +++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/sources/tar.py b/tests/sources/tar.py index 8712c77eb..2ba3833a3 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -392,8 +392,10 @@ def test_use_netrc_bearer_auth(cli, datafiles, tmpdir): { "name": "middle-earth", "kind": "bearermirror", - "aliases": { - "tmpdir": [server.base_url()], + "config": { + "aliases": { + "tmpdir": [server.base_url()], + }, }, }, ], diff --git a/tests/sources/tar/fetch/sourcemirrors/bearermirror.py b/tests/sources/tar/fetch/sourcemirrors/bearermirror.py index 54d930561..1acaa621d 100644 --- a/tests/sources/tar/fetch/sourcemirrors/bearermirror.py +++ b/tests/sources/tar/fetch/sourcemirrors/bearermirror.py @@ -4,15 +4,22 @@ from buildstream import SourceMirror, MappingNode class Sample(SourceMirror): - BST_MIN_VERSION = "2.0" + def configure(self, node): + node.validate_keys(["aliases"]) + + self.aliases = {} + + aliases = node.get_mapping("aliases") + for alias_name, url_list in aliases.items(): + self.aliases[alias_name] = url_list.as_str_list() + + self.set_supported_aliases(self.aliases.keys()) def translate_url( self, *, - project_name: str, alias: str, alias_url: str, - alias_substitute_url: Optional[str], source_url: str, extra_data: Optional[Dict[str, Any]], ) -> str: @@ -20,7 +27,7 @@ class Sample(SourceMirror): if extra_data is not None: extra_data["auth-header-format"] = "Bearer {password}" - return alias_substitute_url + source_url + return self.aliases[alias][0] + source_url # Plugin entry point
