From b8cbb36e4ed2bac1467ddf57b34ff6ebbfa260a3 Mon Sep 17 00:00:00 2001 From: Bob Evans Date: Thu, 4 May 2023 17:14:17 -0400 Subject: [PATCH 1/2] fix: Updated the mock AWS server to handle both XML and JSON. * The SQS clients as of 2.1372.0 and 3.327.0 speak JSON and our mock server only dealt in XML. --- merged/aws-sdk/.eslintrc.js | 6 +- merged/aws-sdk/THIRD_PARTY_NOTICES.md | 2 +- merged/aws-sdk/lib/v2/core.js | 6 +- merged/aws-sdk/package-lock.json | 14 +-- merged/aws-sdk/package.json | 2 +- .../response-server/common.js | 22 ++-- .../aws-server-stubs/response-server/index.js | 23 ++-- .../response-server/sqs/index.js | 107 ++++-------------- .../sqs/responses/create-queue-response.js | 27 +++++ .../sqs/responses/create-queue-response.xml | 8 -- ...sponse.xml => receive-message-response.js} | 34 +++++- .../responses/send-message-batch-response.js | 47 ++++++++ .../responses/send-message-batch-response.xml | 17 --- .../sqs/responses/send-message-response.js | 28 +++++ .../sqs/responses/send-message-response.xml | 9 -- .../aws-sdk/tests/versioned/v2/package.json | 17 +-- merged/aws-sdk/tests/versioned/v2/sqs.tap.js | 60 +++++----- .../aws-sdk/tests/versioned/v3/package.json | 2 +- merged/aws-sdk/third_party_manifest.json | 12 +- 19 files changed, 244 insertions(+), 199 deletions(-) create mode 100644 merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/create-queue-response.js delete mode 100644 merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/create-queue-response.xml rename merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/{receive-message-response.xml => receive-message-response.js} (52%) create mode 100644 merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-batch-response.js delete mode 100644 merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-batch-response.xml create mode 100644 merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-response.js delete mode 100644 merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-response.xml diff --git a/merged/aws-sdk/.eslintrc.js b/merged/aws-sdk/.eslintrc.js index 506f31be89..6cc9e8cb2e 100644 --- a/merged/aws-sdk/.eslintrc.js +++ b/merged/aws-sdk/.eslintrc.js @@ -1,4 +1,8 @@ 'use strict' module.exports = { - extends: '@newrelic' + extends: '@newrelic', + parserOptions: { + ecmaVersion: '2020' + }, + } diff --git a/merged/aws-sdk/THIRD_PARTY_NOTICES.md b/merged/aws-sdk/THIRD_PARTY_NOTICES.md index fc69a56d34..d4e5350f1c 100644 --- a/merged/aws-sdk/THIRD_PARTY_NOTICES.md +++ b/merged/aws-sdk/THIRD_PARTY_NOTICES.md @@ -1089,7 +1089,7 @@ This product includes source derived from [@newrelic/test-utilities](https://git ### aws-sdk -This product includes source derived from [aws-sdk](https://github.com/aws/aws-sdk-js) ([v2.1354.0](https://github.com/aws/aws-sdk-js/tree/v2.1354.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js/blob/v2.1354.0/LICENSE.txt): +This product includes source derived from [aws-sdk](https://github.com/aws/aws-sdk-js) ([v2.1372.0](https://github.com/aws/aws-sdk-js/tree/v2.1372.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js/blob/v2.1372.0/LICENSE.txt): ``` diff --git a/merged/aws-sdk/lib/v2/core.js b/merged/aws-sdk/lib/v2/core.js index e660d0171f..c3ff7a43da 100644 --- a/merged/aws-sdk/lib/v2/core.js +++ b/merged/aws-sdk/lib/v2/core.js @@ -46,7 +46,7 @@ function wrapMakeRequest(shim, fn, name, request) { } const service = getServiceName(this) - const region = this.config && this.config.region + const region = this?.config?.region request.on('complete', function onAwsRequestComplete() { const httpRequest = request.httpRequest && request.httpRequest.stream const segment = shim.getSegment(httpRequest) @@ -55,8 +55,8 @@ function wrapMakeRequest(shim, fn, name, request) { return } - const requestRegion = request.httpRequest.region - const requestId = request.response && request.response.requestId + const requestRegion = request?.httpRequest?.region + const requestId = request?.response?.requestId segment.addAttribute('aws.operation', request.operation || UNKNOWN) segment.addAttribute('aws.requestId', requestId || UNKNOWN) diff --git a/merged/aws-sdk/package-lock.json b/merged/aws-sdk/package-lock.json index b6bd57b8e8..fe1ab55e35 100644 --- a/merged/aws-sdk/package-lock.json +++ b/merged/aws-sdk/package-lock.json @@ -14,7 +14,7 @@ "@newrelic/eslint-config": "^0.0.2", "@newrelic/newrelic-oss-cli": "^0.1.2", "@newrelic/test-utilities": "^7.3.0", - "aws-sdk": "^2.403.0", + "aws-sdk": "^2.1372.0", "c8": "^7.12.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", @@ -4631,9 +4631,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1354.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1354.0.tgz", - "integrity": "sha512-3aDxvyuOqMB9DqJguCq6p8momdsz0JR1axwkWOOCzHA7a35+Bw+WLmqt3pWwRjR1tGIwkkZ2CvGJObYHsOuw3w==", + "version": "2.1372.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1372.0.tgz", + "integrity": "sha512-SkpBohTXS7yJL6I/k+Dk5o2k8xgyVKs1n9zo08DvCaheSmvpMKQHqdj/wCbf1cjLRFr/Ckc1YGDj3SsikPsBgw==", "dev": true, "dependencies": { "buffer": "4.9.2", @@ -15693,9 +15693,9 @@ "dev": true }, "aws-sdk": { - "version": "2.1354.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1354.0.tgz", - "integrity": "sha512-3aDxvyuOqMB9DqJguCq6p8momdsz0JR1axwkWOOCzHA7a35+Bw+WLmqt3pWwRjR1tGIwkkZ2CvGJObYHsOuw3w==", + "version": "2.1372.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1372.0.tgz", + "integrity": "sha512-SkpBohTXS7yJL6I/k+Dk5o2k8xgyVKs1n9zo08DvCaheSmvpMKQHqdj/wCbf1cjLRFr/Ckc1YGDj3SsikPsBgw==", "dev": true, "requires": { "buffer": "4.9.2", diff --git a/merged/aws-sdk/package.json b/merged/aws-sdk/package.json index 4898f6a872..ffd0083c87 100644 --- a/merged/aws-sdk/package.json +++ b/merged/aws-sdk/package.json @@ -32,7 +32,7 @@ "@newrelic/eslint-config": "^0.0.2", "@newrelic/newrelic-oss-cli": "^0.1.2", "@newrelic/test-utilities": "^7.3.0", - "aws-sdk": "^2.403.0", + "aws-sdk": "^2.1372.0", "c8": "^7.12.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/common.js b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/common.js index 5c7c9edefd..ceeddd8ccb 100644 --- a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/common.js +++ b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/common.js @@ -8,16 +8,22 @@ const common = module.exports const path = require('path') const fs = require('fs') -common.parseBody = function parseBody(body) { - const parsed = Object.create(null) +common.parseBody = function parseBody(body, headers) { + try { + const parsed = JSON.parse(body) + parsed.Action = headers['x-amz-target'].split('.')[1] + return parsed + } catch { + const parsed = Object.create(null) - const items = body.split('&') - items.forEach((item) => { - const [key, value] = item.split('=') - parsed[key] = value - }) + const items = body.split('&') + items.forEach((item) => { + const [key, value] = item.split('=') + parsed[key] = value + }) - return parsed + return parsed + } } common.readFromXml = function readFromXml(filePath, callback) { diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/index.js b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/index.js index c77230a4dc..116240a2df 100644 --- a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/index.js +++ b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/index.js @@ -43,10 +43,11 @@ function handlePost(req, res) { }) req.on('end', () => { + const isJson = !!req.headers['x-amz-target'] const endpoint = `http://localhost:${req.connection.localPort}` - const parsed = parseBody(body) + const parsed = parseBody(body, req.headers) - const getDataFunction = createGetDataFromAction(endpoint, parsed) + const getDataFunction = createGetDataFromAction(endpoint, parsed, isJson) getDataFunction((err, data) => { if (err) { @@ -55,25 +56,29 @@ function handlePost(req, res) { console.log(err) } + if (isJson) { + res.setHeader('x-amz-request-id', data.ResponseMetadata.RequestId) + data = JSON.stringify(data) + } res.end(data) }) }) } -function createGetDataFromAction(endpoint, body) { +function createGetDataFromAction(endpoint, body, isJson) { switch (body.Action) { case 'Publish': - return getPublishResponse.bind(null) + return getPublishResponse.bind(null, isJson) case 'ListTopics': - return getListTopicsResponse.bind(null) + return getListTopicsResponse.bind(null, isJson) case 'CreateQueue': - return getCreateQueueResponse.bind(null, endpoint, body.QueueName) + return getCreateQueueResponse.bind(null, endpoint, body.QueueName, isJson) case 'SendMessage': - return getSendMessageResponse.bind(null) + return getSendMessageResponse.bind(null, isJson) case 'SendMessageBatch': - return getSendMessageBatchResponse.bind(null) + return getSendMessageBatchResponse.bind(null, isJson) case 'ReceiveMessage': - return getReceiveMessageResponse.bind(null) + return getReceiveMessageResponse.bind(null, isJson) case 'SendEmail': return getSendEmailResponse.bind(null) case 'AcceptReservedNodeExchange': diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/index.js b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/index.js index 233073b909..cdc54b6f9e 100644 --- a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/index.js +++ b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/index.js @@ -5,97 +5,36 @@ 'use strict' const helpers = module.exports -const { readFromXml } = require('../common') -let createQueueResponse = null -helpers.getCreateQueueResponse = function getCreateQueueResponse(endpoint, queueName, callback) { - if (createQueueResponse) { - const modifiedResponse = replaceQueueUrl(createQueueResponse, endpoint, queueName) - - setImmediate(() => { - callback(null, modifiedResponse) - }) - return - } - - readFromXml('./sqs/responses/create-queue-response.xml', (err, data) => { - if (err) { - callback(err) - return - } - - createQueueResponse = data - const modifiedResponse = replaceQueueUrl(createQueueResponse, endpoint, queueName) - - callback(null, modifiedResponse) - }) -} - -function replaceQueueUrl(xml, endpoint, queueName) { - const modifiedResponse = xml.replace( - '', - `${endpoint}/queue/${queueName}` +helpers.getCreateQueueResponse = function getCreateQueueResponse( + endpoint, + queueName, + isJson, + callback +) { + const createQueueResponse = require('./responses/create-queue-response')( + endpoint, + queueName, + isJson ) - - return modifiedResponse + callback(null, createQueueResponse) } -let sendMessageResponse = null -helpers.getSendMessageResponse = function getSendMessageResponse(callback) { - if (sendMessageResponse) { - setImmediate(() => { - callback(null, sendMessageResponse) - }) - return - } - - readFromXml('./sqs/responses/send-message-response.xml', (err, data) => { - if (err) { - callback(err) - return - } - - sendMessageResponse = data - callback(null, sendMessageResponse) - }) +helpers.formatUrl = function formatUrl(endpoint, queueName) { + return `${endpoint}/queue/${queueName}` } -let sendMessageBatchResponse = null -helpers.getSendMessageBatchResponse = function getSendMessageBatchResponse(callback) { - if (sendMessageBatchResponse) { - setImmediate(() => { - callback(null, sendMessageBatchResponse) - }) - return - } - - readFromXml('./sqs/responses/send-message-batch-response.xml', (err, data) => { - if (err) { - callback(err) - return - } - - sendMessageBatchResponse = data - callback(null, sendMessageBatchResponse) - }) +helpers.getSendMessageResponse = function getSendMessageResponse(isJson, callback) { + const sendMessageResponse = require('./responses/send-message-response')(isJson) + callback(null, sendMessageResponse) } -let receiveMessageResponse = null -helpers.getReceiveMessageResponse = function getReceiveMessageResponse(callback) { - if (receiveMessageResponse) { - setImmediate(() => { - callback(null, receiveMessageResponse) - }) - return - } - - readFromXml('./sqs/responses/receive-message-response.xml', (err, data) => { - if (err) { - callback(err) - return - } +helpers.getSendMessageBatchResponse = function getSendMessageBatchResponse(isJson, callback) { + const sendMessageBatchResponse = require('./responses/send-message-batch-response')(isJson) + callback(null, sendMessageBatchResponse) +} - receiveMessageResponse = data - callback(null, receiveMessageResponse) - }) +helpers.getReceiveMessageResponse = function getReceiveMessageResponse(isJson, callback) { + const receiveMessageResponse = require('./responses/receive-message-response')(isJson) + callback(null, receiveMessageResponse) } diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/create-queue-response.js b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/create-queue-response.js new file mode 100644 index 0000000000..da086fb32c --- /dev/null +++ b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/create-queue-response.js @@ -0,0 +1,27 @@ +/* + * Copyright 2023 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +'use strict' +const { formatUrl } = require('../index') + +module.exports = (endpoint, queueName, isJson) => { + if (isJson) { + return { + QueueUrl: formatUrl(endpoint, queueName), + ResponseMetadata: { + RequestId: 'cb919c0a-9bce-4afe-9b48-9bdf2412bb67' + } + } + } + return ` + + + ${formatUrl(endpoint, queueName)} + + + cb919c0a-9bce-4afe-9b48-9bdf2412bb67 + +` +} diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/create-queue-response.xml b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/create-queue-response.xml deleted file mode 100644 index 7ee7c8bc42..0000000000 --- a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/create-queue-response.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - cb919c0a-9bce-4afe-9b48-9bdf2412bb67 - - \ No newline at end of file diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/receive-message-response.xml b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/receive-message-response.js similarity index 52% rename from merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/receive-message-response.xml rename to merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/receive-message-response.js index 73df7542b8..3a8ba406db 100644 --- a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/receive-message-response.xml +++ b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/receive-message-response.js @@ -1,3 +1,34 @@ +/* + * Copyright 2023 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +'use strict' + +module.exports = (isJson) => { + if (isJson) { + return { + Messages: [ + { + MessageId: '5fea7756-0ea4-451a-a703-a558b933e274', + ReceiptHandle: + 'MbZj6wDWliJvwwJaBV3dcjk2YW2vA3STFFljTM8tJJg6HRG6PYSasuWXPJBCwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQQEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0=', + MD5OfBody: 'fafb00f5732ab283681e124bf8747ed1', + Body: 'This is a test message', + Attributes: { + SenderId: '195004372649', + SentTimestamp: '1238099229000', + ApproximateReceiveCount: '2', + ApproximateFirstReceiveTimestamp: '1595887234772' + } + } + ], + ResponseMetadata: { + RequestId: 'b6633655-283d-45b4-aee4-4e84e0ae6afa' + } + } + } + return ` @@ -30,4 +61,5 @@ b6633655-283d-45b4-aee4-4e84e0ae6afa - \ No newline at end of file +` +} diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-batch-response.js b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-batch-response.js new file mode 100644 index 0000000000..92338c6e83 --- /dev/null +++ b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-batch-response.js @@ -0,0 +1,47 @@ +/* + * Copyright 2023 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +'use strict' + +module.exports = (isJson) => { + if (isJson) { + return { + Failed: [], + Successful: [ + { + Id: 'ONE', + MessageId: '0a5231c7-8bff-4955-be2e-8dc7c50a25fa', + MD5OfMessageBody: '8b2f30468657cfc118bbbebb6ad52b5a' + }, + { + Id: 'TWO', + MessageId: '15ee1ed3-87e7-40c1-bdaa-2e49968ea7e9', + MD5OfMessageBody: '446e666e0c0a8695b7a9693c082bc5da' + } + ], + ResponseMetadata: { + RequestId: 'ca1ad5d0-8271-408b-8d0f-1351bf547e74' + } + } + } + return ` + + + + ONE + 0a5231c7-8bff-4955-be2e-8dc7c50a25fa + 8b2f30468657cfc118bbbebb6ad52b5a + + + TWO + 15ee1ed3-87e7-40c1-bdaa-2e49968ea7e9 + 446e666e0c0a8695b7a9693c082bc5da + + + + ca1ad5d0-8271-408b-8d0f-1351bf547e74 + +` +} diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-batch-response.xml b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-batch-response.xml deleted file mode 100644 index 323d1a32eb..0000000000 --- a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-batch-response.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - ONE - 0a5231c7-8bff-4955-be2e-8dc7c50a25fa - 8b2f30468657cfc118bbbebb6ad52b5a - - - TWO - 15ee1ed3-87e7-40c1-bdaa-2e49968ea7e9 - 446e666e0c0a8695b7a9693c082bc5da - - - - ca1ad5d0-8271-408b-8d0f-1351bf547e74 - - \ No newline at end of file diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-response.js b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-response.js new file mode 100644 index 0000000000..6184374d9d --- /dev/null +++ b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-response.js @@ -0,0 +1,28 @@ +/* + * Copyright 2023 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +'use strict' + +module.exports = (isJson) => { + if (isJson) { + return { + MD5OfMessageBody: 'fafb00f5732ab283681e124bf8747ed1', + MessageId: '5fea7756-0ea4-451a-a703-a558b933e274', + ResponseMetadata: { + RequestId: '27daac76-34dd-47df-bd01-1f6e873584a0' + } + } + } + return ` + + + fafb00f5732ab283681e124bf8747ed1 + 5fea7756-0ea4-451a-a703-a558b933e274 + + + 27daac76-34dd-47df-bd01-1f6e873584a0 + +` +} diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-response.xml b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-response.xml deleted file mode 100644 index 813da254df..0000000000 --- a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/sqs/responses/send-message-response.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - fafb00f5732ab283681e124bf8747ed1 - 5fea7756-0ea4-451a-a703-a558b933e274 - - - 27daac76-34dd-47df-bd01-1f6e873584a0 - - \ No newline at end of file diff --git a/merged/aws-sdk/tests/versioned/v2/package.json b/merged/aws-sdk/tests/versioned/v2/package.json index b6948b5aab..b5aff8ac9c 100644 --- a/merged/aws-sdk/tests/versioned/v2/package.json +++ b/merged/aws-sdk/tests/versioned/v2/package.json @@ -32,7 +32,8 @@ "http-services.tap.js", "instrumentation-supported.tap.js", "s3.tap.js", - "sns.tap.js" + "sns.tap.js", + "sqs.tap.js" ] }, { @@ -49,20 +50,6 @@ "files": [ "amazon-dax-client.tap.js" ] - }, - { - "engines": { - "node": ">=14.0" - }, - "dependencies": { - "aws-sdk": { - "versions": ">=2.380.0 <2.1372.0", - "samples": 10 - } - }, - "files": [ - "sqs.tap.js" - ] } ], "dependencies": {} diff --git a/merged/aws-sdk/tests/versioned/v2/sqs.tap.js b/merged/aws-sdk/tests/versioned/v2/sqs.tap.js index f75425c868..0d9bbe2a01 100644 --- a/merged/aws-sdk/tests/versioned/v2/sqs.tap.js +++ b/merged/aws-sdk/tests/versioned/v2/sqs.tap.js @@ -77,32 +77,38 @@ tap.test('SQS API', (t) => { helper.runInTransaction((transaction) => { const sendMessageParams = getSendMessageParams(queueUrl) - sqs.sendMessage(sendMessageParams, (sendErr, sendData) => { + sqs.sendMessage(sendMessageParams, function sendMessageCb(sendErr, sendData) { t.error(sendErr) t.ok(sendData.MessageId) - sendMessageRequestId = getRequestId(t, sendData) + sendMessageRequestId = this.requestId const sendMessageBatchParams = getSendMessageBatchParams(queueUrl) - sqs.sendMessageBatch(sendMessageBatchParams, (sendBatchErr, sendBatchData) => { - t.error(sendBatchErr) - t.ok(sendBatchData.Successful) - - sendMessageBatchRequestId = getRequestId(t, sendBatchData) - - const receiveMessageParams = getReceiveMessageParams(queueUrl) - sqs.receiveMessage(receiveMessageParams, (receiveErr, receiveData) => { - t.error(receiveErr) - t.ok(receiveData.Messages) - - receiveMessageRequestId = getRequestId(t, receiveData) - - transaction.end() - - const args = [t, transaction] - setImmediate(finish, ...args) - }) - }) + sqs.sendMessageBatch( + sendMessageBatchParams, + function sendBatchCb(sendBatchErr, sendBatchData) { + t.error(sendBatchErr) + t.ok(sendBatchData.Successful) + + sendMessageBatchRequestId = this.requestId + + const receiveMessageParams = getReceiveMessageParams(queueUrl) + sqs.receiveMessage( + receiveMessageParams, + function receiveMsgCb(receiveErr, receiveData) { + t.error(receiveErr) + t.ok(receiveData.Messages) + + receiveMessageRequestId = this.requestId + + transaction.end() + + const args = [t, transaction] + setImmediate(finish, ...args) + } + ) + } + ) }) }) }) @@ -121,7 +127,7 @@ tap.test('SQS API', (t) => { const sendData = await sqs.sendMessage(sendMessageParams).promise() t.ok(sendData.MessageId) - sendMessageRequestId = getRequestId(t, sendData) + sendMessageRequestId = getRequestId(sendData) } catch (error) { t.error(error) } @@ -131,7 +137,7 @@ tap.test('SQS API', (t) => { const sendBatchData = await sqs.sendMessageBatch(sendMessageBatchParams).promise() t.ok(sendBatchData.Successful) - sendMessageBatchRequestId = getRequestId(t, sendBatchData) + sendMessageBatchRequestId = getRequestId(sendBatchData) } catch (error) { t.error(error) } @@ -141,7 +147,7 @@ tap.test('SQS API', (t) => { const receiveData = await sqs.receiveMessage(receiveMessageParams).promise() t.ok(receiveData.Messages) - receiveMessageRequestId = getRequestId(t, receiveData) + receiveMessageRequestId = getRequestId(receiveData) } catch (error) { t.error(error) } @@ -207,10 +213,8 @@ function checkAttributes(t, segment, operation, expectedRequestId) { ) } -function getRequestId(t, apiReturnedData) { - t.ok(apiReturnedData.ResponseMetadata) - - return apiReturnedData.ResponseMetadata.RequestId +function getRequestId(data) { + return data?.$response?.requestId } function getCreateParams(queueName) { diff --git a/merged/aws-sdk/tests/versioned/v3/package.json b/merged/aws-sdk/tests/versioned/v3/package.json index c8d0ec784d..22ecfb7619 100644 --- a/merged/aws-sdk/tests/versioned/v3/package.json +++ b/merged/aws-sdk/tests/versioned/v3/package.json @@ -152,7 +152,7 @@ }, "dependencies": { "@aws-sdk/client-sqs": { - "versions": ">=3.0.0 <=3.193.0 || >3.196.0 <3.327.0", + "versions": ">=3.0.0 <=3.193.0 || >3.196.0", "samples": 10 } }, diff --git a/merged/aws-sdk/third_party_manifest.json b/merged/aws-sdk/third_party_manifest.json index ce56dbd31c..35190d641b 100644 --- a/merged/aws-sdk/third_party_manifest.json +++ b/merged/aws-sdk/third_party_manifest.json @@ -1,5 +1,5 @@ { - "lastUpdated": "Thu Apr 20 2023 11:28:28 GMT-0400 (Eastern Daylight Time)", + "lastUpdated": "Tue May 09 2023 11:40:30 GMT-0400 (Eastern Daylight Time)", "projectName": "New Relic AWS-SDK Instrumentation", "projectUrl": "https://github.com/newrelic/node-newrelic-aws-sdk", "includeOptDeps": false, @@ -70,15 +70,15 @@ "publisher": "New Relic Node.js agent team", "email": "nodejs@newrelic.com" }, - "aws-sdk@2.1354.0": { + "aws-sdk@2.1372.0": { "name": "aws-sdk", - "version": "2.1354.0", - "range": "^2.403.0", + "version": "2.1372.0", + "range": "^2.1372.0", "licenses": "Apache-2.0", "repoUrl": "https://github.com/aws/aws-sdk-js", - "versionedRepoUrl": "https://github.com/aws/aws-sdk-js/tree/v2.1354.0", + "versionedRepoUrl": "https://github.com/aws/aws-sdk-js/tree/v2.1372.0", "licenseFile": "node_modules/aws-sdk/LICENSE.txt", - "licenseUrl": "https://github.com/aws/aws-sdk-js/blob/v2.1354.0/LICENSE.txt", + "licenseUrl": "https://github.com/aws/aws-sdk-js/blob/v2.1372.0/LICENSE.txt", "licenseTextSource": "file", "publisher": "Amazon Web Services", "url": "https://aws.amazon.com/" From 1d214bc78560eea27f30a7488ec4e3cc6a8936c3 Mon Sep 17 00:00:00 2001 From: Bob Evans Date: Tue, 9 May 2023 12:42:23 -0400 Subject: [PATCH 2/2] fix: removed passing isJson into sns mocked responses --- .../tests/versioned/aws-server-stubs/response-server/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/index.js b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/index.js index 116240a2df..751d4f0803 100644 --- a/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/index.js +++ b/merged/aws-sdk/tests/versioned/aws-server-stubs/response-server/index.js @@ -68,9 +68,9 @@ function handlePost(req, res) { function createGetDataFromAction(endpoint, body, isJson) { switch (body.Action) { case 'Publish': - return getPublishResponse.bind(null, isJson) + return getPublishResponse.bind(null) case 'ListTopics': - return getListTopicsResponse.bind(null, isJson) + return getListTopicsResponse.bind(null) case 'CreateQueue': return getCreateQueueResponse.bind(null, endpoint, body.QueueName, isJson) case 'SendMessage':