-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes two issues to get elastictranscoder working: * account for the `rest-json` service type in `get_response()` * account for query strings coming from the url path in sigv4 signer I've also added integration tests that verify we can talk to the Elastic Transcoder service as expected.
- Loading branch information
Showing
5 changed files
with
172 additions
and
28 deletions.
There are no files selected for viewing
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
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,105 @@ | ||
# Copyright (c) 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a | ||
# copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, dis- | ||
# tribute, sublicense, and/or sell copies of the Software, and to permit | ||
# persons to whom the Software is furnished to do so, subject to the fol- | ||
# lowing conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | ||
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | ||
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
# IN THE SOFTWARE. | ||
# | ||
from tests import unittest | ||
import functools | ||
import random | ||
|
||
import botocore.session | ||
|
||
DEFAULT_ROLE_POLICY = """\ | ||
{"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Principal": { | ||
"Service": "elastictranscoder.amazonaws.com" | ||
}, | ||
"Effect": "Allow", | ||
"Sid": "1" | ||
} | ||
]} | ||
""" | ||
|
||
class TestElasticTranscoder(unittest.TestCase): | ||
def setUp(self): | ||
self.session = botocore.session.get_session() | ||
self.service = self.session.get_service('elastictranscoder') | ||
self.endpoint = self.service.get_endpoint('us-east-1') | ||
|
||
def create_bucket(self): | ||
s3 = self.session.get_service('s3') | ||
bucket_name = 'ets-bucket-1-%s' % random.randint(1, 1000000) | ||
create_bucket = s3.get_operation('CreateBucket') | ||
delete_bucket = s3.get_operation('DeleteBucket') | ||
endpoint = s3.get_endpoint('us-east-1') | ||
response = create_bucket.call(endpoint, bucket=bucket_name)[0] | ||
self.assertEqual(response.status_code, 200) | ||
self.addCleanup( | ||
functools.partial(delete_bucket.call, endpoint, | ||
bucket=bucket_name)) | ||
return bucket_name | ||
|
||
def create_iam_role(self): | ||
iam = self.session.get_service('iam') | ||
endpoint = iam.get_endpoint('us-east-1') | ||
create_role = iam.get_operation('CreateRole') | ||
delete_role = iam.get_operation('DeleteRole') | ||
role_name = 'ets-role-name-1-%s' % random.randint(1, 1000000) | ||
response, parsed = create_role.call(endpoint, role_name=role_name, | ||
assume_role_policy_document=DEFAULT_ROLE_POLICY) | ||
self.assertEqual(response.status_code, 200) | ||
arn = parsed['Role']['Arn'] | ||
self.addCleanup( | ||
functools.partial(delete_role.call, endpoint, role_name=role_name)) | ||
return arn | ||
|
||
def test_list_streams(self): | ||
operation = self.service.get_operation('ListPipelines') | ||
http, parsed = operation.call(self.endpoint) | ||
self.assertEqual(http.status_code, 200) | ||
self.assertIn('Pipelines', parsed) | ||
|
||
def test_list_presets(self): | ||
operation = self.service.get_operation('ListPresets') | ||
http, parsed = operation.call(self.endpoint, ascending='true') | ||
self.assertEqual(http.status_code, 200) | ||
self.assertIn('Presets', parsed) | ||
|
||
def test_create_pipeline(self): | ||
# In order to create a pipeline, we need to create 2 s3 buckets | ||
# and 1 iam role. | ||
input_bucket = self.create_bucket() | ||
output_bucket = self.create_bucket() | ||
role = self.create_iam_role() | ||
pipeline_name = 'botocore-test-create-%s' % (random.randint(1, 1000000)) | ||
|
||
operation = self.service.get_operation('CreatePipeline') | ||
http, parsed = operation.call( | ||
self.endpoint, input_bucket=input_bucket, output_bucket=output_bucket, | ||
role=role, name=pipeline_name, | ||
notifications={'Progressing': '', 'Completed': '', | ||
'Warning': '', 'Error': ''}) | ||
self.assertEqual(http.status_code, 201) | ||
self.assertIn('Pipeline', parsed) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
1 change: 1 addition & 0 deletions
1
tests/unit/response_parsing/json/inputs/elastictranscoder-list-pipelines.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 @@ | ||
{"NextPageToken":null,"Pipelines":[{"Arn":"arn:aws:elastictranscoder:us-west-2:12345:pipeline/12345","ContentConfig":{"Bucket":"pipeline-12345","Permissions":[],"StorageClass":"Standard"},"Id":"12345","InputBucket":"12345","Name":"test-pipeline","Notifications":{"Completed":"","Error":"","Progressing":"","Warning":""},"OutputBucket":null,"Role":"arn:aws:iam::12345:role/Elastic_Transcoder_Default_Role","Status":"Active","ThumbnailConfig":{"Bucket":"12345","Permissions":[],"StorageClass":"Standard"}}]} |
30 changes: 30 additions & 0 deletions
30
tests/unit/response_parsing/json/outputs/elastictranscoder-list-pipelines.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,30 @@ | ||
{ | ||
"NextPageToken": null, | ||
"Pipelines": [ | ||
{ | ||
"ContentConfig": { | ||
"Bucket": "pipeline-12345", | ||
"StorageClass": "Standard", | ||
"Permissions": [] | ||
}, | ||
"Status": "Active", | ||
"Name": "test-pipeline", | ||
"ThumbnailConfig": { | ||
"Bucket": "12345", | ||
"StorageClass": "Standard", | ||
"Permissions": [] | ||
}, | ||
"Notifications": { | ||
"Completed": "", | ||
"Warning": "", | ||
"Progressing": "", | ||
"Error": "" | ||
}, | ||
"Role": "arn:aws:iam::12345:role/Elastic_Transcoder_Default_Role", | ||
"InputBucket": "12345", | ||
"OutputBucket": null, | ||
"Id": "12345", | ||
"Arn": "arn:aws:elastictranscoder:us-west-2:12345:pipeline/12345" | ||
} | ||
] | ||
} |