Ejemplo n.º 1
0
    def test_it_returns_a_valid_token(self, db_session, pyramid_request, user, user_service):
        client = models.AuthClient(authority='partner.org', secret='bogus')
        db_session.add(client)
        db_session.flush()

        svc = oauth.OAuthService(db_session, user_service,
                                 pyramid_request.domain)

        token = svc.create_grant_token(user, client)

        decoded = jwt.decode(token, key=client.secret, leeway=240,
                             algorithms=['HS256'],
                             audience=pyramid_request.domain)

        assert decoded['aud'] == pyramid_request.domain
        assert decoded['iss'] == client.id
        assert decoded['sub'] == user.userid
Ejemplo n.º 2
0
 def svc(self, pyramid_request, db_session, user_service):
     return oauth.OAuthService(db_session, user_service,
                               pyramid_request.domain)