2014-08-27 15:17:06 +00:00
|
|
|
from __future__ import unicode_literals
|
2015-08-02 14:27:08 +00:00
|
|
|
|
|
|
|
import json
|
2015-08-02 15:37:10 +00:00
|
|
|
from six.moves.urllib.parse import urlencode
|
2015-08-02 14:27:08 +00:00
|
|
|
import re
|
2015-08-02 15:37:10 +00:00
|
|
|
import sure # noqa
|
2015-08-02 14:27:08 +00:00
|
|
|
|
|
|
|
import moto.server as server
|
|
|
|
|
|
|
|
'''
|
|
|
|
Test the different server responses
|
|
|
|
'''
|
|
|
|
|
2015-08-02 15:37:10 +00:00
|
|
|
|
2015-08-02 14:27:08 +00:00
|
|
|
def test_cloudformation_server_get():
|
|
|
|
backend = server.create_backend_app("cloudformation")
|
|
|
|
stack_name = 'test stack'
|
|
|
|
test_client = backend.test_client()
|
|
|
|
template_body = {
|
|
|
|
"Resources": {},
|
|
|
|
}
|
|
|
|
res = test_client.get(
|
|
|
|
'/?{0}'.format(
|
2015-08-02 15:37:10 +00:00
|
|
|
urlencode({
|
|
|
|
"Action": "CreateStack",
|
|
|
|
"StackName": stack_name,
|
|
|
|
"TemplateBody": json.dumps(template_body)
|
|
|
|
})
|
|
|
|
),
|
|
|
|
headers={"Host": "cloudformation.us-east-1.amazonaws.com"}
|
2015-08-02 14:27:08 +00:00
|
|
|
)
|
2015-08-02 15:37:10 +00:00
|
|
|
stack_id = json.loads(res.data.decode("utf-8"))["CreateStackResponse"]["CreateStackResult"]["StackId"]
|
2015-08-02 14:27:08 +00:00
|
|
|
|
|
|
|
res = test_client.get(
|
|
|
|
'/?Action=ListStacks',
|
2015-08-02 15:37:10 +00:00
|
|
|
headers={"Host": "cloudformation.us-east-1.amazonaws.com"}
|
2015-08-02 14:27:08 +00:00
|
|
|
)
|
|
|
|
stacks = re.search("<StackId>(.*)</StackId>", res.data.decode('utf-8'))
|
|
|
|
|
|
|
|
list_stack_id = stacks.groups()[0]
|
|
|
|
assert stack_id == list_stack_id
|