Пример #1
0
    def setUp(self):

        self.app = expungeservice.create_app('development')
        self.client = self.app.test_client()

        with self.app.app_context():
            expungeservice.request.before()

            self.db_cleanup()
            user.create_user(g.database, self.email, self.hashed_password, False)
            user.create_user(g.database, self.admin_email, self.hashed_admin_password, True)
            expungeservice.request.teardown(None)
Пример #2
0
def test_access_expired_auth_token():
    app = expungeservice.create_app('development')
    app.config['JWT_EXPIRY_TIMER'] = datetime.timedelta(seconds=0)

    client = app.test_client()

    response = get_auth_token(client, '*****@*****.**', 'test_password')
    time.sleep(1)
    response = client.get('/api/v0.1/test/protected',
                          headers={
                              'Authorization':
                              'Bearer {}'.format(
                                  response.get_json()['auth_token'])
                          })
    assert (response.status_code == 401)
Пример #3
0
    def setUp(self):

        self.app = expungeservice.create_app('development')
        self.client = self.app.test_client()

        self.app.add_url_rule(
            '/api/test/user_protected',
            view_func=UserProtectedView.as_view('user_protected'))
        self.app.add_url_rule(
            '/api/test/admin_protected',
            view_func=AdminProtectedView.as_view('admin_protected'))

        with self.app.app_context():
            expungeservice.request.before()

            self.db_cleanup()
            user.create_user(g.database, self.email, self.hashed_password,
                             False)
            expungeservice.request.teardown(None)
Пример #4
0
    def setUp(self):

        self.app = expungeservice.create_app("development")
        self.client = self.app.test_client()

        self.app.add_url_rule(
            "/api/test/user_protected",
            view_func=UserProtectedView.as_view("user_protected"))
        self.app.add_url_rule(
            "/api/test/admin_protected",
            view_func=AdminProtectedView.as_view("admin_protected"))

        with self.app.app_context():
            expungeservice.request.before()

            self.db_cleanup()
            create_result = user.create(g.database, self.email, self.name,
                                        self.group_name, self.hashed_password,
                                        False)
            self.ids[self.email] = create_result["user_id"]
            create_result = user.create(g.database, self.admin_email,
                                        self.admin_name, self.admin_group_name,
                                        self.hashed_admin_password, True)
            self.ids[self.admin_email] = create_result["user_id"]
            expungeservice.request.teardown(None)

        generate_auth_response = self.generate_auth_token(
            self.email, self.password)

        self.user_auth_header = {
            "Authorization":
            "Bearer {}".format(generate_auth_response.get_json()["auth_token"])
        }

        generate_auth_response = self.generate_auth_token(
            self.admin_email, self.admin_password)

        self.admin_auth_header = {
            "Authorization":
            "Bearer {}".format(generate_auth_response.get_json()["auth_token"])
        }
Пример #5
0
    def setUp(self):

        self.app = expungeservice.create_app("development")
        self.client = self.app.test_client()

        self.app.add_url_rule(
            "/api/test/user_protected",
            view_func=UserProtectedView.as_view("user_protected"))
        self.app.add_url_rule(
            "/api/test/admin_protected",
            view_func=AdminProtectedView.as_view("admin_protected"))

        with self.app.app_context():
            expungeservice.request.before()
            self.db_cleanup()

            self.create_test_user("user1")
            self.create_test_user("user2")
            self.create_test_user("admin")
            g.database.connection.commit()

            expungeservice.request.teardown(None)
Пример #6
0
 def __init__(self):
     self.app = expungeservice.create_app("development")
     self.client = self.app.test_client()
Пример #7
0
def app():
    return expungeservice.create_app('development')