Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9696548
D8752.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D8752.diff
View Options
diff --git a/swh/lister/gitea/lister.py b/swh/lister/gitea/lister.py
--- a/swh/lister/gitea/lister.py
+++ b/swh/lister/gitea/lister.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2021 The Software Heritage developers
+# Copyright (C) 2018-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
@@ -20,8 +20,3 @@
accessible at https://try.gitea.io/api/v1/ and https://codeberg.org/api/v1/."""
LISTER_NAME = "gitea"
-
- def on_anonymous_mode(self):
- logger.warning(
- "No authentication token set in configuration, using anonymous mode"
- )
diff --git a/swh/lister/gogs/lister.py b/swh/lister/gogs/lister.py
--- a/swh/lister/gogs/lister.py
+++ b/swh/lister/gogs/lister.py
@@ -50,10 +50,15 @@
Gogs API documentation: https://github.com/gogs/docs-api
- The API is protected behind authentication so credentials/API tokens
- are mandatory. It supports pagination and provides next page URL
- through the 'next' value of the 'Link' header. The default value for
- page size ('limit') is 10 but the maximum allowed value is 50.
+ The API may be protected behind authentication so credentials/API tokens can be
+ provided.
+
+ The lister supports pagination and provides next page URL through the 'next' value
+ of the 'Link' header. The default value for page size ('limit') is 10 but the
+ maximum allowed value is 50.
+
+ Api can usually be found at the location: https://<host>/api/v1/repos/search
+
"""
LISTER_NAME = "gogs"
@@ -90,17 +95,15 @@
username = cred.get("username")
self.api_token = cred["password"]
logger.info("Using authentication credentials from user %s", username)
- else:
- # Raises an error on Gogs, or a warning on Gitea
- self.on_anonymous_mode()
self.session.headers.update({"Accept": "application/json"})
if self.api_token:
self.session.headers["Authorization"] = f"token {self.api_token}"
-
- def on_anonymous_mode(self):
- raise ValueError("No credentials or API token provided")
+ else:
+ logger.warning(
+ "No authentication token set in configuration, using anonymous mode"
+ )
def state_from_dict(self, d: Dict[str, Any]) -> GogsListerState:
return GogsListerState(**d)
@@ -153,7 +156,6 @@
while next_link is not None:
repos = self.extract_repos(body)
- assert len(links) > 0, "API changed: no Link header found"
if "next" in links:
next_link = links["next"]["url"]
else:
diff --git a/swh/lister/gogs/tests/test_lister.py b/swh/lister/gogs/tests/test_lister.py
--- a/swh/lister/gogs/tests/test_lister.py
+++ b/swh/lister/gogs/tests/test_lister.py
@@ -139,16 +139,16 @@
def test_gogs_auth_instance(
swh_scheduler, requests_mock, trygogs_p1, trygogs_p2, trygogs_p3_empty
):
- """Covers token authentication, token from credentials,
+ """Covers without authentication, token authentication, token from credentials,
instance inference from URL."""
api_token = "secret"
instance = "try_gogs"
# Test lister initialization without api_token or credentials:
- with pytest.raises(ValueError, match="No credentials or API token provided"):
- kwargs1 = dict(url=TRY_GOGS_URL, instance=instance)
- GogsLister(scheduler=swh_scheduler, **kwargs1)
+ kwargs1 = dict(url=TRY_GOGS_URL, instance=instance)
+ lister = GogsLister(scheduler=swh_scheduler, **kwargs1)
+ assert "Authorization" not in lister.session.headers
# Test lister initialization using api_token:
kwargs2 = dict(url=TRY_GOGS_URL, api_token=api_token, instance=instance)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Aug 17, 8:33 PM (23 h, 8 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3223506
Attached To
D8752: gogs/lister: Allow public gogs instance listing
Event Timeline
Log In to Comment