当前位置: 首页>>代码示例>>Python>>正文


Python FakeArgs.user方法代码示例

本文整理汇总了Python中helpers.FakeArgs.user方法的典型用法代码示例。如果您正苦于以下问题:Python FakeArgs.user方法的具体用法?Python FakeArgs.user怎么用?Python FakeArgs.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在helpers.FakeArgs的用法示例。


在下文中一共展示了FakeArgs.user方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_equal

# 需要导入模块: from helpers import FakeArgs [as 别名]
# 或者: from helpers.FakeArgs import user [as 别名]
    def test_equal(self):
        xproto = \
"""
    policy output < not (ctx.user = obj.user) >
"""

        args = FakeArgs()
        args.inputs = xproto
        args.target = self.target

        output = XOSGenerator.generate(args)

        exec(output) # This loads the generated function, which should look like this:

        """
        def policy_output_validator(obj, ctx):
            i2 = (ctx.user == obj.user)
            i1 = (not i2)
            if (not i1):
                raise Exception('Necessary Failure')
        """

        obj = FakeArgs()
	obj.user = 1
        ctx = FakeArgs()
	ctx.user = 1

        with self.assertRaises(Exception):
           policy_output_validator(obj, ctx)
开发者ID:vpramo,项目名称:xos-1,代码行数:31,代码来源:general_validation_test.py

示例2: test_equal

# 需要导入模块: from helpers import FakeArgs [as 别名]
# 或者: from helpers.FakeArgs import user [as 别名]
    def test_equal(self):
        xproto = \
"""
    policy output < ctx.user = obj.user >
"""

        args = FakeArgs()
        args.inputs = xproto
        args.target = self.target

        output = XOSGenerator.generate(args)

        exec(output) # This loads the generated function, which should look like this:

        """
        def policy_output_enforcer(obj, ctx):
            i1 = (ctx.user == obj.user)
            return i1
        """

        obj = FakeArgs()
	obj.user = 1
        ctx = FakeArgs()
	ctx.user = 1

        verdict = policy_output_enforcer(obj, ctx)
开发者ID:vpramo,项目名称:xos-1,代码行数:28,代码来源:general_security_test.py

示例3: test_call_policy

# 需要导入模块: from helpers import FakeArgs [as 别名]
# 或者: from helpers.FakeArgs import user [as 别名]
    def test_call_policy(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 policy_sub_policy_enforcer(obj, ctx):
            i1 = (ctx.user == obj.user)
    	    return i1

	def policy_output_enforcer(obj, ctx):
	    i1 = policy_sub_policy_enforcer(obj.child, ctx)
	    return i1
        """

        obj = FakeArgs()
        obj.child = FakeArgs()
	obj.child.user = 1

        ctx = FakeArgs()
	ctx.user = 1

        verdict = policy_output_enforcer(obj, ctx)
        self.assertTrue(verdict)
开发者ID:vpramo,项目名称:xos-1,代码行数:36,代码来源:general_security_test.py

示例4: test_equal

# 需要导入模块: from helpers import FakeArgs [as 别名]
# 或者: from helpers.FakeArgs import user [as 别名]
    def test_equal(self):
        xproto = \
"""
    policy slice_user < slice.user = obj.user >
"""

        target = XProtoTestHelpers.write_tmp_target("{{ proto.policies.slice_user }}")
        args = FakeArgs()
        args.inputs = xproto
        args.target = target

        output = XOSGenerator.generate(args)
       
        slice = FakeArgs()
        slice.user = 'twin'
        obj = FakeArgs()
        obj.user = 'twin'

        (op, operands), = eval(output).items()
        expr = op.join(operands).replace('=','==')

        self.assertTrue(eval(expr))
开发者ID:vpramo,项目名称:xos-1,代码行数:24,代码来源:policy_test.py

示例5: test_term

# 需要导入模块: from helpers import FakeArgs [as 别名]
# 或者: from helpers.FakeArgs import user [as 别名]
    def test_term(self):
        xproto = \
"""
    policy slice_user < slice.user.is_admin >
"""

        target = XProtoTestHelpers.write_tmp_target("{{ proto.policies.slice_user }}")
        args = FakeArgs()
        args.inputs = xproto
        args.target = target

        output = XOSGenerator.generate(args)
       
        slice = FakeArgs()
        slice.user = FakeArgs()
        slice.user.is_admin = True

        expr = eval(output)
        self.assertTrue(expr)
开发者ID:vpramo,项目名称:xos-1,代码行数:21,代码来源:policy_test.py

示例6: test_call_policy

# 需要导入模块: from helpers import FakeArgs [as 别名]
# 或者: from helpers.FakeArgs import user [as 别名]
    def test_call_policy(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 policy_sub_policy_validator(obj, ctx):
            i1 = (ctx.user == obj.user)
            if (not i1):
                raise ValidationError('Necessary Failure')

        def policy_output_validator(obj, ctx):
            i1 = policy_sub_policy_validator(obj.child, ctx)
            if (not i1):
                raise ValidationError('Necessary Failure')
        """

        obj = FakeArgs()
        obj.child = FakeArgs()
	obj.child.user = 1

        ctx = FakeArgs()
	ctx.user = 1

        with self.assertRaises(Exception):
            verdict = policy_output_enforcer(obj, ctx)
开发者ID:vpramo,项目名称:xos-1,代码行数:38,代码来源:general_validation_test.py


注:本文中的helpers.FakeArgs.user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。