Esempio n. 1
0
    def create_user(self, username='******', password='******', external_access_token='abc', remote_user_id=3):
        user_data = {
            'username': username,
            'password': password,
            'external_access_token': external_access_token,
            'remote_user_id': remote_user_id,
        }

        user = User.create_user(**user_data)
        db.session.add(user)
        db.session.commit()

        return user
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
0
    def test_user(self):
        user = self.create_user()

        assert User.get_for_oauth2('voidfiles', 'awesome', {}, {}).id == user.id
Esempio n. 5
0
 def load_current_user():
     user = User.by_pk(r_con, 1)
     g.user = user