Merge pull request #1634 from sthuber90/master
Fixes #1624 and closes #1633
This commit is contained in:
commit
0f816566df
8 changed files with 381 additions and 26 deletions
|
|
@ -418,7 +418,7 @@ def test_get_authorization_token_assume_region():
|
|||
auth_token_response.should.contain('ResponseMetadata')
|
||||
auth_token_response['authorizationData'].should.equal([
|
||||
{
|
||||
'authorizationToken': 'QVdTOnVzLWVhc3QtMS1hdXRoLXRva2Vu',
|
||||
'authorizationToken': 'QVdTOjAxMjM0NTY3ODkxMC1hdXRoLXRva2Vu',
|
||||
'proxyEndpoint': 'https://012345678910.dkr.ecr.us-east-1.amazonaws.com',
|
||||
'expiresAt': datetime(2015, 1, 1, tzinfo=tzlocal())
|
||||
},
|
||||
|
|
@ -428,19 +428,19 @@ def test_get_authorization_token_assume_region():
|
|||
@mock_ecr
|
||||
def test_get_authorization_token_explicit_regions():
|
||||
client = boto3.client('ecr', region_name='us-east-1')
|
||||
auth_token_response = client.get_authorization_token(registryIds=['us-east-1', 'us-west-1'])
|
||||
auth_token_response = client.get_authorization_token(registryIds=['10987654321', '878787878787'])
|
||||
|
||||
auth_token_response.should.contain('authorizationData')
|
||||
auth_token_response.should.contain('ResponseMetadata')
|
||||
auth_token_response['authorizationData'].should.equal([
|
||||
{
|
||||
'authorizationToken': 'QVdTOnVzLWVhc3QtMS1hdXRoLXRva2Vu',
|
||||
'proxyEndpoint': 'https://012345678910.dkr.ecr.us-east-1.amazonaws.com',
|
||||
'authorizationToken': 'QVdTOjEwOTg3NjU0MzIxLWF1dGgtdG9rZW4=',
|
||||
'proxyEndpoint': 'https://10987654321.dkr.ecr.us-east-1.amazonaws.com',
|
||||
'expiresAt': datetime(2015, 1, 1, tzinfo=tzlocal()),
|
||||
},
|
||||
{
|
||||
'authorizationToken': 'QVdTOnVzLXdlc3QtMS1hdXRoLXRva2Vu',
|
||||
'proxyEndpoint': 'https://012345678910.dkr.ecr.us-west-1.amazonaws.com',
|
||||
'authorizationToken': 'QVdTOjg3ODc4Nzg3ODc4Ny1hdXRoLXRva2Vu',
|
||||
'proxyEndpoint': 'https://878787878787.dkr.ecr.us-east-1.amazonaws.com',
|
||||
'expiresAt': datetime(2015, 1, 1, tzinfo=tzlocal())
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||
|
||||
import boto3
|
||||
import sure # noqa
|
||||
import json
|
||||
from moto import mock_iot
|
||||
|
||||
|
||||
|
|
@ -96,6 +97,7 @@ def test_certs():
|
|||
res = client.list_certificates()
|
||||
res.should.have.key('certificates').which.should.have.length_of(0)
|
||||
|
||||
|
||||
@mock_iot
|
||||
def test_certs_create_inactive():
|
||||
client = boto3.client('iot', region_name='ap-northeast-1')
|
||||
|
|
@ -113,6 +115,7 @@ def test_certs_create_inactive():
|
|||
cert_desc = cert['certificateDescription']
|
||||
cert_desc.should.have.key('status').which.should.equal('ACTIVE')
|
||||
|
||||
|
||||
@mock_iot
|
||||
def test_policy():
|
||||
client = boto3.client('iot', region_name='ap-northeast-1')
|
||||
|
|
@ -239,9 +242,9 @@ def test_thing_groups():
|
|||
thing_group.should.have.key('thingGroupArn')
|
||||
|
||||
thing_group = client.describe_thing_group(thingGroupName=group_name)
|
||||
thing_group.should.have.key('thingGroupProperties')\
|
||||
.which.should.have.key('attributePayload')\
|
||||
.which.should.have.key('attributes')
|
||||
thing_group.should.have.key('thingGroupProperties') \
|
||||
.which.should.have.key('attributePayload') \
|
||||
.which.should.have.key('attributes')
|
||||
res_props = thing_group['thingGroupProperties']['attributePayload']['attributes']
|
||||
res_props.should.have.key('key1').which.should.equal('val01')
|
||||
res_props.should.have.key('Key02').which.should.equal('VAL2')
|
||||
|
|
@ -260,9 +263,9 @@ def test_thing_groups():
|
|||
thingGroupProperties=new_props
|
||||
)
|
||||
thing_group = client.describe_thing_group(thingGroupName=group_name)
|
||||
thing_group.should.have.key('thingGroupProperties')\
|
||||
.which.should.have.key('attributePayload')\
|
||||
.which.should.have.key('attributes')
|
||||
thing_group.should.have.key('thingGroupProperties') \
|
||||
.which.should.have.key('attributePayload') \
|
||||
.which.should.have.key('attributes')
|
||||
res_props = thing_group['thingGroupProperties']['attributePayload']['attributes']
|
||||
res_props.should.have.key('key1').which.should.equal('val01')
|
||||
res_props.should.have.key('Key02').which.should.equal('VAL2')
|
||||
|
|
@ -282,9 +285,9 @@ def test_thing_groups():
|
|||
thingGroupProperties=new_props
|
||||
)
|
||||
thing_group = client.describe_thing_group(thingGroupName=group_name)
|
||||
thing_group.should.have.key('thingGroupProperties')\
|
||||
.which.should.have.key('attributePayload')\
|
||||
.which.should.have.key('attributes')
|
||||
thing_group.should.have.key('thingGroupProperties') \
|
||||
.which.should.have.key('attributePayload') \
|
||||
.which.should.have.key('attributes')
|
||||
res_props = thing_group['thingGroupProperties']['attributePayload']['attributes']
|
||||
res_props.should.have.key('k4').which.should.equal('v4')
|
||||
res_props.should_not.have.key('key1')
|
||||
|
|
@ -383,3 +386,135 @@ def test_thing_group_relations():
|
|||
)
|
||||
things.should.have.key('things')
|
||||
things['things'].should.have.length_of(0)
|
||||
|
||||
|
||||
@mock_iot
|
||||
def test_create_job():
|
||||
client = boto3.client('iot', region_name='eu-west-1')
|
||||
name = "my-thing"
|
||||
job_id = "TestJob"
|
||||
# thing
|
||||
thing = client.create_thing(thingName=name)
|
||||
thing.should.have.key('thingName').which.should.equal(name)
|
||||
thing.should.have.key('thingArn')
|
||||
|
||||
# job document
|
||||
job_document = {
|
||||
"field": "value"
|
||||
}
|
||||
|
||||
job = client.create_job(
|
||||
jobId=job_id,
|
||||
targets=[thing["thingArn"]],
|
||||
document=json.dumps(job_document),
|
||||
description="Description",
|
||||
presignedUrlConfig={
|
||||
'roleArn': 'arn:aws:iam::1:role/service-role/iot_job_role',
|
||||
'expiresInSec': 123
|
||||
},
|
||||
targetSelection="CONTINUOUS",
|
||||
jobExecutionsRolloutConfig={
|
||||
'maximumPerMinute': 10
|
||||
}
|
||||
)
|
||||
|
||||
job.should.have.key('jobId').which.should.equal(job_id)
|
||||
job.should.have.key('jobArn')
|
||||
job.should.have.key('description')
|
||||
|
||||
@mock_iot
|
||||
def test_describe_job():
|
||||
client = boto3.client('iot', region_name='eu-west-1')
|
||||
name = "my-thing"
|
||||
job_id = "TestJob"
|
||||
# thing
|
||||
thing = client.create_thing(thingName=name)
|
||||
thing.should.have.key('thingName').which.should.equal(name)
|
||||
thing.should.have.key('thingArn')
|
||||
|
||||
job = client.create_job(
|
||||
jobId=job_id,
|
||||
targets=[thing["thingArn"]],
|
||||
documentSource="https://s3-eu-west-1.amazonaws.com/bucket-name/job_document.json",
|
||||
presignedUrlConfig={
|
||||
'roleArn': 'arn:aws:iam::1:role/service-role/iot_job_role',
|
||||
'expiresInSec': 123
|
||||
},
|
||||
targetSelection="CONTINUOUS",
|
||||
jobExecutionsRolloutConfig={
|
||||
'maximumPerMinute': 10
|
||||
}
|
||||
)
|
||||
|
||||
job.should.have.key('jobId').which.should.equal(job_id)
|
||||
job.should.have.key('jobArn')
|
||||
|
||||
job = client.describe_job(jobId=job_id)
|
||||
job.should.have.key('documentSource')
|
||||
job.should.have.key('job')
|
||||
job.should.have.key('job').which.should.have.key("jobArn")
|
||||
job.should.have.key('job').which.should.have.key("jobId").which.should.equal(job_id)
|
||||
job.should.have.key('job').which.should.have.key("targets")
|
||||
job.should.have.key('job').which.should.have.key("jobProcessDetails")
|
||||
job.should.have.key('job').which.should.have.key("lastUpdatedAt")
|
||||
job.should.have.key('job').which.should.have.key("createdAt")
|
||||
job.should.have.key('job').which.should.have.key("jobExecutionsRolloutConfig")
|
||||
job.should.have.key('job').which.should.have.key("targetSelection").which.should.equal("CONTINUOUS")
|
||||
job.should.have.key('job').which.should.have.key("presignedUrlConfig")
|
||||
job.should.have.key('job').which.should.have.key("presignedUrlConfig").which.should.have.key(
|
||||
"roleArn").which.should.equal('arn:aws:iam::1:role/service-role/iot_job_role')
|
||||
job.should.have.key('job').which.should.have.key("presignedUrlConfig").which.should.have.key(
|
||||
"expiresInSec").which.should.equal(123)
|
||||
job.should.have.key('job').which.should.have.key("jobExecutionsRolloutConfig").which.should.have.key(
|
||||
"maximumPerMinute").which.should.equal(10)
|
||||
|
||||
|
||||
@mock_iot
|
||||
def test_describe_job_1():
|
||||
client = boto3.client('iot', region_name='eu-west-1')
|
||||
name = "my-thing"
|
||||
job_id = "TestJob"
|
||||
# thing
|
||||
thing = client.create_thing(thingName=name)
|
||||
thing.should.have.key('thingName').which.should.equal(name)
|
||||
thing.should.have.key('thingArn')
|
||||
|
||||
# job document
|
||||
job_document = {
|
||||
"field": "value"
|
||||
}
|
||||
|
||||
job = client.create_job(
|
||||
jobId=job_id,
|
||||
targets=[thing["thingArn"]],
|
||||
document=json.dumps(job_document),
|
||||
presignedUrlConfig={
|
||||
'roleArn': 'arn:aws:iam::1:role/service-role/iot_job_role',
|
||||
'expiresInSec': 123
|
||||
},
|
||||
targetSelection="CONTINUOUS",
|
||||
jobExecutionsRolloutConfig={
|
||||
'maximumPerMinute': 10
|
||||
}
|
||||
)
|
||||
|
||||
job.should.have.key('jobId').which.should.equal(job_id)
|
||||
job.should.have.key('jobArn')
|
||||
|
||||
job = client.describe_job(jobId=job_id)
|
||||
job.should.have.key('job')
|
||||
job.should.have.key('job').which.should.have.key("jobArn")
|
||||
job.should.have.key('job').which.should.have.key("jobId").which.should.equal(job_id)
|
||||
job.should.have.key('job').which.should.have.key("targets")
|
||||
job.should.have.key('job').which.should.have.key("jobProcessDetails")
|
||||
job.should.have.key('job').which.should.have.key("lastUpdatedAt")
|
||||
job.should.have.key('job').which.should.have.key("createdAt")
|
||||
job.should.have.key('job').which.should.have.key("jobExecutionsRolloutConfig")
|
||||
job.should.have.key('job').which.should.have.key("targetSelection").which.should.equal("CONTINUOUS")
|
||||
job.should.have.key('job').which.should.have.key("presignedUrlConfig")
|
||||
job.should.have.key('job').which.should.have.key("presignedUrlConfig").which.should.have.key(
|
||||
"roleArn").which.should.equal('arn:aws:iam::1:role/service-role/iot_job_role')
|
||||
job.should.have.key('job').which.should.have.key("presignedUrlConfig").which.should.have.key(
|
||||
"expiresInSec").which.should.equal(123)
|
||||
job.should.have.key('job').which.should.have.key("jobExecutionsRolloutConfig").which.should.have.key(
|
||||
"maximumPerMinute").which.should.equal(10)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue