Skip to content

Commit

Permalink
Maps are modeled in a messed up way unfortunately
Browse files Browse the repository at this point in the history
  • Loading branch information
Bret Ambrose committed Jun 29, 2024
1 parent 573dcc5 commit b0596f1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
20 changes: 10 additions & 10 deletions lib/iotidentity/iotidentityv2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,17 @@ beforeEach(async () => {
afterEach(async () => {
const client = new IoTClient({});

if (identityResources.thingName) {
const command = new DeleteThingCommand({
thingName: identityResources.thingName
if (identityResources.certificateId) {
const command = new DeleteCertificateCommand({
certificateId: identityResources.certificateId,
});

await client.send(command);
}

if (identityResources.certificateId) {
const command = new DeleteCertificateCommand({
certificateId: identityResources.certificateId,
if (identityResources.thingName) {
const command = new DeleteThingCommand({
thingName: identityResources.thingName
});

await client.send(command);
Expand All @@ -221,13 +221,13 @@ async function doProvisioningTest(version: ProtocolVersion) {
expect(createKeysResponse.privateKey).toBeDefined();
expect(createKeysResponse.certificateOwnershipToken).toBeDefined();

const params: { [key: string]: string } = JSON.parse(`{"SerialNumber":"${uuid()}"}`);

let registerThingResponse = await context.client.registerThing({
// @ts-ignore
templateName: process.env.AWS_TEST_IOT_CORE_PROVISIONING_TEMPLATE_NAME,
certificateOwnershipToken: createKeysResponse.certificateOwnershipToken,
parameters: {
SerialNumber: `${uuid()}`
}
parameters: params
});
identityResources.thingName = registerThingResponse.thingName;
expect(registerThingResponse.thingName).toBeDefined();
Expand Down
19 changes: 13 additions & 6 deletions lib/mqtt_request_response_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ function buildResponseDeserializerMap(paths: Array<RequestResponsePath>) : Map<s

function buildResponsePaths(paths: Array<RequestResponsePath>) : Array<mqtt_request_response.ResponsePath> {
return paths.map((path) => {
return {
topic: path.topic,
correlationTokenJsonPath: path.correlationTokenJsonPath,
let responsePath : mqtt_request_response.ResponsePath = {
topic: path.topic
};

if (path.correlationTokenJsonPath) {
responsePath.correlationTokenJsonPath = path.correlationTokenJsonPath;
}

return responsePath;
});
}

Expand Down Expand Up @@ -358,12 +363,13 @@ export function validateValueAsMap(value : any, keyValidator : ElementValidator,
return;
}

/*
if (!(value instanceof Map)) {
throwInvalidPropertyValueError('a map value', propertyName);
}
}*/

let valueAsMap = value as Map<any, any>;
for (const [key, val] of valueAsMap) {
//let valueAsMap = value as Map<any, any>;
for (const key in value) {
try {
keyValidator(key);
} catch (err) {
Expand All @@ -375,6 +381,7 @@ export function validateValueAsMap(value : any, keyValidator : ElementValidator,
}
}

let val = value[key];
try {
valueValidator(val);
} catch (err) {
Expand Down

0 comments on commit b0596f1

Please sign in to comment.