Skip to content

Commit

Permalink
Add all cookie properties to serialized directive object (#448)
Browse files Browse the repository at this point in the history
Signed-off-by: jsetton <[email protected]>
  • Loading branch information
jsetton authored Dec 15, 2021
1 parent e1225ee commit 19e12cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
5 changes: 3 additions & 2 deletions lambda/alexa/smarthome/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ class AlexaDirective {
name: this.name,
...(this.hasEndpoint && {
endpointId: this._directive.endpoint.endpointId,
capabilities: JSON.parse(
(this._directive.endpoint.cookie && this._directive.endpoint.cookie.capabilities) || '[]'
cookie: Object.entries(this._directive.endpoint.cookie || {}).reduce(
(cookie, [key, value]) => ({ ...cookie, [key]: JSON.parse(value) }),
{}
),
payload: this.payload
}),
Expand Down
21 changes: 8 additions & 13 deletions lambda/test/alexa/cases/alexa.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1266,8 +1266,7 @@ module.exports = [
name: 'ReportState'
},
endpoint: {
endpointId: 'switch1',
cookie: {}
endpointId: 'foobar1'
}
},
error: new RequestError(),
Expand All @@ -1294,8 +1293,7 @@ module.exports = [
name: 'ReportState'
},
endpoint: {
endpointId: 'switch1',
cookie: {}
endpointId: 'foobar1'
}
},
error: new StatusCodeError(400),
Expand All @@ -1322,8 +1320,7 @@ module.exports = [
name: 'ReportState'
},
endpoint: {
endpointId: 'switch1',
cookie: {}
endpointId: 'foobar1'
}
},
error: new StatusCodeError(401),
Expand All @@ -1350,8 +1347,7 @@ module.exports = [
name: 'ReportState'
},
endpoint: {
endpointId: 'switch1',
cookie: {}
endpointId: 'foobar1'
}
},
error: new StatusCodeError(404),
Expand All @@ -1378,8 +1374,7 @@ module.exports = [
name: 'ReportState'
},
endpoint: {
endpointId: 'foobar1',
cookie: {}
endpointId: 'foobar1'
}
},
error: new SyntaxError(),
Expand All @@ -1406,8 +1401,7 @@ module.exports = [
name: 'ReportState'
},
endpoint: {
endpointId: 'foobar1',
cookie: {}
endpointId: 'foobar1'
}
},
error: new TypeError(),
Expand Down Expand Up @@ -1435,7 +1429,8 @@ module.exports = [
name: 'ReportState'
},
endpoint: {
endpointId: 'foobar1'
endpointId: 'foobar1',
cookie: { foobar: '{}' }
}
},
error: new Error(),
Expand Down

0 comments on commit 19e12cc

Please sign in to comment.