Ejemplo n.º 1
0
    def test_create_athena_table_tasks(self) -> None:
        mock_orgs = Mock(find_account_by_ids=Mock(return_value=[(account("8", "eight")), (account("3", "three"))]))
        year, month = date.today().year, date.today().month
        tasks = AwsTaskBuilder(mock_orgs, ["8", "3"]).create_athena_table_tasks(year, month)

        self.assert_cloudtrail_tasks_equal(AwsCreateAthenaTableTask(account("8", "eight"), partition()), tasks[0])
        self.assert_cloudtrail_tasks_equal(AwsCreateAthenaTableTask(account("3", "three"), partition()), tasks[1])
Ejemplo n.º 2
0
    def test_role_usage_scanner_tasks(self) -> None:
        mock_orgs = Mock(get_target_accounts=Mock(return_value=[(account("1", "one")), (account("2", "two"))]))
        year, month, role = date.today().year, date.today().month, "SomeRole"
        tasks = AwsTaskBuilder(mock_orgs).role_usage_scanner_tasks(year, month, role)

        self.assert_role_tasks_equal(AwsRoleUsageScannerTask(account("1", "one"), partition(), "SomeRole"), tasks[0])
        self.assert_role_tasks_equal(AwsRoleUsageScannerTask(account("2", "two"), partition(), "SomeRole"), tasks[1])
Ejemplo n.º 3
0
    def test_principal_by_ip_finder_tasks(self) -> None:
        mock_orgs = Mock(get_target_accounts=Mock(return_value=[(account("1", "one")), (account("2", "two"))]))
        year, month, source_ip = date.today().year, date.today().month, "127.0.0.1"
        tasks = AwsTaskBuilder(mock_orgs).principal_by_ip_finder_tasks(year, month, source_ip)

        self.assert_ip_tasks_equal(AwsPrincipalByIPFinderTask(account("1", "one"), partition(), "127.0.0.1"), tasks[0])
        self.assert_ip_tasks_equal(AwsPrincipalByIPFinderTask(account("2", "two"), partition(), "127.0.0.1"), tasks[1])
Ejemplo n.º 4
0
    def test_audit_s3_tasks(self) -> None:
        mock_orgs = Mock(find_account_by_ids=Mock(return_value=[(account("3", "three")), (account("5", "five"))]))
        tasks = AwsTaskBuilder(mock_orgs, ["5", "3"]).audit_s3_tasks()

        self.assert_tasks_equal(AwsAuditS3Task(account("3", "three")), tasks[0])
        self.assert_tasks_equal(AwsAuditS3Task(account("5", "five")), tasks[1])
Ejemplo n.º 5
0
    def test_list_ssm_parameters_tasks(self) -> None:
        mock_orgs = Mock(find_account_by_ids=Mock(return_value=[(account("2", "two")), (account("4", "four"))]))
        tasks = AwsTaskBuilder(mock_orgs, ["4", "2"]).list_ssm_parameters_tasks()

        self.assert_tasks_equal(AwsListSSMParametersTask(account("2", "two")), tasks[0])
        self.assert_tasks_equal(AwsListSSMParametersTask(account("4", "four")), tasks[1])
Ejemplo n.º 6
0
 def test_list_accounts_tasks(self) -> None:
     self.assertEqual([AwsListAccountsTask()], AwsTaskBuilder(Mock()).list_accounts_tasks())
Ejemplo n.º 7
0
 def test_clean_athena_tasks(self) -> None:
     self.assertEqual([AwsAthenaCleanerTask()], AwsTaskBuilder(Mock()).clean_athena_tasks())