Exemplo n.º 1
0
    def test_unauthenticated_userid_doesnt_proxy_to_basic_auth_if_forwarded_user(
            self, pyramid_request, BasicAuthAuthenticationPolicy):
        pyramid_request.headers['X-Forwarded-User'] = '******'
        auth_policy = AuthClientPolicy()

        auth_policy.unauthenticated_userid(pyramid_request)

        assert BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.call_count == 0
Exemplo n.º 2
0
    def test_unauthenticated_userid_doesnt_proxy_to_basic_auth_if_forwarded_user(
        self, pyramid_request, BasicAuthAuthenticationPolicy
    ):
        pyramid_request.headers["X-Forwarded-User"] = "******"
        auth_policy = AuthClientPolicy()

        auth_policy.unauthenticated_userid(pyramid_request)

        assert (
            BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.call_count
            == 0
        )
Exemplo n.º 3
0
    def test_unauthenticated_userid_proxies_to_basic_auth_if_no_forwarded_user(
            self, pyramid_request, BasicAuthAuthenticationPolicy):
        auth_policy = AuthClientPolicy()
        unauth_id = auth_policy.unauthenticated_userid(pyramid_request)

        BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.assert_called_once_with(
            pyramid_request)
        assert unauth_id == BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.return_value
Exemplo n.º 4
0
    def test_unauthenticated_userid_proxies_to_basic_auth_if_no_forwarded_user(
        self, pyramid_request, BasicAuthAuthenticationPolicy
    ):
        auth_policy = AuthClientPolicy()
        unauth_id = auth_policy.unauthenticated_userid(pyramid_request)

        BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.assert_called_once_with(
            pyramid_request
        )
        assert (
            unauth_id
            == BasicAuthAuthenticationPolicy.return_value.unauthenticated_userid.return_value
        )