def test_AuthorizationOn(): model.initialize_registry() cap = model.Capability(label="test-log_tcp_complete-core") res = azn.AuthorizationOn(get_config(config_path)) assert_true(isinstance(res, azn.AuthorizationOn)) assert_true(res.check(cap, id_true_role)) assert_false(res.check(cap, id_false_role))
def create_test_capability(): model.initialize_registry() cap = model.Capability() cap.set_when("now ... future / 1s") cap.add_parameter("source.ip4", "10.0.27.2") cap.add_parameter("destination.ip4") cap.add_result_column("delay.twoway.icmp.us.min") cap.add_result_column("delay.twoway.icmp.us.max") cap.add_result_column("delay.twoway.icmp.us.mean") cap.add_result_column("delay.twoway.icmp.count") cap.add_result_column("packets.lost") return cap
def test_split_stmt_list(): model.initialize_registry() cap = model.Capability() cap.set_when("now ... future / 1s") cap.add_parameter("source.ip4", "10.0.27.2") cap.add_parameter("destination.ip4") cap.add_result_column("delay.twoway.icmp.us.min") cap.add_result_column("delay.twoway.icmp.us.max") cap.add_result_column("delay.twoway.icmp.us.mean") cap.add_result_column("delay.twoway.icmp.count") cap.add_result_column("packets.lost") capjson = model.unparse_json(cap) res = utils.split_stmt_list('['+capjson+']') caps = [] caps.append(cap) # using repr as no __eq__ methos is implemented fot capability objects assert_equal(repr(res[0]), repr(caps[0]))
def test_split_stmt_list(): model.initialize_registry() cap = model.Capability() cap.set_when("now ... future / 1s") cap.add_parameter("source.ip4", "10.0.27.2") cap.add_parameter("destination.ip4") cap.add_result_column("delay.twoway.icmp.us.min") cap.add_result_column("delay.twoway.icmp.us.max") cap.add_result_column("delay.twoway.icmp.us.mean") cap.add_result_column("delay.twoway.icmp.count") cap.add_result_column("packets.lost") capjson = model.unparse_json(cap) res = utils.split_stmt_list('[' + capjson + ']') caps = [] caps.append(cap) # using repr as no __eq__ methos is implemented fot capability objects assert_equal(repr(res[0]), repr(caps[0]))