def test_primitive_mark_for_op(mock_type_marked_for_op_rewrite): assert C7N_Rewriter.primitive(sentinel.resource, {"type": "marked-for-op"}) == str( sentinel.rewritten) assert mock_type_marked_for_op_rewrite.mock_calls == [ call(sentinel.resource, {'type': 'marked-for-op'}) ]
def test_health_event_rewrite(): clause_0 = {"type": "health-event", "statuses": ["upcoming", "open"]} expected_0 = 'size(resource.get_health_events(["upcoming", "open"])) > 0' assert C7N_Rewriter.health_event_rewrite("directory", clause_0) == expected_0 clause_1 = "health-event" assert C7N_Rewriter.primitive("directory", clause_1) == expected_0
def test_primitive_absent(mock_type_value_rewrite): clause = {"tag:aws:autoscaling:groupName": "absent"} assert C7N_Rewriter.primitive(sentinel.resource, clause) == str(sentinel.rewritten) assert mock_type_value_rewrite.mock_calls == [ call(sentinel.resource, clause) ]
def test_is_logging_rewrite(): clause_0 = {"type": "is-logging"} expected_0 = 'resource.get_access_log().exists(a, a["Enabled"])' assert C7N_Rewriter.is_logging_rewrite("elb", clause_0) == expected_0 clause_1 = "is-logging" assert C7N_Rewriter.primitive("elb", clause_1) == expected_0 clause_2 = {"type": "is-logging"} expected_2 = 'resource.get_load_balancer().get("access_logs.s3.enabled")' assert C7N_Rewriter.is_logging_rewrite("app-elb", clause_2) == expected_2 with raises(ValueError): C7N_Rewriter.is_logging_rewrite("nope", clause_2)
def test_shield_enabled_rewrite(): clause_0 = {"type": "shield-enabled", "state": False} expected_0 = '! resource.shield_protection()' assert C7N_Rewriter.shield_enabled_rewrite("elb", clause_0) == expected_0 expected_1 = '! resource.shield_subscription()' assert C7N_Rewriter.primitive("account", clause_0) == expected_1
def test_is_not_logging_rewrite(): clause_0 = {"type": "is-not-logging"} expected_0 = '! resource.get_access_log().exists(a, a["Enabled"])' assert C7N_Rewriter.is_not_logging_rewrite("elb", clause_0) == expected_0 clause_1 = "is-not-logging" assert C7N_Rewriter.primitive("elb", clause_1) == expected_0
def test_unused_rewrite(): clause_0 = {"type": "unused"} expected_0 = '! resource["LaunchConfigurationName"] in all_launch_configuration_names()' assert C7N_Rewriter.unused_rewrite("asg", clause_0) == expected_0 clause_1 = "unused" assert C7N_Rewriter.primitive("asg", clause_1) == expected_0
def test_primitive_event(mock_type_event_rewrite): assert C7N_Rewriter.primitive(sentinel.resource, {"type": "event"}) == str(sentinel.rewritten) assert mock_type_event_rewrite.mock_calls == [ call(sentinel.resource, {'type': 'event'}) ]
def test_primitive_image_age(mock_type_image_age_rewrite): assert C7N_Rewriter.primitive( sentinel.resource, {"type": "image-age"}) == str(sentinel.rewritten) assert mock_type_image_age_rewrite.mock_calls == [ call(sentinel.resource, {'type': 'image-age'}) ]
def test_primitive_value(mock_type_value_rewrite): assert C7N_Rewriter.primitive(sentinel.resource, {"type": "value"}) == str(sentinel.rewritten) assert mock_type_value_rewrite.mock_calls == [ call(sentinel.resource, {'type': 'value'}) ]