コード例 #1
0
    def setUp(self, mock_org_dao, mock_folder_dao, mock_project_dao):
        mock_org_dao.return_value = None
        mock_folder_dao.return_value = None
        mock_project_dao.return_value = None
        self.org_res_rel_dao = org_resource_rel_dao.OrgResourceRelDao({})

        # TODO: move this to separate module
        self.fake_org = organization.Organization(
            organization_id=1,
            display_name='Org 1')
        self.fake_folder1 = folder.Folder(
            folder_id=11,
            display_name='Folder 1',
            parent=self.fake_org)
        self.fake_folder2 = folder.Folder(
            folder_id=22,
            display_name='Folder 2',
            parent=self.fake_folder1)
        self.fake_project1 = project.Project(
            project_number=111,
            project_id='project-1',
            display_name='Project 1',
            parent=self.fake_folder2)

        self.fake_timestamp = '1234567890'
コード例 #2
0
    def __init__(self,
                 global_configs,
                 rule_defs=None,
                 snapshot_timestamp=None,
                 group_defs=None,
                 org_policy=None):
        """Initialize.

        Args:
          global_configs (dict): Global configurations.
          rule_defs (list): The parsed list of dictionary rules from the YAML
            definition file.
          snapshot_timestamp (str): The snapshot to work with.
          group_defs (list): The parsed list of dictionary group ids to rules.
          org_policy (dict): The parsed org policy configuration.
        """
        super(RuleBook, self).__init__()
        self.rule_indices = {}
        self.rules_map = {}
        self.rule_groups_map = {}
        self.org_policy_rules_map = {}
        self.org_res_rel_dao = org_resource_rel_dao.OrgResourceRelDao(
            global_configs)
        self.snapshot_timestamp = snapshot_timestamp or None
        self._repository_lock = threading.RLock()
        if rule_defs:
            self.add_rules(rule_defs)
        if group_defs:
            self.add_rule_groups(group_defs)
        if org_policy:
            self.add_org_policy(org_policy)
コード例 #3
0
    def __init__(self, rule_defs=None, snapshot_timestamp=None):
        """Initialize.

        Args:
            rule_defs: The parsed dictionary of rules from the YAML
                definition file.
            snapshot_timestamp: The snapshot to lookup data.
        """
        super(IamRuleBook, self).__init__()
        self._rules_sema = threading.BoundedSemaphore(value=1)
        self.resource_rules_map = {}
        if not rule_defs:
            self.rule_defs = {}
        else:
            self.rule_defs = rule_defs
            self.add_rules(rule_defs)
        if snapshot_timestamp:
            self.snapshot_timestamp = snapshot_timestamp
        self.org_res_rel_dao = org_resource_rel_dao.OrgResourceRelDao()
コード例 #4
0
    def __init__(self, global_configs, rule_defs=None, snapshot_timestamp=None):
        """Initialization.

        Args:
            global_configs (dict): Global configurations.
            rule_defs (list): KE Version rule definition dicts
            snapshot_timestamp (int): Snapshot timestamp.
        """
        super(KeVersionRuleBook, self).__init__()
        self._lock = threading.Lock()
        self.resource_rules_map = {}
        if not rule_defs:
            self.rule_defs = {}
        else:
            self.rule_defs = rule_defs
            self.add_rules(rule_defs)

        self.snapshot_timestamp = snapshot_timestamp
        self.org_res_rel_dao = org_resource_rel_dao.OrgResourceRelDao(
            global_configs)
        self.project_dao = project_dao.ProjectDao(global_configs)