How to use the foremast.utils.get_template function in foremast

To help you get started, we’ve selected a few foremast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github foremast / foremast / tests / iam / test_iam_create.py View on Github external
def test_ec2_iam_policy():
    """Check template for proper format."""
    ec2_json = get_template(EC2_TEMPLATE_NAME)
    ec2_dict = json.loads(ec2_json)

    assert all(key in ec2_dict for key in ('Version', 'Statement'))
    assert len(ec2_dict['Statement']) == 1

    only_statement = ec2_dict['Statement'][0]

    assert only_statement['Action'] == 'sts:AssumeRole'
    assert only_statement['Effect'] == 'Allow'
    assert only_statement['Principal']['Service'] == 'ec2.amazonaws.com'
github foremast / foremast / tests / test_valid_json_templates.py View on Github external
def valid_json(template, data):
    parsed_template = get_template(template_file=template, data=data)

    assert type(json.loads(parsed_template)) == dict
github foremast / foremast / tests / test_valid_json_templates.py View on Github external
def test_get_template():
    with pytest.raises(ForemastTemplateNotFound):
        template = get_template(template_file='doesnotexist.json.j2')
github foremast / foremast / tests / iam / test_iam_create.py View on Github external
def test_lambda_iam_policy():
    """Check Lambda Trust Relationship template format."""
    lambda_json = get_template(LAMBDA_TEMPLATE_NAME)
    lambda_dict = json.loads(lambda_json)

    assert all(key in lambda_dict for key in ('Version', 'Statement'))
    assert len(lambda_dict['Statement']) == 1

    only_statement = lambda_dict['Statement'][0]

    assert only_statement['Action'] == 'sts:AssumeRole'
    assert only_statement['Effect'] == 'Allow'
    assert only_statement['Principal']['Service'] == 'lambda.amazonaws.com'
github foremast / foremast / tests / iam / test_iam_create.py View on Github external
def test_ec2_iam_policy():
    """Check template for proper format."""
    ec2_json = get_template(EC2_TEMPLATE_NAME)
    ec2_dict = json.loads(ec2_json)

    assert all(key in ec2_dict for key in ('Version', 'Statement'))
    assert len(ec2_dict['Statement']) == 1

    only_statement = ec2_dict['Statement'][0]

    assert only_statement['Action'] == 'sts:AssumeRole'
    assert only_statement['Effect'] == 'Allow'
    assert only_statement['Principal']['Service'] == 'ec2.amazonaws.com'
github foremast / foremast / tests / iam / test_iam_create.py View on Github external
def test_lambda_iam_policy():
    """Check Lambda Trust Relationship template format."""
    lambda_json = get_template(LAMBDA_TEMPLATE_NAME)
    lambda_dict = json.loads(lambda_json)

    assert all(key in lambda_dict for key in ('Version', 'Statement'))
    assert len(lambda_dict['Statement']) == 1

    only_statement = lambda_dict['Statement'][0]

    assert only_statement['Action'] == 'sts:AssumeRole'
    assert only_statement['Effect'] == 'Allow'
    assert only_statement['Principal']['Service'] == 'lambda.amazonaws.com'