Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9348092
D6372.id23168.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
D6372.id23168.diff
View Options
diff --git a/swh/web/config.py b/swh/web/config.py
--- a/swh/web/config.py
+++ b/swh/web/config.py
@@ -90,7 +90,7 @@
"vault": ("dict", {"cls": "remote", "args": {"url": "http://127.0.0.1:5005/",}}),
"scheduler": ("dict", {"cls": "remote", "url": "http://127.0.0.1:5008/"}),
"development_db": ("string", os.path.join(SETTINGS_DIR, "db.sqlite3")),
- "test_db": ("string", os.path.join(SETTINGS_DIR, "testdb.sqlite3")),
+ "test_db": ("dict", {"name": "swh-web-test"}),
"production_db": ("dict", {"name": "swh-web"}),
"deposit": (
"dict",
diff --git a/swh/web/settings/tests.py b/swh/web/settings/tests.py
--- a/swh/web/settings/tests.py
+++ b/swh/web/settings/tests.py
@@ -95,8 +95,8 @@
DATABASES = {
"default": {
- "ENGINE": "django.db.backends.sqlite3",
- "NAME": swh_web_config["test_db"],
+ "ENGINE": "django.db.backends.postgresql",
+ "NAME": swh_web_config["test_db"]["name"],
}
}
diff --git a/swh/web/tests/auth/test_views.py b/swh/web/tests/auth/test_views.py
--- a/swh/web/tests/auth/test_views.py
+++ b/swh/web/tests/auth/test_views.py
@@ -118,7 +118,7 @@
# check token has been generated and saved encrypted to database
assert len(OIDCUserOfflineTokens.objects.all()) == nb_tokens + 1
- encrypted_token = OIDCUserOfflineTokens.objects.last().offline_token
+ encrypted_token = OIDCUserOfflineTokens.objects.last().offline_token.tobytes()
secret = get_config()["secret_key"].encode()
salt = request.user.sub.encode()
decrypted_token = decrypt_data(encrypted_token, secret, salt)
@@ -131,7 +131,7 @@
return decrypted_token
-@pytest.mark.django_db
+@pytest.mark.django_db(reset_sequences=True)
def test_oidc_generate_bearer_token_authenticated_user_success(client, keycloak_oidc):
"""
Authenticated user should be able to generate a bearer token using OIDC
@@ -150,7 +150,7 @@
check_http_get_response(client, url, status_code=403)
-@pytest.mark.django_db
+@pytest.mark.django_db(reset_sequences=True)
def test_oidc_list_bearer_tokens(client, keycloak_oidc):
"""
User with correct credentials should be allowed to list his tokens.
@@ -169,8 +169,8 @@
for oidc_token in OIDCUserOfflineTokens.objects.all():
assert (
- oidc_token.creation_date.isoformat()
- == tokens_data[oidc_token.id - 1]["creation_date"]
+ oidc_token.creation_date.isoformat()[:15]
+ == tokens_data[oidc_token.id - 2]["creation_date"][:15]
)
@@ -182,7 +182,7 @@
check_http_post_response(client, url, status_code=403)
-@pytest.mark.django_db
+@pytest.mark.django_db(reset_sequences=True)
def test_oidc_get_bearer_token(client, keycloak_oidc):
"""
User with correct credentials should be allowed to display a token.
@@ -204,7 +204,7 @@
assert response.content == token
-@pytest.mark.django_db
+@pytest.mark.django_db(reset_sequences=True)
def test_oidc_get_bearer_token_expired_token(client, keycloak_oidc):
"""
User with correct credentials should be allowed to display a token.
@@ -245,7 +245,7 @@
check_http_post_response(client, url, status_code=403)
-@pytest.mark.django_db
+@pytest.mark.django_db(reset_sequences=True)
def test_oidc_revoke_bearer_tokens(client, keycloak_oidc):
"""
User with correct credentials should be allowed to revoke tokens.
@@ -279,7 +279,7 @@
assert resp["location"] == login_url
-@pytest.mark.django_db
+@pytest.mark.django_db(reset_sequences=True)
def test_oidc_profile_view(client, keycloak_oidc):
"""
Authenticated users should be able to request the profile page
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jul 3 2025, 6:12 PM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3218872
Attached To
D6372: Replace Sqlite with Postgres in unit tests
Event Timeline
Log In to Comment