authentik.flows.tests.test_interface_sfe
flow views tests
1"""flow views tests""" 2 3from django.test import RequestFactory 4from django.urls import reverse 5 6from authentik.core.models import Application 7from authentik.core.tests.utils import create_test_flow 8from authentik.flows.planner import PLAN_CONTEXT_APPLICATION, FlowPlan 9from authentik.flows.stage import PLAN_CONTEXT_PENDING_USER_IDENTIFIER 10from authentik.flows.tests import APIFlowTestCase 11from authentik.flows.views.executor import SESSION_KEY_PLAN 12from authentik.flows.views.interface import FlowInterfaceView 13 14 15class TestFlowInterfaceSimple(APIFlowTestCase): 16 """Test which flow executor is selected for a given user agent""" 17 18 def needs_sfe(self, user_agent: str) -> bool: 19 """Run compat_needs_sfe() against a request carrying user_agent""" 20 request = RequestFactory().get("/", HTTP_USER_AGENT=user_agent) 21 view = FlowInterfaceView() 22 view.request = request 23 return view.compat_needs_sfe() 24 25 def test_old_webkit(self): 26 """WebKit older than 16.4 cannot parse the default flow executor""" 27 self.assertTrue( 28 self.needs_sfe( 29 "Mozilla/5.0 (iPad; CPU OS 15_8 like Mac OS X) AppleWebKit/605.1.15 " 30 "(KHTML, like Gecko) Version/15.6.8 Mobile/15E148 Safari/604.1" 31 ) 32 ) 33 34 def test_old_ios_other_browser(self): 35 """Browsers on iOS use the system WebKit, so the iOS version decides""" 36 self.assertTrue( 37 self.needs_sfe( 38 "Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 " 39 "(KHTML, like Gecko) CriOS/119.0 Mobile/15E148 Safari/604.1" 40 ) 41 ) 42 43 def test_old_ipados_desktop_mode(self): 44 """iPadOS in desktop mode reports itself as Safari on macOS""" 45 self.assertTrue( 46 self.needs_sfe( 47 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 " 48 "(KHTML, like Gecko) Version/15.6 Safari/605.1.15" 49 ) 50 ) 51 52 def test_current_webkit(self): 53 """WebKit 16.4 and newer parses the default flow executor""" 54 self.assertFalse( 55 self.needs_sfe( 56 "Mozilla/5.0 (iPhone; CPU iPhone OS 16_4 like Mac OS X) AppleWebKit/605.1.15 " 57 "(KHTML, like Gecko) Version/16.4 Mobile/15E148 Safari/604.1" 58 ) 59 ) 60 61 def test_ie(self): 62 """Test Internet Explorer/Trident""" 63 self.assertTrue( 64 self.needs_sfe("Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko") 65 ) 66 self.assertTrue( 67 self.needs_sfe("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)") 68 ) 69 70 def test_edge_legacy(self): 71 """Test legacy edge""" 72 self.assertTrue( 73 self.needs_sfe( 74 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, " 75 "like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362" 76 ) 77 ) 78 79 def test_current_chrome(self): 80 """Unaffected browsers keep the default flow executor""" 81 self.assertFalse( 82 self.needs_sfe( 83 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 " 84 "(KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36" 85 ) 86 ) 87 88 def test_old_chrome(self): 89 """Unaffected browsers keep the default flow executor""" 90 self.assertTrue( 91 self.needs_sfe( 92 "Mozilla/5.0 (Linux; Android 11; sdk_gphone_x86_64) AppleWebKit/537.36 (KHTML, " 93 "like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36" 94 ) 95 ) 96 97 def test_unknown_user_agent(self): 98 """A user agent without a parseable version keeps the default flow executor""" 99 self.assertFalse(self.needs_sfe("")) 100 101 102class TestFlowInterfaceTitle(APIFlowTestCase): 103 """Test flow title placeholders on the interface page""" 104 105 def test_title_placeholder(self): 106 """Placeholders are blanked as no plan context exists yet""" 107 flow = create_test_flow() 108 flow.title = "Welcome to %(app)s" 109 flow.save() 110 response = self.client.get( 111 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 112 ) 113 self.assertEqual(response.status_code, 200) 114 self.assertContains(response, '<meta name="ak-flow-title" content="Welcome to">') 115 flow.refresh_from_db() 116 self.assertEqual(flow.title, "Welcome to %(app)s") 117 118 def test_title_literal_percent(self): 119 """Titles with a bare percent sign are left as-is""" 120 flow = create_test_flow() 121 flow.title = "100% secure" 122 flow.save() 123 response = self.client.get( 124 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 125 ) 126 self.assertContains(response, '<meta name="ak-flow-title" content="100% secure">') 127 128 def test_title_plan_context(self): 129 """Placeholders are filled from the plan in the session""" 130 flow = create_test_flow() 131 flow.title = "Sign in to %(app)s as %(user)s" 132 flow.save() 133 plan = FlowPlan(flow_pk=flow.pk.hex) 134 plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana") 135 plan.context[PLAN_CONTEXT_PENDING_USER_IDENTIFIER] = "jdoe" 136 session = self.client.session 137 session[SESSION_KEY_PLAN] = plan 138 session.save() 139 response = self.client.get( 140 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 141 ) 142 self.assertContains( 143 response, '<meta name="ak-flow-title" content="Sign in to Grafana as jdoe">' 144 ) 145 146 def test_title_plan_no_pending_user(self): 147 """The user placeholder is empty before the user is identified""" 148 flow = create_test_flow() 149 flow.title = "Sign in to %(app)s as %(user)s" 150 flow.save() 151 plan = FlowPlan(flow_pk=flow.pk.hex) 152 plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana") 153 session = self.client.session 154 session[SESSION_KEY_PLAN] = plan 155 session.save() 156 response = self.client.get( 157 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 158 ) 159 self.assertContains( 160 response, '<meta name="ak-flow-title" content="Sign in to Grafana as ">' 161 ) 162 163 def test_title_plan_other_flow(self): 164 """A plan for a different flow still fills placeholders""" 165 flow = create_test_flow() 166 flow.title = "Sign in to %(app)s" 167 flow.save() 168 plan = FlowPlan(flow_pk=create_test_flow().pk.hex) 169 plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana") 170 session = self.client.session 171 session[SESSION_KEY_PLAN] = plan 172 session.save() 173 response = self.client.get( 174 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 175 ) 176 self.assertContains(response, '<meta name="ak-flow-title" content="Sign in to Grafana">') 177 178 def test_title_plan_invalid_placeholder(self): 179 """Unknown placeholders with a plan keep the original title""" 180 flow = create_test_flow() 181 flow.title = "Hello %(foo)s" 182 flow.save() 183 session = self.client.session 184 session[SESSION_KEY_PLAN] = FlowPlan(flow_pk=flow.pk.hex) 185 session.save() 186 response = self.client.get( 187 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 188 ) 189 self.assertContains(response, '<meta name="ak-flow-title" content="Hello %(foo)s">') 190 191 192class TestFlowInterfaceBackground(APIFlowTestCase): 193 """Test the flow background on the interface page""" 194 195 def test_themed_background(self): 196 """A themed background renders its light variant, and its dark variant under 197 data-theme="dark", before the flow executor loads""" 198 flow = create_test_flow() 199 flow.background = "/static/authentik/sources/kerberos/%(theme)s.png" 200 flow.save() 201 response = self.client.get( 202 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 203 ) 204 self.assertEqual(response.status_code, 200) 205 content = response.content.decode() 206 self.assertRegex( 207 content, 208 r":root \{\s*--ak-global--background-image: " 209 r'url\("http://testserver/static/authentik/sources/kerberos/light.png"\);', 210 ) 211 self.assertRegex( 212 content, 213 r':root\[data-theme="dark"\] \{\s*--ak-global--background-image: ' 214 r'url\("http://testserver/static/authentik/sources/kerberos/dark.png"\);', 215 )
16class TestFlowInterfaceSimple(APIFlowTestCase): 17 """Test which flow executor is selected for a given user agent""" 18 19 def needs_sfe(self, user_agent: str) -> bool: 20 """Run compat_needs_sfe() against a request carrying user_agent""" 21 request = RequestFactory().get("/", HTTP_USER_AGENT=user_agent) 22 view = FlowInterfaceView() 23 view.request = request 24 return view.compat_needs_sfe() 25 26 def test_old_webkit(self): 27 """WebKit older than 16.4 cannot parse the default flow executor""" 28 self.assertTrue( 29 self.needs_sfe( 30 "Mozilla/5.0 (iPad; CPU OS 15_8 like Mac OS X) AppleWebKit/605.1.15 " 31 "(KHTML, like Gecko) Version/15.6.8 Mobile/15E148 Safari/604.1" 32 ) 33 ) 34 35 def test_old_ios_other_browser(self): 36 """Browsers on iOS use the system WebKit, so the iOS version decides""" 37 self.assertTrue( 38 self.needs_sfe( 39 "Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 " 40 "(KHTML, like Gecko) CriOS/119.0 Mobile/15E148 Safari/604.1" 41 ) 42 ) 43 44 def test_old_ipados_desktop_mode(self): 45 """iPadOS in desktop mode reports itself as Safari on macOS""" 46 self.assertTrue( 47 self.needs_sfe( 48 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 " 49 "(KHTML, like Gecko) Version/15.6 Safari/605.1.15" 50 ) 51 ) 52 53 def test_current_webkit(self): 54 """WebKit 16.4 and newer parses the default flow executor""" 55 self.assertFalse( 56 self.needs_sfe( 57 "Mozilla/5.0 (iPhone; CPU iPhone OS 16_4 like Mac OS X) AppleWebKit/605.1.15 " 58 "(KHTML, like Gecko) Version/16.4 Mobile/15E148 Safari/604.1" 59 ) 60 ) 61 62 def test_ie(self): 63 """Test Internet Explorer/Trident""" 64 self.assertTrue( 65 self.needs_sfe("Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko") 66 ) 67 self.assertTrue( 68 self.needs_sfe("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)") 69 ) 70 71 def test_edge_legacy(self): 72 """Test legacy edge""" 73 self.assertTrue( 74 self.needs_sfe( 75 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, " 76 "like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362" 77 ) 78 ) 79 80 def test_current_chrome(self): 81 """Unaffected browsers keep the default flow executor""" 82 self.assertFalse( 83 self.needs_sfe( 84 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 " 85 "(KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36" 86 ) 87 ) 88 89 def test_old_chrome(self): 90 """Unaffected browsers keep the default flow executor""" 91 self.assertTrue( 92 self.needs_sfe( 93 "Mozilla/5.0 (Linux; Android 11; sdk_gphone_x86_64) AppleWebKit/537.36 (KHTML, " 94 "like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36" 95 ) 96 ) 97 98 def test_unknown_user_agent(self): 99 """A user agent without a parseable version keeps the default flow executor""" 100 self.assertFalse(self.needs_sfe(""))
Test which flow executor is selected for a given user agent
19 def needs_sfe(self, user_agent: str) -> bool: 20 """Run compat_needs_sfe() against a request carrying user_agent""" 21 request = RequestFactory().get("/", HTTP_USER_AGENT=user_agent) 22 view = FlowInterfaceView() 23 view.request = request 24 return view.compat_needs_sfe()
Run compat_needs_sfe() against a request carrying user_agent
26 def test_old_webkit(self): 27 """WebKit older than 16.4 cannot parse the default flow executor""" 28 self.assertTrue( 29 self.needs_sfe( 30 "Mozilla/5.0 (iPad; CPU OS 15_8 like Mac OS X) AppleWebKit/605.1.15 " 31 "(KHTML, like Gecko) Version/15.6.8 Mobile/15E148 Safari/604.1" 32 ) 33 )
WebKit older than 16.4 cannot parse the default flow executor
35 def test_old_ios_other_browser(self): 36 """Browsers on iOS use the system WebKit, so the iOS version decides""" 37 self.assertTrue( 38 self.needs_sfe( 39 "Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 " 40 "(KHTML, like Gecko) CriOS/119.0 Mobile/15E148 Safari/604.1" 41 ) 42 )
Browsers on iOS use the system WebKit, so the iOS version decides
44 def test_old_ipados_desktop_mode(self): 45 """iPadOS in desktop mode reports itself as Safari on macOS""" 46 self.assertTrue( 47 self.needs_sfe( 48 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 " 49 "(KHTML, like Gecko) Version/15.6 Safari/605.1.15" 50 ) 51 )
iPadOS in desktop mode reports itself as Safari on macOS
53 def test_current_webkit(self): 54 """WebKit 16.4 and newer parses the default flow executor""" 55 self.assertFalse( 56 self.needs_sfe( 57 "Mozilla/5.0 (iPhone; CPU iPhone OS 16_4 like Mac OS X) AppleWebKit/605.1.15 " 58 "(KHTML, like Gecko) Version/16.4 Mobile/15E148 Safari/604.1" 59 ) 60 )
WebKit 16.4 and newer parses the default flow executor
62 def test_ie(self): 63 """Test Internet Explorer/Trident""" 64 self.assertTrue( 65 self.needs_sfe("Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko") 66 ) 67 self.assertTrue( 68 self.needs_sfe("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)") 69 )
Test Internet Explorer/Trident
71 def test_edge_legacy(self): 72 """Test legacy edge""" 73 self.assertTrue( 74 self.needs_sfe( 75 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, " 76 "like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362" 77 ) 78 )
Test legacy edge
80 def test_current_chrome(self): 81 """Unaffected browsers keep the default flow executor""" 82 self.assertFalse( 83 self.needs_sfe( 84 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 " 85 "(KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36" 86 ) 87 )
Unaffected browsers keep the default flow executor
89 def test_old_chrome(self): 90 """Unaffected browsers keep the default flow executor""" 91 self.assertTrue( 92 self.needs_sfe( 93 "Mozilla/5.0 (Linux; Android 11; sdk_gphone_x86_64) AppleWebKit/537.36 (KHTML, " 94 "like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36" 95 ) 96 )
Unaffected browsers keep the default flow executor
103class TestFlowInterfaceTitle(APIFlowTestCase): 104 """Test flow title placeholders on the interface page""" 105 106 def test_title_placeholder(self): 107 """Placeholders are blanked as no plan context exists yet""" 108 flow = create_test_flow() 109 flow.title = "Welcome to %(app)s" 110 flow.save() 111 response = self.client.get( 112 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 113 ) 114 self.assertEqual(response.status_code, 200) 115 self.assertContains(response, '<meta name="ak-flow-title" content="Welcome to">') 116 flow.refresh_from_db() 117 self.assertEqual(flow.title, "Welcome to %(app)s") 118 119 def test_title_literal_percent(self): 120 """Titles with a bare percent sign are left as-is""" 121 flow = create_test_flow() 122 flow.title = "100% secure" 123 flow.save() 124 response = self.client.get( 125 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 126 ) 127 self.assertContains(response, '<meta name="ak-flow-title" content="100% secure">') 128 129 def test_title_plan_context(self): 130 """Placeholders are filled from the plan in the session""" 131 flow = create_test_flow() 132 flow.title = "Sign in to %(app)s as %(user)s" 133 flow.save() 134 plan = FlowPlan(flow_pk=flow.pk.hex) 135 plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana") 136 plan.context[PLAN_CONTEXT_PENDING_USER_IDENTIFIER] = "jdoe" 137 session = self.client.session 138 session[SESSION_KEY_PLAN] = plan 139 session.save() 140 response = self.client.get( 141 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 142 ) 143 self.assertContains( 144 response, '<meta name="ak-flow-title" content="Sign in to Grafana as jdoe">' 145 ) 146 147 def test_title_plan_no_pending_user(self): 148 """The user placeholder is empty before the user is identified""" 149 flow = create_test_flow() 150 flow.title = "Sign in to %(app)s as %(user)s" 151 flow.save() 152 plan = FlowPlan(flow_pk=flow.pk.hex) 153 plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana") 154 session = self.client.session 155 session[SESSION_KEY_PLAN] = plan 156 session.save() 157 response = self.client.get( 158 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 159 ) 160 self.assertContains( 161 response, '<meta name="ak-flow-title" content="Sign in to Grafana as ">' 162 ) 163 164 def test_title_plan_other_flow(self): 165 """A plan for a different flow still fills placeholders""" 166 flow = create_test_flow() 167 flow.title = "Sign in to %(app)s" 168 flow.save() 169 plan = FlowPlan(flow_pk=create_test_flow().pk.hex) 170 plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana") 171 session = self.client.session 172 session[SESSION_KEY_PLAN] = plan 173 session.save() 174 response = self.client.get( 175 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 176 ) 177 self.assertContains(response, '<meta name="ak-flow-title" content="Sign in to Grafana">') 178 179 def test_title_plan_invalid_placeholder(self): 180 """Unknown placeholders with a plan keep the original title""" 181 flow = create_test_flow() 182 flow.title = "Hello %(foo)s" 183 flow.save() 184 session = self.client.session 185 session[SESSION_KEY_PLAN] = FlowPlan(flow_pk=flow.pk.hex) 186 session.save() 187 response = self.client.get( 188 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 189 ) 190 self.assertContains(response, '<meta name="ak-flow-title" content="Hello %(foo)s">')
Test flow title placeholders on the interface page
106 def test_title_placeholder(self): 107 """Placeholders are blanked as no plan context exists yet""" 108 flow = create_test_flow() 109 flow.title = "Welcome to %(app)s" 110 flow.save() 111 response = self.client.get( 112 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 113 ) 114 self.assertEqual(response.status_code, 200) 115 self.assertContains(response, '<meta name="ak-flow-title" content="Welcome to">') 116 flow.refresh_from_db() 117 self.assertEqual(flow.title, "Welcome to %(app)s")
Placeholders are blanked as no plan context exists yet
119 def test_title_literal_percent(self): 120 """Titles with a bare percent sign are left as-is""" 121 flow = create_test_flow() 122 flow.title = "100% secure" 123 flow.save() 124 response = self.client.get( 125 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 126 ) 127 self.assertContains(response, '<meta name="ak-flow-title" content="100% secure">')
Titles with a bare percent sign are left as-is
129 def test_title_plan_context(self): 130 """Placeholders are filled from the plan in the session""" 131 flow = create_test_flow() 132 flow.title = "Sign in to %(app)s as %(user)s" 133 flow.save() 134 plan = FlowPlan(flow_pk=flow.pk.hex) 135 plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana") 136 plan.context[PLAN_CONTEXT_PENDING_USER_IDENTIFIER] = "jdoe" 137 session = self.client.session 138 session[SESSION_KEY_PLAN] = plan 139 session.save() 140 response = self.client.get( 141 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 142 ) 143 self.assertContains( 144 response, '<meta name="ak-flow-title" content="Sign in to Grafana as jdoe">' 145 )
Placeholders are filled from the plan in the session
147 def test_title_plan_no_pending_user(self): 148 """The user placeholder is empty before the user is identified""" 149 flow = create_test_flow() 150 flow.title = "Sign in to %(app)s as %(user)s" 151 flow.save() 152 plan = FlowPlan(flow_pk=flow.pk.hex) 153 plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana") 154 session = self.client.session 155 session[SESSION_KEY_PLAN] = plan 156 session.save() 157 response = self.client.get( 158 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 159 ) 160 self.assertContains( 161 response, '<meta name="ak-flow-title" content="Sign in to Grafana as ">' 162 )
The user placeholder is empty before the user is identified
164 def test_title_plan_other_flow(self): 165 """A plan for a different flow still fills placeholders""" 166 flow = create_test_flow() 167 flow.title = "Sign in to %(app)s" 168 flow.save() 169 plan = FlowPlan(flow_pk=create_test_flow().pk.hex) 170 plan.context[PLAN_CONTEXT_APPLICATION] = Application(name="Grafana") 171 session = self.client.session 172 session[SESSION_KEY_PLAN] = plan 173 session.save() 174 response = self.client.get( 175 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 176 ) 177 self.assertContains(response, '<meta name="ak-flow-title" content="Sign in to Grafana">')
A plan for a different flow still fills placeholders
179 def test_title_plan_invalid_placeholder(self): 180 """Unknown placeholders with a plan keep the original title""" 181 flow = create_test_flow() 182 flow.title = "Hello %(foo)s" 183 flow.save() 184 session = self.client.session 185 session[SESSION_KEY_PLAN] = FlowPlan(flow_pk=flow.pk.hex) 186 session.save() 187 response = self.client.get( 188 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 189 ) 190 self.assertContains(response, '<meta name="ak-flow-title" content="Hello %(foo)s">')
Unknown placeholders with a plan keep the original title
193class TestFlowInterfaceBackground(APIFlowTestCase): 194 """Test the flow background on the interface page""" 195 196 def test_themed_background(self): 197 """A themed background renders its light variant, and its dark variant under 198 data-theme="dark", before the flow executor loads""" 199 flow = create_test_flow() 200 flow.background = "/static/authentik/sources/kerberos/%(theme)s.png" 201 flow.save() 202 response = self.client.get( 203 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 204 ) 205 self.assertEqual(response.status_code, 200) 206 content = response.content.decode() 207 self.assertRegex( 208 content, 209 r":root \{\s*--ak-global--background-image: " 210 r'url\("http://testserver/static/authentik/sources/kerberos/light.png"\);', 211 ) 212 self.assertRegex( 213 content, 214 r':root\[data-theme="dark"\] \{\s*--ak-global--background-image: ' 215 r'url\("http://testserver/static/authentik/sources/kerberos/dark.png"\);', 216 )
Test the flow background on the interface page
196 def test_themed_background(self): 197 """A themed background renders its light variant, and its dark variant under 198 data-theme="dark", before the flow executor loads""" 199 flow = create_test_flow() 200 flow.background = "/static/authentik/sources/kerberos/%(theme)s.png" 201 flow.save() 202 response = self.client.get( 203 reverse("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) 204 ) 205 self.assertEqual(response.status_code, 200) 206 content = response.content.decode() 207 self.assertRegex( 208 content, 209 r":root \{\s*--ak-global--background-image: " 210 r'url\("http://testserver/static/authentik/sources/kerberos/light.png"\);', 211 ) 212 self.assertRegex( 213 content, 214 r':root\[data-theme="dark"\] \{\s*--ak-global--background-image: ' 215 r'url\("http://testserver/static/authentik/sources/kerberos/dark.png"\);', 216 )
A themed background renders its light variant, and its dark variant under data-theme="dark", before the flow executor loads