Esempio n. 1
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()
Esempio n. 2
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()
Esempio n. 3
0
    def test_get_sets_field_defaults(self, pyramid_request):
        ctrl = AuthClientCreateController(pyramid_request)

        ctx = ctrl.get()

        assert ctx['form'] == {'authority': 'example.com',
                               'grant_type': GrantType.authorization_code,
                               'response_type': ResponseType.code,
                               'trusted': False}
Esempio n. 4
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
Esempio n. 5
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'
Esempio n. 6
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
Esempio n. 7
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()
Esempio n. 8
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)
Esempio n. 9
0
    def test_post_generates_secret_for_jwt_clients(self, form_post, pyramid_request):
        pyramid_request.POST = form_post
        pyramid_request.POST["grant_type"] = "jwt_bearer"
        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"
Esempio n. 10
0
    def test_post_generates_secret_for_jwt_clients(self, form_post, pyramid_request):
        pyramid_request.POST = form_post
        pyramid_request.POST["grant_type"] = "jwt_bearer"
        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"
    def test_get_sets_field_defaults(self, pyramid_request):
        ctrl = AuthClientCreateController(pyramid_request)

        ctx = ctrl.get()

        assert ctx["form"] == {
            "authority": "example.com",
            "grant_type": GrantType.authorization_code,
            "response_type": ResponseType.code,
            "trusted": False,
        }
Esempio n. 12
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
Esempio n. 13
0
    def test_get_sets_field_defaults(self, pyramid_request):
        ctrl = AuthClientCreateController(pyramid_request)

        ctx = ctrl.get()

        assert ctx["form"] == {
            "authority": "example.com",
            "grant_type": GrantType.authorization_code,
            "response_type": ResponseType.code,
            "trusted": False,
        }
Esempio n. 14
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)
Esempio n. 15
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