예제 #1
0
    def test_check_proxies_to_verify_auth_client(self, pyramid_request,
                                                 verify_auth_client):
        AuthClientPolicy.check("someusername", "somepassword", pyramid_request)

        verify_auth_client.assert_called_once_with("someusername",
                                                   "somepassword",
                                                   pyramid_request.db)
예제 #2
0
파일: policy_test.py 프로젝트: hypothesis/h
    def test_check_proxies_to_verify_auth_client(
        self, pyramid_request, verify_auth_client
    ):
        AuthClientPolicy.check("someusername", "somepassword", pyramid_request)

        verify_auth_client.assert_called_once_with(
            "someusername", "somepassword", pyramid_request.db
        )
예제 #3
0
    def test_check_doesnt_proxy_to_principals_for_auth_client_if_forwarded_user(
            self, user_service, pyramid_request, verify_auth_client,
            principals_for_auth_client):
        pyramid_request.headers['X-Forwarded-User'] = '******'

        AuthClientPolicy.check('someusername', 'somepassword', pyramid_request)

        assert principals_for_auth_client.call_count == 0
예제 #4
0
    def test_check_fetches_user_if_forwarded_user(self, pyramid_request,
                                                  verify_auth_client,
                                                  user_service):

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

        AuthClientPolicy.check("someusername", "somepassword", pyramid_request)

        user_service.fetch.assert_called_once_with("acct:[email protected]")
예제 #5
0
    def test_check_fetches_user_if_forwarded_user(self, pyramid_request,
                                                  verify_auth_client,
                                                  user_service):

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

        AuthClientPolicy.check('someusername', 'somepassword', pyramid_request)

        user_service.fetch.assert_called_once_with('acct:[email protected]')
예제 #6
0
파일: policy_test.py 프로젝트: hypothesis/h
    def test_check_fetches_user_if_forwarded_user(
        self, pyramid_request, verify_auth_client, user_service
    ):

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

        AuthClientPolicy.check("someusername", "somepassword", pyramid_request)

        user_service.fetch.assert_called_once_with("acct:[email protected]")
예제 #7
0
파일: policy_test.py 프로젝트: hypothesis/h
    def test_check_doesnt_proxy_to_principals_for_auth_client_if_forwarded_user(
        self,
        user_service,
        pyramid_request,
        verify_auth_client,
        principals_for_auth_client,
    ):
        pyramid_request.headers["X-Forwarded-User"] = "******"

        AuthClientPolicy.check("someusername", "somepassword", pyramid_request)

        assert principals_for_auth_client.call_count == 0
예제 #8
0
    def test_check_returns_None_if_verify_auth_client_fails(
            self, pyramid_request, verify_auth_client):
        verify_auth_client.return_value = None

        principals = AuthClientPolicy.check("someusername", "somepassword",
                                            pyramid_request)

        assert principals is None
예제 #9
0
    def test_check_returns_None_if_fetch_forwarded_user_fails(
            self, pyramid_request, verify_auth_client, user_service):
        user_service.fetch.return_value = None
        pyramid_request.headers["X-Forwarded-User"] = "******"

        principals = AuthClientPolicy.check("someusername", "somepassword",
                                            pyramid_request)

        assert principals is None
예제 #10
0
    def test_check_returns_None_if_user_fetch_raises_valueError(
            self, pyramid_request, verify_auth_client, user_service):

        pyramid_request.headers["X-Forwarded-User"] = "******"
        user_service.fetch.side_effect = ValueError("whoops")

        principals = AuthClientPolicy.check("someusername", "somepassword",
                                            pyramid_request)

        assert principals is None
예제 #11
0
파일: policy_test.py 프로젝트: hypothesis/h
    def test_check_returns_None_if_verify_auth_client_fails(
        self, pyramid_request, verify_auth_client
    ):
        verify_auth_client.return_value = None

        principals = AuthClientPolicy.check(
            "someusername", "somepassword", pyramid_request
        )

        assert principals is None
예제 #12
0
    def test_check_returns_None_if_user_fetch_raises_valueError(
            self, pyramid_request, verify_auth_client, user_service):

        pyramid_request.headers['X-Forwarded-User'] = '******'
        user_service.fetch.side_effect = ValueError('whoops')

        principals = AuthClientPolicy.check('someusername', 'somepassword',
                                            pyramid_request)

        assert principals is None
예제 #13
0
    def test_check_proxies_to_principals_for_auth_client_if_no_forwarded_user(
            self, pyramid_request, verify_auth_client,
            principals_for_auth_client):

        principals = AuthClientPolicy.check("someusername", "somepassword",
                                            pyramid_request)

        assert principals == principals_for_auth_client.return_value
        principals_for_auth_client.assert_called_once_with(
            verify_auth_client.return_value)
