Skip to content

Commit

Permalink
Revert "tests: domain is localhost.local"
Browse files Browse the repository at this point in the history
This reverts commit 44aed27.
  • Loading branch information
azmeuk committed Oct 1, 2023
1 parent b843f9d commit 88dcf94
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion canaille/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_current_mail_domain():
if current_app.config["SMTP"].get("FROM_ADDR"):
return current_app.config["SMTP"]["FROM_ADDR"].split("@")[-1]

return get_current_domain().split(":")[0]
return get_current_domain()


def validate_uri(value):
Expand Down
8 changes: 1 addition & 7 deletions tests/app/test_mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
import warnings
from unittest import mock

import pytest
from canaille import create_app
from flask_webtest import TestApp


@pytest.fixture
def configuration(configuration, httpserver):
configuration["SERVER_NAME"] = f"{httpserver.host}:{httpserver.port}"
return configuration


def test_send_test_email(testclient, logged_admin, smtpd):
assert len(smtpd.messages) == 0

Expand Down Expand Up @@ -120,6 +113,7 @@ def test_mail_with_default_logo(testclient, logged_admin, smtpd, httpserver):
raw_logo = fd.read()

httpserver.expect_request(logo_path).respond_with_data(raw_logo)
testclient.app.config["SERVER_NAME"] = f"{httpserver.host}:{httpserver.port}"
assert len(smtpd.messages) == 0

res = testclient.get(f"http://{httpserver.host}:{httpserver.port}/admin/mail")
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def configuration(smtpd):
smtpd.config.use_starttls = True
conf = {
"SECRET_KEY": gen_salt(24),
"SERVER_NAME": "localhost.local",
"JAVASCRIPT": False,
"LOGO": "/static/img/canaille-head.png",
"TIMEZONE": "UTC",
Expand Down
4 changes: 2 additions & 2 deletions tests/oidc/test_dynamic_client_registration_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_get(testclient, backend, client, user):
"https://mydomain.tld/redirect2",
],
"registration_access_token": "static-token",
"registration_client_uri": f"http://localhost.local/oauth/register/{client.client_id}",
"registration_client_uri": f"http://localhost/oauth/register/{client.client_id}",
"token_endpoint_auth_method": "client_secret_basic",
"grant_types": [
"password",
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_update(testclient, backend, client, user):
"client_secret_expires_at": None,
"redirect_uris": ["https://newname.example.org/callback"],
"registration_access_token": "static-token",
"registration_client_uri": f"http://localhost.local/oauth/register/{client.client_id}",
"registration_client_uri": f"http://localhost/oauth/register/{client.client_id}",
"token_endpoint_auth_method": "none",
"grant_types": ["refresh_token"],
"response_types": ["code", "token"],
Expand Down
26 changes: 13 additions & 13 deletions tests/oidc/test_well_known.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ def test_oauth_authorization_server(testclient):
res = testclient.get("/.well-known/oauth-authorization-server", status=200).json
assert "https://auth.mydomain.tld" == res["issuer"]
assert res == {
"authorization_endpoint": "http://localhost.local/oauth/authorize",
"authorization_endpoint": "http://localhost/oauth/authorize",
"code_challenge_methods_supported": ["plain", "S256"],
"introspection_endpoint": "http://localhost.local/oauth/introspect",
"introspection_endpoint": "http://localhost/oauth/introspect",
"issuer": "https://auth.mydomain.tld",
"jwks_uri": "http://localhost.local/oauth/jwks.json",
"registration_endpoint": "http://localhost.local/oauth/register",
"jwks_uri": "http://localhost/oauth/jwks.json",
"registration_endpoint": "http://localhost/oauth/register",
"response_types_supported": [
"code",
"token",
Expand All @@ -27,7 +27,7 @@ def test_oauth_authorization_server(testclient):
"phone",
"groups",
],
"token_endpoint": "http://localhost.local/oauth/token",
"token_endpoint": "http://localhost/oauth/token",
"token_endpoint_auth_methods_supported": [
"client_secret_basic",
"private_key_jwt",
Expand All @@ -36,15 +36,15 @@ def test_oauth_authorization_server(testclient):
],
"token_endpoint_auth_signing_alg_values_supported": ["RS256", "ES256"],
"ui_locales_supported": g.available_language_codes,
"userinfo_endpoint": "http://localhost.local/oauth/userinfo",
"userinfo_endpoint": "http://localhost/oauth/userinfo",
}


def test_openid_configuration(testclient):
res = testclient.get("/.well-known/openid-configuration", status=200).json
assert "https://auth.mydomain.tld" == res["issuer"]
assert res == {
"authorization_endpoint": "http://localhost.local/oauth/authorize",
"authorization_endpoint": "http://localhost/oauth/authorize",
"claims_supported": [
"sub",
"iss",
Expand All @@ -65,12 +65,12 @@ def test_openid_configuration(testclient):
"nonce",
],
"code_challenge_methods_supported": ["plain", "S256"],
"end_session_endpoint": "http://localhost.local/oauth/end_session",
"end_session_endpoint": "http://localhost/oauth/end_session",
"id_token_signing_alg_values_supported": ["RS256", "ES256", "HS256"],
"introspection_endpoint": "http://localhost.local/oauth/introspect",
"introspection_endpoint": "http://localhost/oauth/introspect",
"issuer": "https://auth.mydomain.tld",
"jwks_uri": "http://localhost.local/oauth/jwks.json",
"registration_endpoint": "http://localhost.local/oauth/register",
"jwks_uri": "http://localhost/oauth/jwks.json",
"registration_endpoint": "http://localhost/oauth/register",
"response_types_supported": [
"code",
"token",
Expand All @@ -88,7 +88,7 @@ def test_openid_configuration(testclient):
"groups",
],
"subject_types_supported": ["pairwise", "public"],
"token_endpoint": "http://localhost.local/oauth/token",
"token_endpoint": "http://localhost/oauth/token",
"token_endpoint_auth_methods_supported": [
"client_secret_basic",
"private_key_jwt",
Expand All @@ -97,5 +97,5 @@ def test_openid_configuration(testclient):
],
"token_endpoint_auth_signing_alg_values_supported": ["RS256", "ES256"],
"ui_locales_supported": g.available_language_codes,
"userinfo_endpoint": "http://localhost.local/oauth/userinfo",
"userinfo_endpoint": "http://localhost/oauth/userinfo",
}

0 comments on commit 88dcf94

Please sign in to comment.