Exemplo n.º 1
0
 def test_decode_auth_token(self):
     user = Customer(customer_mail_address='*****@*****.**',
                     customer_pin_hash=str(12612),
                     customer_first_name='foo',
                     customer_last_name='bar')
     db.session.add(user)
     db.session.commit()
     auth_token = user.encode_auth_token()
     self.assertTrue(isinstance(auth_token, bytes))
     resp = Customer.decode_auth_token(auth_token.decode("utf-8"))
     if resp['status'] == 'success':
         self.assertTrue(resp['customer'] == user.customer_mail_address)
     else:
         assert False
Exemplo n.º 2
0
def register_admin_customer():
    admin = Customer(customer_mail_address='*****@*****.**',
                     customer_first_name='admin',
                     customer_last_name='admin',
                     customer_pin_hash='12345')
    admin.customer_is_admin = True
    db.session.add(admin)
    try:
        db.session.commit()
    except IntegrityError:
        db.session.remove()
        raise Conflict(description=admin.__repr__() + ' already exists')
    response = {
        'mail_address': admin.customer_mail_address,
        'pin': 12345,
        'message': 'Login to get an admin token'
    }
    return response, 200