예제 #14
0
파일: policy_test.py 프로젝트: hypothesis/h
    def test_check_returns_None_if_fetch_forwarded_user_fails(
        self, pyramid_request, verify_auth_client, user_service
    ):
        user_service.fetch.return_value = None
        pyramid_request.headers["X-Forwarded-User"] = "******"

        principals = AuthClientPolicy.check(
            "someusername", "somepassword", pyramid_request
        )

        assert principals is None
예제 #15
0
파일: policy_test.py 프로젝트: xiangsxuan/h
    def test_check_returns_None_if_userid_is_invalid(self, pyramid_request,
                                                     verify_auth_client,
                                                     user_service):
        pyramid_request.headers["X-Forwarded-User"] = "******"
        user_service.fetch.side_effect = InvalidUserId("badly_formatted")

        principals = AuthClientPolicy.check(mock.sentinel.username,
                                            mock.sentinel.password,
                                            pyramid_request)

        assert principals is None
예제 #16
0
파일: policy_test.py 프로젝트: hypothesis/h
    def test_check_proxies_to_principals_for_auth_client_if_no_forwarded_user(
        self, pyramid_request, verify_auth_client, principals_for_auth_client
    ):

        principals = AuthClientPolicy.check(
            "someusername", "somepassword", pyramid_request
        )

        assert principals == principals_for_auth_client.return_value
        principals_for_auth_client.assert_called_once_with(
            verify_auth_client.return_value
        )
예제 #17
0
파일: policy_test.py 프로젝트: hypothesis/h
    def test_check_returns_None_if_user_fetch_raises_valueError(
        self, pyramid_request, verify_auth_client, user_service
    ):

        pyramid_request.headers["X-Forwarded-User"] = "******"
        user_service.fetch.side_effect = ValueError("whoops")

        principals = AuthClientPolicy.check(
            "someusername", "somepassword", pyramid_request
        )

        assert principals is None
예제 #18
0
    def test_check_returns_None_if_forwarded_user_authority_mismatch(
            self, pyramid_request, verify_auth_client, user_service,
            factories):
        mismatched_user = factories.User(authority="two.com")
        verify_auth_client.return_value = factories.ConfidentialAuthClient(
            authority="one.com")
        user_service.fetch.return_value = mismatched_user
        pyramid_request.headers["X-Forwarded-User"] = mismatched_user.userid

        principals = AuthClientPolicy.check("someusername", "somepassword",
                                            pyramid_request)

        assert principals is None
예제 #19
0
파일: policy_test.py 프로젝트: hypothesis/h
    def test_check_returns_None_if_forwarded_user_authority_mismatch(
        self, pyramid_request, verify_auth_client, user_service, factories
    ):
        mismatched_user = factories.User(authority="two.com")
        verify_auth_client.return_value = factories.ConfidentialAuthClient(
            authority="one.com"
        )
        user_service.fetch.return_value = mismatched_user
        pyramid_request.headers["X-Forwarded-User"] = mismatched_user.userid

        principals = AuthClientPolicy.check(
            "someusername", "somepassword", pyramid_request
        )

        assert principals is None
예제 #20
0
    def test_it_proxies_to_principals_for_user_if_fetch_forwarded_user_ok(
            self, pyramid_request, verify_auth_client, user_service, factories,
            principals_for_auth_client_user):
        matched_user = factories.User(authority="one.com")
        verify_auth_client.return_value = factories.ConfidentialAuthClient(
            authority="one.com")
        user_service.fetch.return_value = matched_user
        pyramid_request.headers['X-Forwarded-User'] = matched_user.userid

        principals = AuthClientPolicy.check('someusername', 'somepassword',
                                            pyramid_request)

        principals_for_auth_client_user.assert_called_once_with(
            matched_user, verify_auth_client.return_value)
        assert principals == principals_for_auth_client_user.return_value
예제 #21
0
파일: policy_test.py 프로젝트: hypothesis/h
    def test_it_proxies_to_principals_for_user_if_fetch_forwarded_user_ok(
        self,
        pyramid_request,
        verify_auth_client,
        user_service,
        factories,
        principals_for_auth_client_user,
    ):
        matched_user = factories.User(authority="one.com")
        verify_auth_client.return_value = factories.ConfidentialAuthClient(
            authority="one.com"
        )
        user_service.fetch.return_value = matched_user
        pyramid_request.headers["X-Forwarded-User"] = matched_user.userid

        principals = AuthClientPolicy.check(
            "someusername", "somepassword", pyramid_request
        )

        principals_for_auth_client_user.assert_called_once_with(
            matched_user, verify_auth_client.return_value
        )
        assert principals == principals_for_auth_client_user.return_value