You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

2 years ago
  1. import time
  2. import pytest
  3. from fe.access import auth
  4. from fe import conf
  5. class TestLogin:
  6. @pytest.fixture(autouse=True)
  7. def pre_run_initialization(self):
  8. self.auth = auth.Auth(conf.URL)
  9. # register a user
  10. self.user_id = "test_login_{}".format(time.time())
  11. self.password = "password_" + self.user_id
  12. self.terminal = "terminal_" + self.user_id
  13. assert self.auth.register(self.user_id, self.password) == 200
  14. yield
  15. def test_ok(self):
  16. code, token = self.auth.login(self.user_id, self.password, self.terminal)
  17. assert code == 200
  18. code = self.auth.logout(self.user_id + "_x", token)
  19. assert code == 401
  20. code = self.auth.logout(self.user_id, token + "_x")
  21. assert code == 401
  22. code = self.auth.logout(self.user_id, token)
  23. assert code == 200
  24. def test_error_user_id(self):
  25. code, token = self.auth.login(self.user_id + "_x", self.password, self.terminal)
  26. assert code == 401
  27. def test_error_password(self):
  28. code, token = self.auth.login(self.user_id, self.password + "_x", self.terminal)
  29. assert code == 401