File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
mozilla_django_oidc_db/templatetags Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ from django import template
2+
3+ from ..constants import OIDC_ADMIN_CONFIG_IDENTIFIER
4+ from ..models import OIDCClient
5+
6+ register = template .Library ()
7+
8+
9+ @register .simple_tag
10+ def get_oidc_admin_client () -> OIDCClient | None :
11+ return OIDCClient .objects .filter (identifier = OIDC_ADMIN_CONFIG_IDENTIFIER ).first ()
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from mozilla_django_oidc_db .constants import OIDC_ADMIN_CONFIG_IDENTIFIER
4+ from mozilla_django_oidc_db .models import OIDCClient
5+ from mozilla_django_oidc_db .templatetags .mozilla_django_oidc_db import (
6+ get_oidc_admin_client ,
7+ )
8+
9+
10+ @pytest .mark .oidcconfig (enabled = True )
11+ def test_templatetag_admin_oidc_enabled (filled_admin_config ):
12+ retrieved_client = get_oidc_admin_client ()
13+
14+ assert retrieved_client == filled_admin_config
15+
16+
17+ @pytest .mark .django_db
18+ def test_templatetag_admin_oidc_disabled ():
19+ # The object is present because the migrations create it
20+ OIDCClient .objects .filter (identifier = OIDC_ADMIN_CONFIG_IDENTIFIER ).delete ()
21+
22+ retrieved_client = get_oidc_admin_client ()
23+
24+ assert retrieved_client is None
You can’t perform that action at this time.
0 commit comments