File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1717User = get_user_model ()
1818
1919
20+ def my_custom_op_logout (* args , ** kwargs ):
21+ return 'http://example.com/logged/out'
22+
23+
2024class OIDCAuthorizationCallbackViewTestCase (TestCase ):
2125 def setUp (self ):
2226 self .factory = RequestFactory ()
@@ -330,3 +334,19 @@ def test_post(self):
330334
331335 self .assertEqual (response .status_code , 302 )
332336 self .assertEqual (response .url , '/example-logout' )
337+
338+ @override_settings (LOGOUT_REDIRECT_URL = '/example-logout' )
339+ @override_settings (OIDC_OP_LOGOUT_URL_METHOD = 'tests.test_views.my_custom_op_logout' )
340+ def test_post_with_OIDC_OP_LOGOUT_URL_METHOD (self ):
341+ user = User .objects .create_user ('example_username' )
342+ url = reverse ('oidc_logout' )
343+ request = self .factory .post (url )
344+ request .user = user
345+ logout_view = views .OIDCLogoutView .as_view ()
346+
347+ with patch ('mozilla_django_oidc.views.auth.logout' ) as mock_logout :
348+ response = logout_view (request )
349+ mock_logout .assert_called_once_with (request )
350+
351+ self .assertEqual (response .status_code , 302 )
352+ self .assertEqual (response .url , 'http://example.com/logged/out' )
You can’t perform that action at this time.
0 commit comments