Merge pull request #2105 from pbiering/regression-user-is-email
Additional test cases if user is email
This commit is contained in:
@@ -385,6 +385,16 @@ class TestBaseAuthRequests(BaseTest):
|
||||
self._test_htpasswd("plain", "tmp:bepo", (
|
||||
("tmp", "bepo", True), ("tmp@domain.example", "bepo", True), ("tmp1", "bepo", False)))
|
||||
|
||||
def test_htpasswd_email_encoding_url_true(self) -> None:
|
||||
self.configure({"auth": {"urldecode_username": "True"}})
|
||||
self._test_htpasswd("plain", "tmp@domain.example:bepo", (
|
||||
("tmp", "bepo", False), ("tmp%40domain.example", "bepo", True), ("tmp@domain.example", "bepo", True)))
|
||||
|
||||
def test_htpasswd_email_encoding_url_false(self) -> None:
|
||||
self.configure({"auth": {"urldecode_username": "False"}})
|
||||
self._test_htpasswd("plain", "tmp@domain.example:bepo", (
|
||||
("tmp", "bepo", False), ("tmp%40domain.example", "bepo", False), ("tmp@domain.example", "bepo", True)))
|
||||
|
||||
def test_remote_user(self) -> None:
|
||||
self.configure({"auth": {"type": "remote_user"}})
|
||||
_, responses = self.propfind("/", """\
|
||||
|
||||
@@ -27,6 +27,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import urllib
|
||||
from typing import Dict, Sequence, Tuple, Union
|
||||
|
||||
import pytest
|
||||
@@ -48,6 +49,10 @@ class TestSharingApiSanity(BaseTest):
|
||||
encoding: str = self.configuration.get("encoding", "stock")
|
||||
htpasswd = ["owner:ownerpw", "user:userpw",
|
||||
"owner1:owner1pw", "user1:user1pw",
|
||||
"owner@domain.example:owner@pw", "user@domain.example:user@pw",
|
||||
"owner.surename@domain.example:owner@pw", "user.surename@domain.example:user@pw",
|
||||
"owner-surename@domain.example:owner@pw", "user-surename@domain.example:user@pw",
|
||||
"owner_surename@domain.example:owner@pw", "user_surename@domain.example:user@pw",
|
||||
"us😀er:user😀pw",
|
||||
"owner2:owner2pw", "user2:user2pw"]
|
||||
htpasswd_content = "\n".join(htpasswd)
|
||||
@@ -1098,6 +1103,68 @@ class TestSharingApiSanity(BaseTest):
|
||||
json_dict['PathMapped'] = path_owner
|
||||
_, headers, answer = self._sharing_api_json("map", "create", 409, login="owner:ownerpw", json_dict=json_dict)
|
||||
|
||||
def test_sharing_api_map_basic_email(self) -> None:
|
||||
"""share-by-map API basic tests."""
|
||||
self.configure({"auth": {"type": "htpasswd",
|
||||
"htpasswd_filename": self.htpasswd_file_path,
|
||||
"htpasswd_encryption": "plain"},
|
||||
"sharing": {
|
||||
"type": "csv",
|
||||
"collection_by_map": "True",
|
||||
"collection_by_token": "True"},
|
||||
"logging": {"request_header_on_debug": "False",
|
||||
"response_content_on_debug": "True",
|
||||
"request_content_on_debug": "True"},
|
||||
"rights": {"type": "owner_only"}})
|
||||
|
||||
json_dict: dict
|
||||
|
||||
for (owner, user) in [
|
||||
("owner@domain.example", "user@domain.example"),
|
||||
("owner.surename@domain.example", "user.surename@domain.example"),
|
||||
("owner-surename@domain.example", "user-surename@domain.example"),
|
||||
("owner_surename@domain.example", "user_surename@domain.example"),
|
||||
]:
|
||||
|
||||
path_owner = "/" + owner + "/calendar.ics/"
|
||||
path_user_base = "/" + user + "/"
|
||||
path_user = path_user_base + "calendar-owner.ics/"
|
||||
self.mkcalendar(path_owner, login=owner + ":owner@pw")
|
||||
|
||||
for db_type in list(filter(lambda item: item != "none", sharing.INTERNAL_TYPES)):
|
||||
self.configure({"sharing": {"permit_create_map": "True"}})
|
||||
|
||||
logging.info("\n*** test: %s", db_type)
|
||||
self.configure({"sharing": {"type": db_type}})
|
||||
|
||||
logging.info("\n*** create map with PathMapped, User, PathOrToken (json) -> 200")
|
||||
json_dict = {}
|
||||
json_dict['User'] = user
|
||||
json_dict['PathOrToken'] = path_user
|
||||
json_dict['PathMapped'] = path_owner
|
||||
json_dict['Enabled'] = True
|
||||
json_dict['Hidden'] = False
|
||||
_, headers, answer = self._sharing_api_json("map", "create", 200, login=owner + ":owner@pw", json_dict=json_dict)
|
||||
|
||||
logging.info("\n*** enable+unhide (json) -> 200")
|
||||
json_dict = {}
|
||||
json_dict['PathOrToken'] = path_user
|
||||
json_dict['Enabled'] = True
|
||||
json_dict['Hidden'] = False
|
||||
_, headers, answer = self._sharing_api_json("map", "update", 200, login=user + ":user@pw", json_dict=json_dict)
|
||||
|
||||
# check PROPFIND as user
|
||||
logging.info("\n*** PROPFIND collection user -> ok")
|
||||
_, responses = self.propfind(path_user_base, """\
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<propfind xmlns="DAV:">
|
||||
<calendar-home-set xmlns="urn:ietf:params:xml:ns:caldav" />
|
||||
</propfind>""", login=user + ":user@pw", HTTP_DEPTH="1")
|
||||
assert len(responses) == 2
|
||||
logging.info("response: %r", responses)
|
||||
response = responses[urllib.parse.quote(path_user)]
|
||||
assert isinstance(response, dict)
|
||||
|
||||
def test_sharing_api_map_usage(self) -> None:
|
||||
"""share-by-map API usage tests."""
|
||||
self.configure({"auth": {"type": "htpasswd",
|
||||
|
||||
Reference in New Issue
Block a user