def test_batch_create_at_mangement_group(self): with change_dir(TESTINGPATH): path = os.path.join(os.getcwd(), "azure_policy_definitions") policy_definition_list = list() with change_dir(path): for file in glob.glob("*.json"): policy_definition_path = os.path.abspath(file) base_name = os.path.basename(policy_definition_path) policy_defintion_name = os.path.splitext(base_name)[0] if not os.path.isfile(policy_definition_path): raise FileNotFoundError policy_definition_list.append({ "policy_defintion_name": policy_defintion_name, "policy_definition_path": policy_definition_path }) if len(policy_definition_list) > 0: policy_definition_client = MopPolicyDefinition( operations_path=TESTINGPATH, config_variables=TESTVARIABLES) policy_definition_client.batch_create_at_mangement_group( self.management_group_id, policy_definition_list)
def __init__(self, operations_path=OPERATIONSPATH, config_variables=CONFVARIABLES): with change_dir(operations_path): self.config = ConfigParser() self.config.read(config_variables) self.subscription_id = self.config["DEFAULT"][ "azure_subscription_id"] self.management_group_id = self.config["DEFAULT"][ "azure_management_group_id"] self.operations_path = operations_path self.config_variables = config_variables
def setUp(self) -> None: load_dotenv() with change_dir(TESTINGPATH): self.config = ConfigParser() self.config.read(TESTVARIABLES) self.test_data_config = ConfigParser() test_data_file = self.config['DEFAULT']['test_data_file'] self.test_data_config.read(test_data_file) self.subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] self.tenant_id = os.environ["AZURE_TENANT_ID"] self.management_group_id = os.environ["AZURE_MANAGEMENT_GROUP_ID"] client_id = os.environ["CLIENT"] client_secret = os.environ["KEY"] logging_level = self.config['LOGGING']['level'] logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
def main(): with change_dir(OPERATIONSPATH): create_baseline_configuration(CONFVARIABLES) with change_dir(TESTINGPATH): create_baseline_configuration(TESTVARIABLES)