Once a save request has been accepted, you can follow its current status in the
submitted save requests list.
+
+ If you submitted requests while being authenticated, you will be able
+ to only display your requests.
diff --git a/swh/web/tests/create_test_admin.py b/swh/web/tests/create_test_users.py
rename from swh/web/tests/create_test_admin.py
rename to swh/web/tests/create_test_users.py
--- a/swh/web/tests/create_test_admin.py
+++ b/swh/web/tests/create_test_users.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2019 The Software Heritage developers
+# Copyright (C) 2019-2021 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
@@ -14,3 +14,10 @@
if not User.objects.filter(username=username).exists():
User.objects.create_superuser(username, email, password)
+
+username = "user"
+password = "user"
+email = "user@swh-web.org"
+
+if not User.objects.filter(username=username).exists():
+ User.objects.create_user(username, email, password)
diff --git a/swh/web/tests/misc/test_origin_save.py b/swh/web/tests/misc/test_origin_save.py
--- a/swh/web/tests/misc/test_origin_save.py
+++ b/swh/web/tests/misc/test_origin_save.py
@@ -8,6 +8,7 @@
import pytest
+from swh.auth.django.utils import oidc_user_from_profile
from swh.web.common.models import SaveOriginRequest
from swh.web.common.origin_save import SAVE_REQUEST_ACCEPTED, SAVE_TASK_SUCCEEDED
from swh.web.common.utils import reverse
@@ -23,7 +24,7 @@
@pytest.mark.django_db
-def test_save_origin_requests_list(client, mocker):
+def test_save_origin_requests_list(client, mocker, keycloak_oidc):
visit_types = ("git", "svn", "hg")
nb_origins_per_type = 10
for visit_type in visit_types:
@@ -94,3 +95,42 @@
assert sors["recordsTotal"] == len(visit_types) * nb_origins_per_type
assert len(sors["data"]) == nb_origins_per_type
assert all(d["visit_type"] == visit_type for d in sors["data"])
+
+ # simulate a user is logged in and create a save request
+ user = oidc_user_from_profile(keycloak_oidc, keycloak_oidc.login())
+ client.login(code="", code_verifier="", redirect_uri="")
+
+ sor = SaveOriginRequest.objects.create(
+ request_date=datetime.now(tz=timezone.utc),
+ visit_type=visit_type,
+ origin_url="https://git.example.org/user/project",
+ status=SAVE_REQUEST_ACCEPTED,
+ visit_date=datetime.now(tz=timezone.utc) + timedelta(hours=1),
+ loading_task_id=i,
+ loading_task_status=SAVE_TASK_SUCCEEDED,
+ user_id=str(user.id),
+ )
+
+ # filter save requests according to user id
+ url = reverse(
+ "origin-save-requests-list",
+ url_args={"status": "all"},
+ query_params={
+ "draw": i + 1,
+ "search[value]": "",
+ "order[0][column]": "0",
+ "columns[0][name]": "request_date",
+ "order[0][dir]": "desc",
+ "length": nb_origins_per_type,
+ "start": "0",
+ "user_requests_only": "1",
+ },
+ )
+
+ resp = check_http_get_response(
+ client, url, status_code=200, content_type="application/json"
+ )
+ sors = json.loads(resp.content.decode("utf-8"))
+ assert sors["recordsFiltered"] == 1
+ assert sors["recordsTotal"] == len(visit_types) * nb_origins_per_type + 1
+ assert sors["data"][0] == sor.to_dict()