Exemplo n.º 1
0
def test_encode_and_decode_token(db):
    user = models.User(fullname=faker.name(),
                       username=faker.name(),
                       password=faker.text(16))
    user.is_active = True
    db.add(user)
    db.commit()
    access_token = auth.generate_access_token(user.username)

    data_decoded = auth.decode_token(access_token)
    assert data_decoded['sub'] == user.username
Exemplo n.º 2
0
 def setUp(self):
     super().setUp()
     user = models.User(username=faker.name(),
                        fullname=faker.name(),
                        password=faker.text(16),
                        is_active=True)
     models.session.add(user)
     models.session.commit()
     self.user = user
     access_token = auth.generate_access_token(user.username)
     self.data = {
         'title': faker.text(20),
     }
     self.headers = {'Authorization': f'Bearer {access_token}'}
Exemplo n.º 3
0
 def setUp(self):
     super().setUp()
     user = models.User(username=faker.name(),
                        fullname=faker.name(),
                        password=faker.text(16),
                        is_active=True)
     models.session.add(user)
     models.session.flush()
     tasks = list()
     for _ in range(3):
         task = models.Task(title=faker.name(),
                            created_by=user.username,
                            description=faker.text())
         models.session.add(task)
         tasks.append(task)
     models.session.commit()
     self.user = user
     self.tasks = tasks
     access_token = auth.generate_access_token(user.username)
     self.data = {
         'title': faker.text(20),
     }
     self.headers = {'Authorization': f'Bearer {access_token}'}