CORD-1870: Port policy fails when the instance field is missing
Change-Id: Idcda824d9a2c74716c7caf29c95db9c1dea78d1f
diff --git a/lib/xos-genx/tests/general_security_test.py b/lib/xos-genx/tests/general_security_test.py
index dbf8538..60eab97 100644
--- a/lib/xos-genx/tests/general_security_test.py
+++ b/lib/xos-genx/tests/general_security_test.py
@@ -161,6 +161,42 @@
verdict = output_security_check(obj, ctx)
self.assertTrue(verdict)
+ def test_call_policy_child_none(self):
+ xproto = \
+"""
+ policy sub_policy < ctx.user = obj.user >
+ policy output < *sub_policy(child) >
+"""
+
+ args = FakeArgs()
+ args.inputs = xproto
+ args.target = self.target
+
+ output = XOSGenerator.generate(args)
+
+ exec(output,globals()) # This loads the generated function, which should look like this:
+
+ """
+ def sub_policy_security_check(obj, ctx):
+ i1 = (ctx.user == obj.user)
+ return i1
+
+ def output_security_check(obj, ctx):
+ if obj.child:
+ i1 = sub_policy_security_check(obj.child, ctx)
+ else:
+ i1 = True
+ return i1
+ """
+
+ obj = FakeArgs()
+ obj.child = None
+
+ ctx = FakeArgs()
+ ctx.user = 1
+
+ verdict = output_security_check(obj, ctx)
+ self.assertTrue(verdict)
def test_bin(self):
xproto = \