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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Python Integration Tests
Commits
6df13096
Commit
6df13096
authored
4 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
TST: Update test_permissions.py to new query errors
parent
fab42131
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_permissions.py
+95
-110
95 additions, 110 deletions
tests/test_permissions.py
with
95 additions
and
110 deletions
tests/test_permissions.py
+
95
−
110
View file @
6df13096
...
...
@@ -195,7 +195,6 @@ def test_basic_acl_stuff():
assert_false
(
"
DELETE
"
in
other_role_permissions
)
@with_setup
(
setup
,
teardown
)
def
test_query
():
person
=
db
.
RecordType
(
"
TestPerson
"
).
insert
()
db
.
Property
(
"
TestFirstName
"
,
datatype
=
db
.
TEXT
).
insert
()
...
...
@@ -210,30 +209,21 @@ def test_query():
name
=
"
TestConductor
"
,
value
=
dan
.
id
).
insert
()
assert_equal
(
db
.
execute_query
(
assert
db
.
execute_query
(
"
FIND TestExperiment WHICH HAS A TestConductor->TestPerson
"
,
unique
=
True
).
id
,
exp
.
id
)
assert_equal
(
db
.
execute_query
(
unique
=
True
).
id
==
exp
.
id
assert
db
.
execute_query
(
"
FIND TestExperiment WHICH HAS A TestConductor=TestPerson
"
,
unique
=
True
).
id
,
exp
.
id
)
assert_equal
(
db
.
execute_query
(
unique
=
True
).
id
==
exp
.
id
assert
db
.
execute_query
(
"
FIND TestExperiment WHICH HAS A TestConductor=
"
+
str
(
dan
.
id
),
unique
=
True
).
id
,
exp
.
id
)
assert_equal
(
db
.
execute_query
(
unique
=
True
).
id
==
exp
.
id
assert
db
.
execute_query
(
"
FIND TestExperiment
"
,
unique
=
True
).
id
,
exp
.
id
)
assert_equal
(
db
.
execute_query
(
unique
=
True
).
id
==
exp
.
id
assert
db
.
execute_query
(
"
FIND TestExperiment WHICH HAS A TestConductor WHICH has a TestFirstName=Daniel
"
,
unique
=
True
).
id
,
exp
.
id
)
unique
=
True
).
id
==
exp
.
id
'''
success
'''
grant_permission
(
person
,
"
RETRIEVE:*
"
)
...
...
@@ -241,11 +231,9 @@ def test_query():
grant_permission
(
exp
,
"
RETRIEVE:*
"
)
switch_to_test_user
()
assert_equal
(
db
.
execute_query
(
assert
db
.
execute_query
(
"
FIND TestExperiment WHICH HAS A TestConductor WHICH has a TestFirstName=Daniel
"
,
unique
=
True
).
id
,
exp
.
id
)
unique
=
True
).
id
==
exp
.
id
'''
failure - dan
'''
deny_permission
(
dan
,
"
RETRIEVE:*
"
)
...
...
@@ -253,11 +241,10 @@ def test_query():
# this fails if server is configured with
# QUERY_FILTER_ENTITIES_WITHOUT_RETRIEVE_PERMISSIONS = FALSE
with
raises
(
db
.
TransactionError
)
as
cm
:
with
raises
(
db
.
EmptyUniqueQueryError
)
:
db
.
execute_query
(
"
FIND TestExperiment WHICH HAS A TestConductor WHICH has a TestFirstName=Daniel
"
,
unique
=
True
)
assert
cm
.
value
.
has_error
(
db
.
EntityDoesNotExistError
)
'''
... but works without the which clause
'''
assert
db
.
execute_query
(
"
FIND TestExperiment
"
,
unique
=
True
).
id
==
exp
.
id
'''
and with the id
'''
...
...
@@ -270,15 +257,13 @@ def test_query():
deny_permission
(
exp
,
"
RETRIEVE:*
"
)
switch_to_test_user
()
with
raises
(
db
.
TransactionError
)
as
cm
:
with
raises
(
db
.
EmptyUniqueQueryError
)
:
db
.
execute_query
(
"
FIND TestExperiment WHICH HAS A TestConductor=TestDaniel
"
,
unique
=
True
)
assert
cm
.
value
.
has_error
(
db
.
EntityDoesNotExistError
)
with
raises
(
db
.
TransactionError
)
as
cm
:
with
raises
(
db
.
EmptyUniqueQueryError
)
:
db
.
execute_query
(
"
FIND TestExperiment
"
,
unique
=
True
)
assert
cm
.
value
.
has_error
(
db
.
EntityDoesNotExistError
)
@
with_setup
(
setup
,
teardown
)
...
...
@@ -1210,7 +1195,7 @@ def test_check_entity_acl_roles():
with
raises
(
db
.
TransactionError
)
as
cm
:
grant_permission
(
p
,
"
USE:AS_PARENT
"
,
username
=
"
asdf-non-existing
"
,
switch
=
False
)
errors
=
cm
.
value
.
entities
[
0
].
errors
errors
=
cm
.
value
.
entities
[
0
].
get_
errors
()
assert
errors
[
0
].
description
==
"
User Role does not exist.
"
db
.
administration
.
set_server_property
(
"
CHECK_ENTITY_ACL_ROLES_MODE
"
,
"
SHOULD
"
)
...
...
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