test_auth.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- coding: utf-8 -*-
  2. #
  3. # This file is part of Radicale Server - Calendar Server
  4. # Copyright © 2012-2013 Guillaume Ayoub
  5. # Copyright © 2012-2013 Jean-Marc Martins
  6. #
  7. # This library is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with Radicale. If not, see <http://www.gnu.org/licenses/>.
  19. """
  20. Radicale tests with simple requests and authentication.
  21. """
  22. from nose import with_setup
  23. from . import HtpasswdAuthSystem
  24. class TestBaseAuthRequests(HtpasswdAuthSystem):
  25. """
  26. Tests basic requests with auth.
  27. ..note Only htpasswd works at the moment since
  28. it requires to spawn processes running servers for
  29. others auth methods (ldap).
  30. """
  31. @with_setup(HtpasswdAuthSystem.setup, HtpasswdAuthSystem.teardown)
  32. def test_root(self):
  33. """Tests a GET request at "/"."""
  34. status, headers, answer = self.request(
  35. "GET", "/", HTTP_AUTHORIZATION=self.userpass)
  36. assert status == 200
  37. assert "Radicale works!" in answer