소스 검색

Test the remote_user and http_x_remote user backends

Unrud 8 년 전
부모
커밋
c2387403dd
1개의 변경된 파일28개의 추가작업 그리고 0개의 파일을 삭제
  1. 28 0
      radicale/tests/test_auth.py

+ 28 - 0
radicale/tests/test_auth.py

@@ -109,6 +109,34 @@ class TestBaseAuthRequests(BaseTest):
             "bcrypt",
             "tmp:$2y$05$oD7hbiQFQlvCM7zoalo/T.MssV3VNTRI3w5KDnj8NTUKJNWfVpvRq")
 
+    def test_remote_user(self):
+        self.configuration.set("auth", "type", "remote_user")
+        self.application = Application(self.configuration, self.logger)
+        status, _, answer = self.request(
+            "PROPFIND", "/",
+            """<?xml version="1.0" encoding="utf-8"?>
+               <propfind xmlns="DAV:">
+                 <prop>
+                   <current-user-principal />
+                 </prop>
+               </propfind>""", REMOTE_USER="test")
+        assert status == 207
+        assert ">/test/<" in answer
+
+    def test_http_x_remote_user(self):
+        self.configuration.set("auth", "type", "http_x_remote_user")
+        self.application = Application(self.configuration, self.logger)
+        status, _, answer = self.request(
+            "PROPFIND", "/",
+            """<?xml version="1.0" encoding="utf-8"?>
+               <propfind xmlns="DAV:">
+                 <prop>
+                   <current-user-principal />
+                 </prop>
+               </propfind>""", HTTP_X_REMOTE_USER="test")
+        assert status == 207
+        assert ">/test/<" in answer
+
     def test_custom(self):
         """Custom authentication."""
         self.configuration.set("auth", "type", "tests.custom.auth")