Skip to content
Snippets Groups Projects

Revert "WIP: pipeline"

Open Florian Spreckelsen requested to merge f-update-acl into dev
2 unresolved threads
1 file
+ 58
0
Compare changes
  • Side-by-side
  • Inline
+ 58
0
@@ -1350,3 +1350,61 @@ def test_select_query_with_invisible_reference():
@@ -1350,3 +1350,61 @@ def test_select_query_with_invisible_reference():
values = select_results.get_property_values(*value_args)[0]
values = select_results.get_property_values(*value_args)[0]
assert values[0] is None
assert values[0] is None
assert values[1] is None
assert values[1] is None
 
 
 
def test_update_acl_with_unique():
Please register or sign in to reply
 
"""Test that ACL can be updated despite name duplications with
 
``unique=False``.
 
 
"""
 
 
rt = db.RecordType(name="TestType").insert()
 
# Name duplicate
 
rec1 = db.Record(name="TestRec").add_parent(rt).insert()
 
# This should be invisible to test at first:
 
rec1.retrieve(flags={"ACL": None})
 
rec1.deny(username=test_user, priority=False, permission="RETRIEVE:*")
 
rec1.update_acl()
 
rec2 = db.Record(name="TestRec").add_parent(rt).insert(unique=False)
 
switch_to_test_user()
 
with raises(db.TransactionError):
 
# Should be invisible to test user here
 
rec = db.Record(id=rec1.id).retrieve()
 
switch_to_admin_user()
 
rec1.retrieve(flags={"ACL": None})
 
rec1.grant(username=test_user, priority=True, permission="RETRIEVE:*")
 
with raises(db.TransactionError):
 
# This should fail due to name collision
 
rec1.update_acl()
 
# This shouldn't
 
rec1.update_acl(unique=False)
 
 
# test user should be able to see this
 
switch_to_test_user()
 
rec = db.Record(id=rec1.id).retrieve()
 
assert rec.name == rec1.name
 
assert rec.name == rec2.name
 
 
 
def test_container_update_unique():
    • ... and this shows that you would not have needed it in the first place, at least, if you're willing to sacrifice the sanity checks of Entity.update_acl.

Please register or sign in to reply
 
"""Test that ACL updates are performed correctly within a Container."""
 
 
# Both are visible to test at first
 
rt = db.RecordType(name="TestType").insert()
 
rec1 = db.Record(name="TestRec").add_parent(rt).insert()
 
rec2 = db.Record(name="TestRec").add_parent(rt).insert(unique=False)
 
 
switch_to_test_user()
 
ents = db.execute_query("FIND ENTITY TestType")
 
assert len(ents) == 3
 
 
switch_to_admin_user()
 
cont = db.Container().extend([rt, rec1, rec2])
 
cont.retrieve(flags={"ACL": None})
 
for ent in cont:
 
ent.deny(username=test_user, priority=False, permission="RETRIEVE:*")
 
cont.update(unique=False)
 
 
switch_to_test_user()
 
ents = db.execute_query("FIND ENTITY TestType")
 
assert len(ents) == 0
Loading