-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ce86e9
commit d214e8a
Showing
18 changed files
with
476 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...puppet/workflow/service_control_policies/do_execute_service_control_policies_task_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
from unittest import skip | ||
from servicecatalog_puppet.workflow import tasks_unit_tests_helper | ||
|
||
|
||
class DoExecuteServiceControlPoliciesTaskTest( | ||
tasks_unit_tests_helper.PuppetTaskUnitTest | ||
): | ||
service_control_policy_name = "service_control_policy_name" | ||
region = "region" | ||
account_id = "account_id" | ||
ou_name = "ou_name" | ||
content = {} | ||
description = "description" | ||
manifest_file_path = "manifest_file_path" | ||
requested_priority = 1 | ||
|
||
def setUp(self) -> None: | ||
from servicecatalog_puppet.workflow.service_control_policies import ( | ||
do_execute_service_control_policies_task, | ||
) | ||
|
||
self.module = do_execute_service_control_policies_task | ||
|
||
self.sut = self.module.DoExecuteServiceControlPoliciesTask( | ||
**self.get_common_args(), | ||
service_control_policy_name=self.service_control_policy_name, | ||
region=self.region, | ||
account_id=self.account_id, | ||
ou_name=self.ou_name, | ||
content=self.content, | ||
description=self.description, | ||
manifest_file_path=self.manifest_file_path, | ||
requested_priority=self.requested_priority, | ||
) | ||
|
||
self.wire_up_mocks() | ||
|
||
def test_params_for_results_display(self): | ||
# setup | ||
expected_result = { | ||
"puppet_account_id": self.puppet_account_id, | ||
"service_control_policy_name": self.service_control_policy_name, | ||
"region": self.region, | ||
"account_id": self.account_id, | ||
"ou_name": self.ou_name, | ||
"cache_invalidator": self.cache_invalidator, | ||
} | ||
|
||
# exercise | ||
actual_result = self.sut.params_for_results_display() | ||
|
||
# verify | ||
self.assertEqual(expected_result, actual_result) | ||
|
||
@skip | ||
def test_requires(self): | ||
# setup | ||
# exercise | ||
actual_result = self.sut.requires() | ||
|
||
# verify | ||
raise NotImplementedError() | ||
|
||
def test_api_calls_used(self): | ||
# setup | ||
expected_result = [ | ||
f"organizations.attach_policy_{self.region}", | ||
] | ||
|
||
# exercise | ||
actual_result = self.sut.api_calls_used() | ||
|
||
# verify | ||
self.assertEqual(expected_result, actual_result) | ||
|
||
@skip | ||
def test_run(self): | ||
# setup | ||
# exercise | ||
actual_result = self.sut.run() | ||
|
||
# verify | ||
raise NotImplementedError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...ppet/workflow/service_control_policies/do_terminate_service_control_policies_task_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
from unittest import skip | ||
from servicecatalog_puppet.workflow import tasks_unit_tests_helper | ||
|
||
|
||
class DoTerminateServiceControlPoliciesTaskTest( | ||
tasks_unit_tests_helper.PuppetTaskUnitTest | ||
): | ||
service_control_policy_name = "service_control_policy_name" | ||
region = "region" | ||
account_id = "account_id" | ||
ou_name = "ou_name" | ||
content = {} | ||
description = "description" | ||
manifest_file_path = "manifest_file_path" | ||
requested_priority = 1 | ||
|
||
def setUp(self) -> None: | ||
from servicecatalog_puppet.workflow.service_control_policies import ( | ||
do_terminate_service_control_policies_task, | ||
) | ||
|
||
self.module = do_terminate_service_control_policies_task | ||
|
||
self.sut = self.module.DoTerminateServiceControlPoliciesTask( | ||
**self.get_common_args(), | ||
service_control_policy_name=self.service_control_policy_name, | ||
region=self.region, | ||
account_id=self.account_id, | ||
ou_name=self.ou_name, | ||
content=self.content, | ||
description=self.description, | ||
manifest_file_path=self.manifest_file_path, | ||
requested_priority=self.requested_priority, | ||
) | ||
|
||
self.wire_up_mocks() | ||
|
||
def test_params_for_results_display(self): | ||
# setup | ||
expected_result = { | ||
"puppet_account_id": self.puppet_account_id, | ||
"service_control_policy_name": self.service_control_policy_name, | ||
"region": self.region, | ||
"account_id": self.account_id, | ||
"ou_name": self.ou_name, | ||
"cache_invalidator": self.cache_invalidator, | ||
} | ||
|
||
# exercise | ||
actual_result = self.sut.params_for_results_display() | ||
|
||
# verify | ||
self.assertEqual(expected_result, actual_result) | ||
|
||
@skip | ||
def test_requires(self): | ||
# setup | ||
# exercise | ||
actual_result = self.sut.requires() | ||
|
||
# verify | ||
raise NotImplementedError() | ||
|
||
def test_api_calls_used(self): | ||
# setup | ||
expected_result = [ | ||
f"organizations.detach_policy_{self.region}", | ||
] | ||
|
||
# exercise | ||
actual_result = self.sut.api_calls_used() | ||
|
||
# verify | ||
self.assertEqual(expected_result, actual_result) | ||
|
||
@skip | ||
def test_run(self): | ||
# setup | ||
# exercise | ||
actual_result = self.sut.run() | ||
|
||
# verify | ||
raise NotImplementedError() |
89 changes: 89 additions & 0 deletions
89
servicecatalog_puppet/workflow/simulate_policies/do_execute_simulate_policy_task_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
from unittest import skip | ||
from servicecatalog_puppet.workflow import tasks_unit_tests_helper | ||
|
||
|
||
class DoExecuteSimulatePolicyTaskTest(tasks_unit_tests_helper.PuppetTaskUnitTest): | ||
simulate_policy_name = "simulate_policy_name" | ||
region = "region" | ||
account_id = "account_id" | ||
execution = "execution" | ||
simulation_type = "simulation_type" | ||
policy_source_arn = "policy_source_arn" | ||
policy_input_list = [] | ||
permissions_boundary_policy_input_list = [] | ||
action_names = [] | ||
expected_decision = "expected_decision" | ||
resource_arns = [] | ||
resource_policy = "resource_policy" | ||
resource_owner = "resource_owner" | ||
caller_arn = "caller_arn" | ||
context_entries = [] | ||
resource_handling_option = "resource_handling_option" | ||
requested_priority = 1 | ||
|
||
def setUp(self) -> None: | ||
from servicecatalog_puppet.workflow.simulate_policies import ( | ||
do_execute_simulate_policy_task, | ||
) | ||
|
||
self.module = do_execute_simulate_policy_task | ||
|
||
self.sut = self.module.DoExecuteSimulatePolicyTask( | ||
**self.get_common_args(), | ||
simulate_policy_name=self.simulate_policy_name, | ||
region=self.region, | ||
account_id=self.account_id, | ||
execution=self.execution, | ||
simulation_type=self.simulation_type, | ||
policy_source_arn=self.policy_source_arn, | ||
policy_input_list=self.policy_input_list, | ||
permissions_boundary_policy_input_list=self.permissions_boundary_policy_input_list, | ||
action_names=self.action_names, | ||
expected_decision=self.expected_decision, | ||
resource_arns=self.resource_arns, | ||
resource_policy=self.resource_policy, | ||
resource_owner=self.resource_owner, | ||
caller_arn=self.caller_arn, | ||
context_entries=self.context_entries, | ||
resource_handling_option=self.resource_handling_option, | ||
requested_priority=self.requested_priority, | ||
) | ||
|
||
self.wire_up_mocks() | ||
|
||
def test_params_for_results_display(self): | ||
# setup | ||
expected_result = { | ||
"puppet_account_id": self.puppet_account_id, | ||
"simulate_policy_name": self.simulate_policy_name, | ||
"region": self.region, | ||
"account_id": self.account_id, | ||
"cache_invalidator": self.cache_invalidator, | ||
} | ||
|
||
# exercise | ||
actual_result = self.sut.params_for_results_display() | ||
|
||
# verify | ||
self.assertEqual(expected_result, actual_result) | ||
|
||
def test_api_calls_used(self): | ||
# setup | ||
expected_result = [ | ||
f"iam.simulate_{self.simulation_type}_policy_{self.account_id}_{self.region}" | ||
] | ||
|
||
# exercise | ||
actual_result = self.sut.api_calls_used() | ||
|
||
# verify | ||
self.assertEqual(expected_result, actual_result) | ||
|
||
@skip | ||
def test_run(self): | ||
# setup | ||
# exercise | ||
actual_result = self.sut.run() | ||
|
||
# verify | ||
raise NotImplementedError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.