Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
added custom s3 policy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pidah committed Apr 14, 2015
1 parent 83b6c1b commit c41e14a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/sample-custom-s3-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ "Action": ["s3:Get*", "s3:Put*", "s3:List*", "s3:Delete*"],
"Resource": "arn:aws:s3:::moj-test-dev-static/*",
"Effect": "Allow",
"Principal": { "AWS": "*" }
}
27 changes: 27 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,33 @@ def test_s3(self):
config = ConfigParser(ProjectConfig('tests/sample-project.yaml', 'dev').config, 'my-stack-name')
self.assertEquals(known, config.s3())

def test_custom_s3_policy(self):
expected_s3 = [
{
'Action': [
's3:Get*',
's3:Put*',
's3:List*',
's3:Delete*'],
'Resource': 'arn:aws:s3:::moj-test-dev-static/*',
'Effect': 'Allow',
'Principal': {'AWS': '*'}
}
]

project_config = ProjectConfig('tests/sample-project.yaml', 'dev')

project_config.config['s3'] = {
'static-bucket-name': 'moj-test-dev-static',
'policy': 'tests/sample-custom-s3-policy.json'}

config = ConfigParser(project_config.config, 'my-stack-name')
s3_cfg = config.s3()
s3_custom_cfg = s3_cfg['StaticBucketPolicy'][
'Properties']['PolicyDocument']['Statement']

compare(expected_s3, s3_custom_cfg)

def test_rds(self):
known = {
'DBSecurityGroup': {
Expand Down

0 comments on commit c41e14a

Please sign in to comment.