示例#1
0
    def test_post_does_not_generate_secret_for_authcode_clients(self, form_post, pyramid_request):
        pyramid_request.POST = form_post
        pyramid_request.POST['grant_type'] = 'authorization_code'
        ctrl = AuthClientCreateController(pyramid_request)

        ctrl.post()

        client = pyramid_request.db.query(AuthClient).one()
        assert client.secret is None
示例#2
0
    def test_post_does_not_generate_secret_for_authcode_clients(self, form_post, pyramid_request):
        pyramid_request.POST = form_post
        pyramid_request.POST['grant_type'] = 'authorization_code'
        ctrl = AuthClientCreateController(pyramid_request)

        ctrl.post()

        client = pyramid_request.db.query(AuthClient).one()
        assert client.secret is None
示例#3
0
    def test_post_generates_secret_for_client_credentials_clients(self, form_post, pyramid_request):
        pyramid_request.POST = form_post
        pyramid_request.POST['grant_type'] = 'client_credentials'
        secret_gen = Mock(return_value='keep-me-secret')
        ctrl = AuthClientCreateController(pyramid_request, secret_gen=secret_gen)

        ctrl.post()

        client = pyramid_request.db.query(AuthClient).one()
        assert client.secret == 'keep-me-secret'
示例#4
0
    def test_post_sets_response_type(self, form_post, pyramid_request,
                                     grant_type, expected_response_type):
        pyramid_request.POST = form_post
        pyramid_request.POST['grant_type'] = grant_type
        ctrl = AuthClientCreateController(pyramid_request)

        ctrl.post()

        client = pyramid_request.db.query(AuthClient).one()
        assert client.response_type == expected_response_type
示例#5
0
    def test_post_creates_authclient(self, form_post, pyramid_request):
        pyramid_request.POST = form_post
        pyramid_request.POST['name'] = 'Third Party App'
        ctrl = AuthClientCreateController(pyramid_request)

        ctrl.post()

        pyramid_request.db.query(AuthClient) \
                          .filter_by(name='Third Party App') \
                          .one()
示例#6
0
    def test_post_generates_secret_for_client_credentials_clients(self, form_post, pyramid_request):
        pyramid_request.POST = form_post
        pyramid_request.POST['grant_type'] = 'client_credentials'
        secret_gen = Mock(return_value='keep-me-secret')
        ctrl = AuthClientCreateController(pyramid_request, secret_gen=secret_gen)

        ctrl.post()

        client = pyramid_request.db.query(AuthClient).one()
        assert client.secret == 'keep-me-secret'
示例#7
0
    def test_post_sets_response_type(self, form_post, pyramid_request,
                                     grant_type, expected_response_type):
        pyramid_request.POST = form_post
        pyramid_request.POST['grant_type'] = grant_type
        ctrl = AuthClientCreateController(pyramid_request)

        ctrl.post()

        client = pyramid_request.db.query(AuthClient).one()
        assert client.response_type == expected_response_type
示例#8
0
    def test_post_creates_authclient(self, form_post, pyramid_request):
        pyramid_request.POST = form_post
        pyramid_request.POST['name'] = 'Third Party App'
        ctrl = AuthClientCreateController(pyramid_request)

        ctrl.post()

        pyramid_request.db.query(AuthClient) \
                          .filter_by(name='Third Party App') \
                          .one()
示例#9
0
    def test_post_redirects_to_edit_view(self, form_post, pyramid_request):
        pyramid_request.POST = form_post
        ctrl = AuthClientCreateController(pyramid_request)

        response = ctrl.post()

        client = pyramid_request.db.query(AuthClient).one()
        expected_location = pyramid_request.route_url('admin_oauthclients_edit',
                                                      id=client.id)
        assert response == redirect_302_to(expected_location)
示例#10
0
    def test_post_redirects_to_edit_view(self, form_post, matchers, pyramid_request):
        pyramid_request.POST = form_post
        ctrl = AuthClientCreateController(pyramid_request)

        response = ctrl.post()

        client = pyramid_request.db.query(AuthClient).one()
        expected_location = pyramid_request.route_url('admin_oauthclients_edit',
                                                      id=client.id)
        assert response == matchers.Redirect302To(expected_location)