def list_nodes(): """ Return a list of available nodes """ nodes = get_privacyidea_nodes() g.audit_object.log({"success": True}) return send_result(nodes)
def get_policy_defs(scope=None): """ This is a helper function that returns the POSSIBLE policy definitions, that can be used to define your policies. If the given scope is "conditions", this returns a dictionary with the following keys: * ``"sections"``, containing a dictionary mapping each condition section name to a dictionary with the following keys: * ``"description"``, a human-readable description of the section * ``"comparators"``, containing a dictionary mapping each comparator to a dictionary with the following keys: * ``"description"``, a human-readable description of the comparator if the scope is "pinodes", it returns a list of the configured privacyIDEA nodes. :query scope: if given, the function will only return policy definitions for the given scope. :return: The policy definitions of the allowed scope with the actions and action types. The top level key is the scope. :rtype: dict """ if scope == 'conditions': # special treatment: get descriptions of conditions section_descriptions = get_policy_condition_sections() comparator_descriptions = get_policy_condition_comparators() result = { "sections": section_descriptions, "comparators": comparator_descriptions, } elif scope == 'pinodes': result = get_privacyidea_nodes() else: static_pol = get_static_policy_definitions() dynamic_pol = get_dynamic_policy_definitions() # combine static and dynamic policies keys = list(static_pol) + list(dynamic_pol) result = { k: dict( list(static_pol.get(k, {}).items()) + list(dynamic_pol.get(k, {}).items())) for k in keys } if scope: result = result.get(scope) g.audit_object.log({"success": True, 'info': scope}) return send_result(result)
def test_07_node_names(self): node = get_privacyidea_node() self.assertEqual(node, "Node1") nodes = get_privacyidea_nodes() self.assertTrue("Node1" in nodes) self.assertTrue("Node2" in nodes)