Пример #1
0
    def test_authenticated_userid_does_not_proxy_if_no_forwarded_user(
            self, pyramid_request, BasicAuthAuthenticationPolicy):
        auth_policy = AuthClientPolicy()
        auth_policy.authenticated_userid(pyramid_request)

        assert BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.call_count == 0
        assert BasicAuthAuthenticationPolicy.return_value.callback.call_count == 0
Пример #2
0
    def test_authenticated_userid_does_not_proxy_if_no_forwarded_user(
        self, pyramid_request, BasicAuthAuthenticationPolicy
    ):
        auth_policy = AuthClientPolicy()
        auth_policy.authenticated_userid(pyramid_request)

        assert (
            BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.call_count
            == 0
        )
        assert BasicAuthAuthenticationPolicy.return_value.callback.call_count == 0
Пример #3
0
    def test_authenticated_userid_proxies_to_basic_auth_policy_if_forwarded_user(
            self, pyramid_request, BasicAuthAuthenticationPolicy):
        pyramid_request.headers['X-Forwarded-User'] = '******'
        auth_policy = AuthClientPolicy()
        auth_policy.authenticated_userid(pyramid_request)

        BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.assert_called_once_with(
            pyramid_request)
        BasicAuthAuthenticationPolicy.return_value.callback.assert_called_once_with(
            BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.
            return_value, pyramid_request)
Пример #4
0
    def test_authenticated_userid_proxies_to_basic_auth_policy_if_forwarded_user(
        self, pyramid_request, BasicAuthAuthenticationPolicy
    ):
        pyramid_request.headers["X-Forwarded-User"] = "******"
        auth_policy = AuthClientPolicy()
        auth_policy.authenticated_userid(pyramid_request)

        BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.assert_called_once_with(
            pyramid_request
        )
        BasicAuthAuthenticationPolicy.return_value.callback.assert_called_once_with(
            BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.return_value,
            pyramid_request,
        )
Пример #5
0
    def test_authenticated_userid_returns_None_if_callback_not_OK(
            self, check, pyramid_request):
        check.return_value = None
        policy = AuthClientPolicy(check=check)

        pyramid_request.headers["X-Forwarded-User"] = "******"

        userid = policy.authenticated_userid(pyramid_request)

        assert userid is None
Пример #6
0
    def test_authenticated_userid_returns_None_if_callback_not_OK(
        self, check, pyramid_request
    ):
        check.return_value = None
        policy = AuthClientPolicy(check=check)

        pyramid_request.headers["X-Forwarded-User"] = "******"

        userid = policy.authenticated_userid(pyramid_request)

        assert userid is None