Пример #1
0
    def test_client(self):
        user = self.create_user()

        client = self.create_client(user)

        assert client.user.id == user.id
        assert client.redirect_uris == ['http://example.com', 'http://example.com/2']
        assert client.default_scopes == ['email', 'user']
        assert client.default_redirect_uri == 'http://example.com'
        assert Client.get_for_oauth2('123').client_id == client.client_id
Пример #2
0
    def create_client(self, user, name='TextApp', description='An awesome test app', client_id='123', client_secret='abc',
                      is_confidential=True, default_scope=['email', 'user'],
                      redirect_uris=['http://example.com', 'http://example.com/2']):

        client_data = {
            'user': user,
            'name': name,
            'description': description,
            'client_id': client_id,
            'client_secret': client_secret,
            '_default_scopes': ' '.join(default_scope),
            '_redirect_uris': ' '.join(redirect_uris),
        }

        client = Client(**client_data)
        db.session.add(client)
        db.session.commit()

        return client
Пример #3
0
    def setUp(self):
        app = Flask(__name__)
        self.db_fd, self.path = tempfile.mkstemp()
        app.config['DEBUG'] = True
        app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///%s" % (self.path)
        app.register_blueprint(lark_admin_api, url_prefix='/admin')
        self.app = app
        self.client = app.test_client()
        self.request_ctx = self.app.test_request_context()
        self.request_ctx.push()
        db.create_all()
        self.client = app.test_client()

        user = User.create_user(username='******', password='******')
        self.user = user
        user2 = User.create_user(username='******', password='******')
        self.user2 = user2
        client = Client.create_from_user(user, {
            'name': 'Test Test',
            'description': 'test is testy',
            'redirect_uris': ['http://localhost:8000'],
        })
        self.oauth_client = client
Пример #4
0
def prepare_app(app):
    user = User(r_con, username='******', password='******')
    user.save()

    user2 = User(r_con, username='******', password='******')
    user2.save()

    client1 = Client(r_con, name='dev', client_id='dev', client_secret='dev',
                     user=user, redirect_uris=('http://localhost:8000/authorized',
                                               'http://localhost/authorized'))

    client1.save()

    client2 = Client(r_con, name='confidential', client_id='confidential',
                     client_secret='confidential', client_type='confidential',
                     user=user2, redirect_uris=('http://localhost:8000/authorized',
                                                'http://localhost/authorized'))

    client2.save()

    return app