-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename permission handlers to
check_permissions
and update tests.
- Loading branch information
Showing
3 changed files
with
32 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,49 @@ | ||
from goosebit.auth import compare_permission, compare_permissions | ||
from goosebit.auth import check_permissions | ||
|
||
|
||
def test_compare_single_permission(): | ||
assert compare_permission("home.read", "home.read") | ||
def test_single_permission(): | ||
assert check_permissions(["home.read"], ["home.read"]) | ||
|
||
|
||
def test_compare_inverted_single_permission(): | ||
assert not compare_permission("home.read", "!home.read") | ||
def test_inverted_single_permission(): | ||
assert not check_permissions(["home.read"], ["!home.read"]) | ||
|
||
|
||
def test_compare_wildcard_sub_permission(): | ||
assert compare_permission("home.read", "home.*") | ||
def test_wildcard_sub_permission(): | ||
assert check_permissions(["home.read"], ["home.*"]) | ||
|
||
|
||
def test_compare_inverted_wildcard_sub_permission(): | ||
assert not compare_permission("home.read", "!home.*") | ||
def test_inverted_wildcard_sub_permission(): | ||
assert not check_permissions(["home.read"], ["!home.*"]) | ||
|
||
|
||
def test_compare_root_permission(): | ||
assert compare_permission("home.read", "home") | ||
def test_root_permission(): | ||
assert check_permissions(["home.read"], ["home"]) | ||
|
||
|
||
def test_compare_inverted_root_permission(): | ||
assert not compare_permission("home.read", "!home") | ||
def test_inverted_root_permission(): | ||
assert not check_permissions(["home.read"], ["!home"]) | ||
|
||
|
||
def test_compare_root_wildcard_permission(): | ||
assert compare_permission("home.read", "*") | ||
def test_root_wildcard_permission(): | ||
assert check_permissions(["home.read"], ["*"]) | ||
|
||
|
||
def test_compare_inverted_root_wildcard_permission(): | ||
assert not compare_permission("home.read", "!*") | ||
def test_inverted_root_wildcard_permission(): | ||
assert not check_permissions(["home.read"], ["!*"]) | ||
|
||
|
||
def test_compare_multiple_single_permissions(): | ||
assert compare_permissions(["home.read", "device.write"], ["home.read", "device.write"]) | ||
def test_multiple_single_permissions(): | ||
assert check_permissions(["home.read", "device.write"], ["home.read", "device.write"]) | ||
|
||
|
||
def test_compare_invalid_multiple_single_permissions(): | ||
assert not compare_permissions(["home.read", "device.write"], ["home.read", "device.read"]) | ||
def test_invalid_multiple_single_permissions(): | ||
assert not check_permissions(["home.read", "device.write"], ["home.read", "device.read"]) | ||
|
||
|
||
def test_compare_inverted_multiple_permissions(): | ||
assert not compare_permissions(["home.read", "device.write"], ["home.read", "device", "!device.write"]) | ||
def test_inverted_multiple_permissions(): | ||
assert not check_permissions(["home.read", "device.write"], ["home.read", "device", "!device.write"]) | ||
|
||
|
||
def test_compare_multiple_root_wildcard_permissions(): | ||
assert compare_permissions( | ||
["home.read", "device.write", "device.read", "software.read"], ["*.read", "device.write"] | ||
) | ||
def test_multiple_root_wildcard_permissions(): | ||
assert check_permissions(["home.read", "device.write", "device.read", "software.read"], ["*.read", "device.write"]) |