forked from Kozea/Radicale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip group collection match when groups are not used
- Loading branch information
Showing
4 changed files
with
19 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,10 +30,10 @@ class TestBaseRightsRequests(BaseTest): | |
def _test_rights(self, rights_type: str, user: str, path: str, mode: str, | ||
expected_status: int, with_auth: bool = True) -> None: | ||
assert mode in ("r", "w") | ||
assert user in ("", "tmp") | ||
assert user in ("", "tmp", "[email protected]") | ||
htpasswd_file_path = os.path.join(self.colpath, ".htpasswd") | ||
with open(htpasswd_file_path, "w") as f: | ||
f.write("tmp:bepo\nother:bepo") | ||
f.write("tmp:bepo\nother:bepo\n[email protected]:bepo") | ||
self.configure({ | ||
"rights": {"type": rights_type}, | ||
"auth": {"type": "htpasswd" if with_auth else "none", | ||
|
@@ -42,8 +42,9 @@ def _test_rights(self, rights_type: str, user: str, path: str, mode: str, | |
for u in ("tmp", "other"): | ||
# Indirect creation of principal collection | ||
self.propfind("/%s/" % u, login="%s:bepo" % u) | ||
os.makedirs(os.path.join(self.colpath, "collection-root", "domain.test"), exist_ok=True) | ||
(self.propfind if mode == "r" else self.proppatch)( | ||
path, check=expected_status, login="tmp:bepo" if user else None) | ||
path, check=expected_status, login="%s:bepo" % user if user else None) | ||
|
||
def test_owner_only(self) -> None: | ||
self._test_rights("owner_only", "", "/", "r", 401) | ||
|
@@ -110,14 +111,23 @@ def test_from_file(self) -> None: | |
[custom] | ||
user: .* | ||
collection: custom(/.*)? | ||
permissions: Rr""") | ||
permissions: Rr | ||
[read-domain-principal] | ||
user: .+@([^@]+) | ||
collection: {0} | ||
permissions: R""") | ||
self.configure({"rights": {"file": rights_file_path}}) | ||
self._test_rights("from_file", "", "/other/", "r", 401) | ||
self._test_rights("from_file", "tmp", "/tmp/", "r", 207) | ||
self._test_rights("from_file", "tmp", "/other/", "r", 403) | ||
self._test_rights("from_file", "", "/custom/sub", "r", 404) | ||
self._test_rights("from_file", "tmp", "/custom/sub", "r", 404) | ||
self._test_rights("from_file", "", "/custom/sub", "w", 401) | ||
self._test_rights("from_file", "tmp", "/custom/sub", "w", 403) | ||
self._test_rights("from_file", "tmp", "/custom/sub", "w", 403) | ||
self._test_rights("from_file", "[email protected]", "/domain.test/", "r", 207) | ||
self._test_rights("from_file", "[email protected]", "/tmp/", "r", 403) | ||
self._test_rights("from_file", "[email protected]", "/other/", "r", 403) | ||
|
||
def test_from_file_limited_get(self): | ||
rights_file_path = os.path.join(self.colpath, "rights") | ||
|