2022-01-01 06:52:31 -08:00
|
|
|
# Copyright 2022 Google LLC
|
2020-04-08 05:54:49 -07:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2022-11-11 08:47:27 -08:00
|
|
|
from .validate_policies import validate_policy_boolean, validate_policy_list
|
2022-11-03 03:41:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
def test_policy_boolean(plan_runner):
|
|
|
|
"Test boolean org policy."
|
2022-11-11 08:47:27 -08:00
|
|
|
tfvars = 'test.orgpolicies-boolean.tfvars'
|
|
|
|
_, resources = plan_runner(tf_var_file=tfvars)
|
|
|
|
validate_policy_boolean(resources)
|
2022-11-03 03:41:53 -07:00
|
|
|
|
2022-10-28 05:40:53 -07:00
|
|
|
|
2022-11-03 03:41:53 -07:00
|
|
|
def test_policy_list(plan_runner):
|
|
|
|
"Test list org policy."
|
2022-11-11 08:47:27 -08:00
|
|
|
tfvars = 'test.orgpolicies-list.tfvars'
|
|
|
|
_, resources = plan_runner(tf_var_file=tfvars)
|
|
|
|
validate_policy_list(resources)
|
2022-11-03 03:41:53 -07:00
|
|
|
|
|
|
|
|
2022-11-11 08:47:27 -08:00
|
|
|
def test_factory_policy_boolean(plan_runner, tfvars_to_yaml, tmp_path):
|
|
|
|
dest = tmp_path / 'policies.yaml'
|
2022-12-02 11:07:15 -08:00
|
|
|
tfvars_to_yaml('fixture/test.orgpolicies-boolean.tfvars', dest,
|
|
|
|
'org_policies')
|
2022-11-03 03:41:53 -07:00
|
|
|
_, resources = plan_runner(org_policies_data_path=f'"{tmp_path}"')
|
2022-11-11 08:47:27 -08:00
|
|
|
validate_policy_boolean(resources)
|
2022-11-03 03:41:53 -07:00
|
|
|
|
|
|
|
|
2022-11-11 08:47:27 -08:00
|
|
|
def test_factory_policy_list(plan_runner, tfvars_to_yaml, tmp_path):
|
|
|
|
dest = tmp_path / 'policies.yaml'
|
2022-12-02 11:07:15 -08:00
|
|
|
tfvars_to_yaml('fixture/test.orgpolicies-list.tfvars', dest, 'org_policies')
|
2022-11-03 03:41:53 -07:00
|
|
|
_, resources = plan_runner(org_policies_data_path=f'"{tmp_path}"')
|
2022-11-11 08:47:27 -08:00
|
|
|
validate_policy_list(resources)
|