Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
177348ce
Verified
Commit
177348ce
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
TST: add new tests for ACL
parent
ecf16ac0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!53
Release 0.7.2
,
!49
F parse acl
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_acl.py
+50
-0
50 additions, 0 deletions
unittests/test_acl.py
with
50 additions
and
0 deletions
unittests/test_acl.py
0 → 100644
+
50
−
0
View file @
177348ce
# -*- encoding: utf-8 -*-
#
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2022 Indiscale GmbH <info@indiscale.com>
# Copyright (C) 2022 Timm Fitschen <f.fitschen@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
import
caosdb
as
db
from
lxml
import
etree
def
test_parse_xml
():
xml_str
=
"""
<EntityACL>
<Grant priority=
"
False
"
role=
"
role1
"
>
<Permission name=
"
RETRIEVE:ENTITY
"
/>
</Grant>
<Deny priority=
"
False
"
role=
"
role1
"
>
<Permission name=
"
RETRIEVE:ENTITY
"
/>
</Deny>
<Grant priority=
"
True
"
role=
"
role1
"
>
<Permission name=
"
RETRIEVE:ENTITY
"
/>
</Grant>
<Deny priority=
"
True
"
role=
"
role1
"
>
<Permission name=
"
RETRIEVE:ENTITY
"
/>
</Deny>
</EntityACL>
"""
xml
=
etree
.
fromstring
(
xml_str
)
left_acl
=
db
.
ACL
(
xml
)
right_acl
=
db
.
ACL
()
right_acl
.
grant
(
role
=
"
role1
"
,
permission
=
"
RETRIEVE:ENTITY
"
,
revoke_denial
=
False
)
right_acl
.
deny
(
role
=
"
role1
"
,
permission
=
"
RETRIEVE:ENTITY
"
,
revoke_grant
=
False
)
right_acl
.
grant
(
role
=
"
role1
"
,
permission
=
"
RETRIEVE:ENTITY
"
,
priority
=
True
,
revoke_denial
=
False
)
right_acl
.
deny
(
role
=
"
role1
"
,
permission
=
"
RETRIEVE:ENTITY
"
,
priority
=
True
,
revoke_grant
=
False
)
assert
left_acl
==
right_acl
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment