示例#1
0
    def test_logout_not_authenticated(self):
        from wirecloud.keycloak import views
        reload(views)

        views.wirecloud_logout = MagicMock()

        request = MagicMock(META=(), user=MagicMock(is_authenticated=False))
        response = views.logout(request)

        views.wirecloud_logout.assert_called_once_with(request)
        self.assertEqual(views.wirecloud_logout(), response)
示例#2
0
    def test_logout(self):
        from wirecloud.keycloak import views
        reload(views)

        views.wirecloud_logout = MagicMock()

        request = MagicMock()
        request.META = ()
        response = views.logout(request)

        views.wirecloud_logout.assert_called_once_with(request)
        self.assertEqual(views.wirecloud_logout(), response)
示例#3
0
    def test_logout(self):
        from wirecloud.keycloak import views
        reload(views)

        views.build_backend = MagicMock()
        views.build_backend().end_session_url.return_value = 'https://accounts.example.com/logout'
        views.wirecloud_logout = MagicMock()
        views.get_absolute_reverse_url = MagicMock(return_value='https://example.com/')
        views.settings.LOGOUT_REDIRECT_URL = '/'
        views.quote = MagicMock(return_value='https:%2F%2Fexample.com%2F')

        request = MagicMock(META=())
        response = views.logout(request)

        views.wirecloud_logout.assert_called_once_with(request, next_page='https://accounts.example.com/logout?redirect_uri=https:%2F%2Fexample.com%2F')
        self.assertEqual(views.wirecloud_logout(), response)