def test_encode_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))
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