Skip to content
Snippets Groups Projects
Commit 20da34e9 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

templates/layout: Fallback to django auth when keycloak is not used

This restores the login link to use basic django authentication when
Keycloak is not used, for instance in the docker environment.
parent 83ecdb86
No related branches found
No related tags found
1 merge request!505templates/layout: Fallback to django auth when keycloak is not used
......@@ -129,6 +129,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
{% else %}
<a href="{% url 'oidc-login' %}">login</a>
{% endif %}
{% else %}
{% if request.path != logout_url %}
<a href="{% url 'login' %}?next={{ request.build_absolute_uri }}">login</a>
{% else %}
<a href="{% url 'login' %}">login</a>
{% endif %}
{% endif %}
</li>
</ul>
......
......@@ -6,7 +6,7 @@
import random
from swh.web.common.utils import reverse
from swh.web.config import STAGING_SERVER_NAMES
from swh.web.config import STAGING_SERVER_NAMES, get_config
from swh.web.tests.django_asserts import assert_contains, assert_not_contains
from swh.web.tests.utils import check_http_get_response
......@@ -23,3 +23,20 @@ def test_layout_with_staging_ribbon(client):
client, url, status_code=200, server_name=random.choice(STAGING_SERVER_NAMES),
)
assert_contains(resp, "swh-corner-ribbon")
def test_layout_with_oidc_auth_enabled(client):
url = reverse("swh-web-homepage")
resp = check_http_get_response(client, url, status_code=200)
assert_contains(resp, reverse("oidc-login"))
def test_layout_without_oidc_auth_enabled(client, mocker):
config = get_config()
config["keycloak"]["server_url"] = ""
mock_get_config = mocker.patch("swh.web.common.utils.get_config")
mock_get_config.return_value = config
url = reverse("swh-web-homepage")
resp = check_http_get_response(client, url, status_code=200)
assert_contains(resp, reverse("login"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment