-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from mathom/roleupdate
Update the IAM role if it exists
- Loading branch information
Showing
15 changed files
with
155 additions
and
27 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
tests/placebo/TestZappa.test_create_iam_roles/iam.CreateRole_1.json
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,26 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"Role": { | ||
"AssumeRolePolicyDocument": "%7B%0A%20%20%22Version%22%3A%20%222012-10-17%22%2C%0A%20%20%22Statement%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22Sid%22%3A%20%22%22%2C%0A%20%20%20%20%20%20%22Effect%22%3A%20%22Allow%22%2C%0A%20%20%20%20%20%20%22Principal%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22Service%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%22lambda.amazonaws.com%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22apigateway.amazonaws.com%22%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22Action%22%3A%20%22sts%3AAssumeRole%22%0A%20%20%20%20%7D%0A%20%20%5D%0A%7D", | ||
"RoleId": "AROAIJTKAN7OBBD7BF25O", | ||
"CreateDate": { | ||
"hour": 1, | ||
"__class__": "datetime", | ||
"month": 2, | ||
"second": 20, | ||
"microsecond": 221000, | ||
"year": 2016, | ||
"day": 25, | ||
"minute": 28 | ||
}, | ||
"RoleName": "ZappaLambdaExecution", | ||
"Path": "/", | ||
"Arn": "arn:aws:iam::123:role/ZappaLambdaExecution" | ||
}, | ||
"ResponseMetadata": { | ||
"HTTPStatusCode": 200, | ||
"RequestId": "0da2623f-db5f-11e5-9d89-67e11bce6785" | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/placebo/TestZappa.test_create_iam_roles/iam.GetRolePolicy_1.json
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,14 @@ | ||
{ | ||
"status_code": 404, | ||
"data": { | ||
"ResponseMetadata": { | ||
"HTTPStatusCode": 404, | ||
"RequestId": "0e11c69f-db5f-11e5-aa20-65c7ceb91dfa" | ||
}, | ||
"Error": { | ||
"Message": "The role policy with name zappa-permissions cannot be found.", | ||
"Code": "NoSuchEntity", | ||
"Type": "Sender" | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/placebo/TestZappa.test_create_iam_roles/iam.GetRole_1.json
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,14 @@ | ||
{ | ||
"status_code": 404, | ||
"data": { | ||
"ResponseMetadata": { | ||
"HTTPStatusCode": 404, | ||
"RequestId": "0d24322f-db5f-11e5-9d89-67e11bce6785" | ||
}, | ||
"Error": { | ||
"Message": "The role with name ZappaLambdaExecution cannot be found.", | ||
"Code": "NoSuchEntity", | ||
"Type": "Sender" | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/placebo/TestZappa.test_create_iam_roles/iam.PutRolePolicy_1.json
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,9 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"ResponseMetadata": { | ||
"HTTPStatusCode": 200, | ||
"RequestId": "0e619422-db5f-11e5-9d89-67e11bce6785" | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import placebo | ||
import boto3 | ||
import os | ||
import functools | ||
|
||
PLACEBO_DIR = os.path.join(os.path.dirname(__file__), 'placebo') | ||
|
||
|
||
def placebo_session(function): | ||
""" | ||
Decorator to help do testing with placebo. | ||
Simply wrap the function you want to test and make sure to add | ||
a "session" argument so the decorator can pass the placebo session. | ||
Accepts the following environment variables to configure placebo: | ||
PLACEBO_MODE: set to "record" to record AWS calls and save them | ||
PLACEBO_PROFILE: optionally set an AWS credential profile to record with | ||
""" | ||
|
||
@functools.wraps(function) | ||
def wrapper(*args, **kwargs): | ||
session_kwargs = {} | ||
profile_name = os.environ.get('PLACEBO_PROFILE', None) | ||
if profile_name: | ||
session_kwargs['profile_name'] = profile_name | ||
|
||
session = boto3.Session(**session_kwargs) | ||
|
||
self = args[0] | ||
prefix = self.__class__.__name__ + '.' + function.__name__ | ||
record_dir = os.path.join(PLACEBO_DIR, prefix) | ||
|
||
if not os.path.exists(record_dir): | ||
os.makedirs(record_dir) | ||
|
||
pill = placebo.attach(session, data_path=record_dir) | ||
|
||
if os.environ.get('PLACEBO_MODE') == 'record': | ||
pill.record() | ||
else: | ||
pill.playback() | ||
|
||
kwargs['session'] = session | ||
|
||
return function(*args, **kwargs) | ||
|
||
return wrapper |
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