parent
0211e9d78d
commit
c9dd9cc7f9
8 changed files with 120 additions and 13 deletions
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
from six.moves.urllib.parse import quote
|
||||
|
||||
import pytest
|
||||
import sure # noqa
|
||||
|
||||
import moto.server as server
|
||||
|
|
@ -17,4 +21,32 @@ def test_iot_list():
|
|||
|
||||
# just making sure that server is up
|
||||
res = test_client.get("/things")
|
||||
res.status_code.should.equal(404)
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"url_encode_arn",
|
||||
[
|
||||
pytest.param(True, id="Target Arn in Path is URL encoded"),
|
||||
pytest.param(False, id="Target Arn in Path is *not* URL encoded"),
|
||||
],
|
||||
)
|
||||
@mock_iot
|
||||
def test_list_attached_policies(url_encode_arn):
|
||||
backend = server.create_backend_app("iot")
|
||||
test_client = backend.test_client()
|
||||
|
||||
result = test_client.post("/keys-and-certificate?setAsActive=true")
|
||||
result_dict = json.loads(result.data.decode("utf-8"))
|
||||
certificate_arn = result_dict["certificateArn"]
|
||||
|
||||
test_client.post("/policies/my-policy", json={"policyDocument": {}})
|
||||
test_client.put("/target-policies/my-policy", json={"target": certificate_arn})
|
||||
|
||||
if url_encode_arn:
|
||||
certificate_arn = quote(certificate_arn, safe="")
|
||||
|
||||
result = test_client.post("/attached-policies/{}".format(certificate_arn))
|
||||
result.status_code.should.equal(200)
|
||||
result_dict = json.loads(result.data.decode("utf-8"))
|
||||
result_dict["policies"][0]["policyName"].should.equal("my-policy")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from six.moves.urllib.parse import quote
|
||||
|
||||
import pytest
|
||||
import sure # noqa
|
||||
|
||||
import moto.server as server
|
||||
|
|
@ -19,3 +22,22 @@ def test_iotdata_list():
|
|||
thing_name = "nothing"
|
||||
res = test_client.get("/things/{}/shadow".format(thing_name))
|
||||
res.status_code.should.equal(404)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"url_encode_topic",
|
||||
[
|
||||
pytest.param(True, id="Topic in Path is URL encoded"),
|
||||
pytest.param(False, id="Topic in Path is *not* URL encoded"),
|
||||
],
|
||||
)
|
||||
@mock_iotdata
|
||||
def test_publish(url_encode_topic):
|
||||
backend = server.create_backend_app("iot-data")
|
||||
test_client = backend.test_client()
|
||||
|
||||
topic = "test/topic"
|
||||
topic_for_path = quote(topic, safe="") if url_encode_topic else topic
|
||||
|
||||
result = test_client.post("/topics/{}".format(topic_for_path))
|
||||
result.status_code.should.equal(200)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue