Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Python Integration Tests
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 Python Integration Tests
Commits
79e249ef
Verified
Commit
79e249ef
authored
2 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
TST: corner case where a role has the PROPERTY:ADD but not the REMOVE permission
parent
3b9fd769
No related branches found
No related tags found
1 merge request
!38
TST: corner case where a role has the PROPERTY:ADD but not the REMOVE permission
Pipeline
#25212
passed
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_issues_server.py
+58
-0
58 additions, 0 deletions
tests/test_issues_server.py
with
58 additions
and
0 deletions
tests/test_issues_server.py
+
58
−
0
View file @
79e249ef
...
...
@@ -943,3 +943,61 @@ def test_147():
rec3
=
db
.
Record
(
"
TestRec3
"
).
add_parent
(
"
TestRT
"
).
add_property
(
"
TestPropInt
"
,
1
).
insert
()
assert
db
.
execute_query
(
"
FIND TestRT WITH TestPropInt < 2
"
,
unique
=
True
).
id
==
rec3
.
id
assert
db
.
execute_query
(
"
FIND TestRT WITH TestPropInt < 2.5
"
,
unique
=
True
).
id
==
rec3
.
id
def
test_140
():
"""
https://gitlab.com/caosdb/caosdb-server/-/issues/140
"""
admin
.
_insert_role
(
name
=
CURATOR_ROLE
,
description
=
"
Desc
"
)
perms
=
admin
.
_get_permissions
(
CURATOR_ROLE
)
g
=
admin
.
PermissionRule
(
action
=
"
Grant
"
,
permission
=
"
TRANSACTION:*
"
)
perms
.
add
(
g
)
admin
.
_set_permissions
(
CURATOR_ROLE
,
permission_rules
=
perms
)
admin
.
_insert_user
(
name
=
"
TestUser
"
,
password
=
"
Password1!
"
,
status
=
"
ACTIVE
"
)
admin
.
_set_roles
(
username
=
"
TestUser
"
,
roles
=
[
CURATOR_ROLE
])
core_model_deny_permissions
=
[
"
DELETE
"
,
"
UPDATE:*
"
,
"
EDIT:ACL
"
]
core_model_grant_permissions
=
[
"
RETRIEVE:*
"
,
"
USE:*
"
,
"
UPDATE:PROPERTY:ADD
"
]
prop
=
db
.
Property
(
name
=
"
TestProp
"
,
datatype
=
db
.
TEXT
).
insert
()
rt
=
db
.
RecordType
(
name
=
"
TestRT
"
).
insert
(
flags
=
{
"
ACL
"
:
None
})
for
d
in
core_model_deny_permissions
:
# First deny s.th. later the "UPDATE:PROPERTY:ADD" permission can be granted explicitely
rt
.
deny
(
role
=
CURATOR_ROLE
,
permission
=
d
)
rt
.
update_acl
()
# retrieve again to be sure
rt
.
retrieve
(
flags
=
{
"
ACL
"
:
None
})
for
g
in
core_model_grant_permissions
:
rt
.
grant
(
role
=
CURATOR_ROLE
,
permission
=
g
)
rt
.
update_acl
()
print
(
rt
.
acl
)
db
.
configure_connection
(
username
=
"
TestUser
"
,
password_method
=
"
plain
"
,
password
=
"
Password1!
"
)
assert
db
.
Info
().
user_info
.
name
==
"
TestUser
"
assert
db
.
Info
().
user_info
.
roles
==
[
CURATOR_ROLE
]
rt
.
add_property
(
prop
)
rt
.
get_property
(
"
TestProp
"
).
value
=
"
some value
"
# this should succeed because the curator has UPDATE:PROPERTY:ADD
rt
.
update
()
assert
rt
.
get_property
(
"
TestProp
"
).
value
==
"
some value
"
rt
.
get_property
(
"
TestProp
"
).
value
=
"
some other value
"
with
pytest
.
raises
(
TransactionError
)
as
cm
:
# this should fail because the curator doesn't have
# UPDATE:PROPERTY:REMOVE
rt
.
update
()
assert
cm
.
value
.
errors
[
0
].
msg
==
"
You are not allowed to do this.
"
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