From 3584e87ba4b1d5b2001b468671f3c485a384b0e9 Mon Sep 17 00:00:00 2001 From: rtrevino89 <99822668+rtrevino89@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:01:10 -0600 Subject: [PATCH] add msuseragent for alpha ids tests (#26455) Added a custom msuseragent header to identify tests. --- .../communication-alpha-ids/CHANGELOG.md | 2 + .../communication-alpha-ids/karma.conf.js | 1 + ..._list_all_dynamic_alpha_ids_countries.json | 12 ++-- .../recording_can_manage_configuration.json | 36 +++++----- ..._can_list_all_preregistered_alpha_ids.json | 24 +++---- ...all_preregistered_alpha_ids_countries.json | 12 ++-- ..._list_all_dynamic_alpha_ids_countries.json | 13 ++-- .../recording_can_manage_configuration.json | 39 +++++++---- ..._can_list_all_preregistered_alpha_ids.json | 26 ++++--- ...all_preregistered_alpha_ids_countries.json | 13 ++-- .../src/alphaIdsClient.ts | 4 ++ .../src/utils/customPipelinePolicies.ts | 36 ++++++++++ .../test/public/dynamicAlphaId.spec.ts | 69 +++++++++++++++++-- .../test/public/preRegisteredAlphaId.spec.ts | 69 +++++++++++++++---- .../test/public/utils/msUserAgentPolicy.ts | 24 +++++++ .../test/public/utils/recordedClient.ts | 11 ++- 16 files changed, 295 insertions(+), 96 deletions(-) create mode 100644 sdk/communication/communication-alpha-ids/src/utils/customPipelinePolicies.ts create mode 100644 sdk/communication/communication-alpha-ids/test/public/utils/msUserAgentPolicy.ts diff --git a/sdk/communication/communication-alpha-ids/CHANGELOG.md b/sdk/communication/communication-alpha-ids/CHANGELOG.md index 5bc3c300f308..0a2bbcad1ef2 100644 --- a/sdk/communication/communication-alpha-ids/CHANGELOG.md +++ b/sdk/communication/communication-alpha-ids/CHANGELOG.md @@ -10,6 +10,8 @@ ### Bugs Fixed +- Fixed a pagination issue by adding a custom paging policy + ### Other Changes - Updated to `@azure/communication-common` 2.2.0. diff --git a/sdk/communication/communication-alpha-ids/karma.conf.js b/sdk/communication/communication-alpha-ids/karma.conf.js index d08f9b0f82a0..c4e01d2f3852 100644 --- a/sdk/communication/communication-alpha-ids/karma.conf.js +++ b/sdk/communication/communication-alpha-ids/karma.conf.js @@ -49,6 +49,7 @@ module.exports = function (config) { "AZURE_CLIENT_SECRET", "AZURE_TENANT_ID", "RECORDINGS_RELATIVE_PATH", + "AZURE_USERAGENT_OVERRIDE", ], // test results reporter to use diff --git a/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__manage_configuration/recording_can_list_all_dynamic_alpha_ids_countries.json b/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__manage_configuration/recording_can_list_all_dynamic_alpha_ids_countries.json index eebd924f566e..1909a4a6986b 100644 --- a/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__manage_configuration/recording_can_list_all_dynamic_alpha_ids_countries.json +++ b/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__manage_configuration/recording_can_list_all_dynamic_alpha_ids_countries.json @@ -19,8 +19,8 @@ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/112.0.5614.0 Safari/537.36", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:22 GMT", - "x-ms-useragent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 OS" + "x-ms-date": "Wed, 12 Jul 2023 16:29:51 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, @@ -28,12 +28,12 @@ "api-supported-versions": "2022-09-26-preview, 2023-07-12", "Content-Length": "115", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:23 GMT", - "MS-CV": "E9jdHz\u002BCskC3dz2Q8FwiWA.0", + "Date": "Wed, 12 Jul 2023 16:29:53 GMT", + "MS-CV": "RYhp53OpFEezgotg3xK6Zg.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0jAWaZAAAAABTsb5nc7NZQ5tyTHO5V6amREZXMzBFREdFMTYxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Azure-Ref": "0AdWuZAAAAACZFoVbyF57QbcwqTVN0MbqREZXMzBFREdFMTYxNABjYzkyNzU4ZC0wNWY3LTRhZDYtYWE1ZS0wZmE5NzE4ZDg5ODU=", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "342ms" + "X-Processing-Time": "764ms" }, "ResponseBody": { "countries": [ diff --git a/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__manage_configuration/recording_can_manage_configuration.json b/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__manage_configuration/recording_can_manage_configuration.json index ec80d24ec9cd..05a466b7c02c 100644 --- a/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__manage_configuration/recording_can_manage_configuration.json +++ b/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__manage_configuration/recording_can_manage_configuration.json @@ -21,8 +21,8 @@ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/112.0.5614.0 Safari/537.36", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "JrNCayWTdjyW0IkLSnegu/ZtE/xRKwxrE4ojwpDzCio=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:20 GMT", - "x-ms-useragent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 OS" + "x-ms-date": "Wed, 12 Jul 2023 16:29:47 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": { "enabled": true @@ -32,12 +32,12 @@ "api-supported-versions": "2022-09-26-preview, 2023-07-12", "Content-Length": "16", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:22 GMT", - "MS-CV": "mNRHyK/F8Uq7xsQrhNdnnQ.0", + "Date": "Wed, 12 Jul 2023 16:29:49 GMT", + "MS-CV": "da41AGUNd0Ci4HY6g4xHQg.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0igWaZAAAAADGyurFDBM6RaNLlTYGNT4SREZXMzBFREdFMTYxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Azure-Ref": "0/dSuZAAAAABpZCUW\u002B4R0TaCSDVeRX/uZREZXMzBFREdFMTYxNABjYzkyNzU4ZC0wNWY3LTRhZDYtYWE1ZS0wZmE5NzE4ZDg5ODU=", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "701ms" + "X-Processing-Time": "704ms" }, "ResponseBody": { "enabled": true @@ -62,8 +62,8 @@ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/112.0.5614.0 Safari/537.36", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:21 GMT", - "x-ms-useragent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 OS" + "x-ms-date": "Wed, 12 Jul 2023 16:29:48 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, @@ -71,12 +71,12 @@ "api-supported-versions": "2022-09-26-preview, 2023-07-12", "Content-Length": "16", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:22 GMT", - "MS-CV": "LlyVApzSw0WnfhUruVCsOw.0", + "Date": "Wed, 12 Jul 2023 16:29:51 GMT", + "MS-CV": "PabmeibTUUaGe11gyF1v0g.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0iwWaZAAAAAAQdzU8bWT0RYXJziKS0vRkREZXMzBFREdFMTYxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Azure-Ref": "0/tSuZAAAAAA\u002BeGAohh/tR4NlAOOHEe4LREZXMzBFREdFMTYxNABjYzkyNzU4ZC0wNWY3LTRhZDYtYWE1ZS0wZmE5NzE4ZDg5ODU=", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "280ms" + "X-Processing-Time": "1199ms" }, "ResponseBody": { "enabled": true @@ -103,8 +103,8 @@ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/112.0.5614.0 Safari/537.36", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "Ws8/93tEIGd7WSMHHzA/rKunqSc6NGKEpmeidd8yUUY=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:21 GMT", - "x-ms-useragent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 OS" + "x-ms-date": "Wed, 12 Jul 2023 16:29:50 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": { "enabled": false @@ -114,12 +114,12 @@ "api-supported-versions": "2022-09-26-preview, 2023-07-12", "Content-Length": "17", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:23 GMT", - "MS-CV": "4NPHARdHFUCK1y8uytZZkg.0", + "Date": "Wed, 12 Jul 2023 16:29:52 GMT", + "MS-CV": "BrUH7ChVJ0iyDilrE2xsRA.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0iwWaZAAAAABQuA3yOhocQYqiw1zMgAGXREZXMzBFREdFMTYxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Azure-Ref": "0ANWuZAAAAAC\u002BLFblmWZ\u002BRoG32a0JVR6RREZXMzBFREdFMTYxNABjYzkyNzU4ZC0wNWY3LTRhZDYtYWE1ZS0wZmE5NzE4ZDg5ODU=", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "413ms" + "X-Processing-Time": "931ms" }, "ResponseBody": { "enabled": false diff --git a/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids.json b/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids.json index 5cfccc8fbbc5..c09ef42c3540 100644 --- a/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids.json +++ b/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids.json @@ -19,8 +19,8 @@ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/112.0.5614.0 Safari/537.36", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:22 GMT", - "x-ms-useragent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 OS" + "x-ms-date": "Wed, 12 Jul 2023 16:29:52 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, @@ -28,12 +28,12 @@ "api-supported-versions": "2022-09-26-preview, 2023-07-12", "Content-Length": "15", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:24 GMT", - "MS-CV": "\u002BCniR9QVIEGA32UJkR4QfA.0", + "Date": "Wed, 12 Jul 2023 16:29:53 GMT", + "MS-CV": "RSyBEk9wUE6QULKGSLrGgA.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0jAWaZAAAAACMrjUaVQ0UR7TbKlz3XAnnREZXMzBFREdFMTYxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Azure-Ref": "0AtWuZAAAAABKlcbybtm\u002BSKxsjbL3wwgKREZXMzBFREdFMTYxNABjYzkyNzU4ZC0wNWY3LTRhZDYtYWE1ZS0wZmE5NzE4ZDg5ODU=", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "227ms" + "X-Processing-Time": "278ms" }, "ResponseBody": { "alphaIds": [] @@ -58,8 +58,8 @@ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/112.0.5614.0 Safari/537.36", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:23 GMT", - "x-ms-useragent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 OS" + "x-ms-date": "Wed, 12 Jul 2023 16:29:52 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, @@ -67,12 +67,12 @@ "api-supported-versions": "2022-09-26-preview, 2023-07-12", "Content-Length": "15", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:24 GMT", - "MS-CV": "DSOum7sjoEew0NjXEUhFpQ.0", + "Date": "Wed, 12 Jul 2023 16:29:53 GMT", + "MS-CV": "S8mvqeAQBkyLCjRss\u002BY8Dg.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0jAWaZAAAAABzLsZixf9eSqGZuAVBMFTnREZXMzBFREdFMTYxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Azure-Ref": "0AtWuZAAAAABWLPMp0HIaRKJVBkNz9NZiREZXMzBFREdFMTYxNABjYzkyNzU4ZC0wNWY3LTRhZDYtYWE1ZS0wZmE5NzE4ZDg5ODU=", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "183ms" + "X-Processing-Time": "284ms" }, "ResponseBody": { "alphaIds": [] diff --git a/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids_countries.json b/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids_countries.json index 3add96047820..3a5505d8c362 100644 --- a/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids_countries.json +++ b/sdk/communication/communication-alpha-ids/recordings/browsers/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids_countries.json @@ -19,8 +19,8 @@ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/112.0.5614.0 Safari/537.36", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:23 GMT", - "x-ms-useragent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 OS" + "x-ms-date": "Wed, 12 Jul 2023 16:29:52 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, @@ -28,12 +28,12 @@ "api-supported-versions": "2022-09-26-preview, 2023-07-12", "Content-Length": "50", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:24 GMT", - "MS-CV": "Oo\u002BRosL8nk6Sb5h2RQBOSw.0", + "Date": "Wed, 12 Jul 2023 16:29:55 GMT", + "MS-CV": "zKQ8wRa2XkSA71WiaSggAg.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0jQWaZAAAAADOxWzBjakHSozW5o27uvHUREZXMzBFREdFMTYxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "X-Azure-Ref": "0AtWuZAAAAACzN7/ZvI3bQpn5JjS4QceLREZXMzBFREdFMTYxNABjYzkyNzU4ZC0wNWY3LTRhZDYtYWE1ZS0wZmE5NzE4ZDg5ODU=", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "316ms" + "X-Processing-Time": "1111ms" }, "ResponseBody": { "countries": [ diff --git a/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__manage_configuration/recording_can_list_all_dynamic_alpha_ids_countries.json b/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__manage_configuration/recording_can_list_all_dynamic_alpha_ids_countries.json index a6869d852543..82e981cd0331 100644 --- a/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__manage_configuration/recording_can_list_all_dynamic_alpha_ids_countries.json +++ b/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__manage_configuration/recording_can_list_all_dynamic_alpha_ids_countries.json @@ -11,20 +11,23 @@ "User-Agent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 Node/v18.13.0 OS/(x64-Linux-5.15.90.1-microsoft-standard-WSL2)", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:09 GMT" + "x-ms-date": "Wed, 12 Jul 2023 16:29:39 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { + "Accept-Ranges": "bytes", "api-supported-versions": "2022-09-26-preview, 2023-07-12", + "Connection": "keep-alive", "Content-Length": "115", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:11 GMT", - "MS-CV": "ZNZw1JlNxkGGdxB51lVRBg.0", + "Date": "Wed, 12 Jul 2023 16:29:42 GMT", + "MS-CV": "RQHf7xBQAU\u002BWhNxA0KAUKw.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0fwWaZAAAAADxGLYJq5w0SbxR8gBIhIHtREZXMzBFREdFMTUxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "x-azure-ref": "20230712T162941Z-8y7szcdm2p25h06gxbcp527udc00000000bg000000003ana", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "415ms" + "X-Processing-Time": "947ms" }, "ResponseBody": { "countries": [ diff --git a/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__manage_configuration/recording_can_manage_configuration.json b/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__manage_configuration/recording_can_manage_configuration.json index 7c8e86e2385a..5d6398e90d7d 100644 --- a/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__manage_configuration/recording_can_manage_configuration.json +++ b/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__manage_configuration/recording_can_manage_configuration.json @@ -13,22 +13,25 @@ "User-Agent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 Node/v18.13.0 OS/(x64-Linux-5.15.90.1-microsoft-standard-WSL2)", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "JrNCayWTdjyW0IkLSnegu/ZtE/xRKwxrE4ojwpDzCio=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:08 GMT" + "x-ms-date": "Wed, 12 Jul 2023 16:29:34 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": { "enabled": true }, "StatusCode": 200, "ResponseHeaders": { + "Accept-Ranges": "bytes", "api-supported-versions": "2022-09-26-preview, 2023-07-12", + "Connection": "keep-alive", "Content-Length": "16", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:09 GMT", - "MS-CV": "zxMpMRb1qUS4EepAgTIkoQ.0", + "Date": "Wed, 12 Jul 2023 16:29:38 GMT", + "MS-CV": "jMB1LofkT0uWILmWIazj5g.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0fgWaZAAAAACTcFp7m/\u002BYQYMdvUEYRlFRREZXMzBFREdFMTUxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "x-azure-ref": "20230712T162937Z-8y7szcdm2p25h06gxbcp527udc00000000bg000000003a5u", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "422ms" + "X-Processing-Time": "1548ms" }, "ResponseBody": { "enabled": true @@ -45,20 +48,23 @@ "User-Agent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 Node/v18.13.0 OS/(x64-Linux-5.15.90.1-microsoft-standard-WSL2)", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:09 GMT" + "x-ms-date": "Wed, 12 Jul 2023 16:29:37 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { + "Accept-Ranges": "bytes", "api-supported-versions": "2022-09-26-preview, 2023-07-12", + "Connection": "keep-alive", "Content-Length": "16", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:10 GMT", - "MS-CV": "szIIkg4fUUutMHrPMkOdvg.0", + "Date": "Wed, 12 Jul 2023 16:29:39 GMT", + "MS-CV": "RKzyMtqD1E6bHm3HzOENcg.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0fgWaZAAAAADd\u002Bxpv\u002Bu0VSr/LsBqssGXdREZXMzBFREdFMTUxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "x-azure-ref": "20230712T162939Z-8y7szcdm2p25h06gxbcp527udc00000000bg000000003abb", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "205ms" + "X-Processing-Time": "810ms" }, "ResponseBody": { "enabled": true @@ -77,22 +83,25 @@ "User-Agent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 Node/v18.13.0 OS/(x64-Linux-5.15.90.1-microsoft-standard-WSL2)", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "Ws8/93tEIGd7WSMHHzA/rKunqSc6NGKEpmeidd8yUUY=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:09 GMT" + "x-ms-date": "Wed, 12 Jul 2023 16:29:38 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": { "enabled": false }, "StatusCode": 200, "ResponseHeaders": { + "Accept-Ranges": "bytes", "api-supported-versions": "2022-09-26-preview, 2023-07-12", + "Connection": "keep-alive", "Content-Length": "17", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:10 GMT", - "MS-CV": "KK18JwBXmEGPw5aCU/fPCw.0", + "Date": "Wed, 12 Jul 2023 16:29:41 GMT", + "MS-CV": "b5alhZEx40qmRS3TMzYb6Q.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0fwWaZAAAAAALySJMTqc5SbniDK2gw6\u002BjREZXMzBFREdFMTUxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "x-azure-ref": "20230712T162939Z-8y7szcdm2p25h06gxbcp527udc00000000bg000000003af2", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "263ms" + "X-Processing-Time": "1193ms" }, "ResponseBody": { "enabled": false diff --git a/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids.json b/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids.json index 4f0287a36ce6..0a2b85a3a2f5 100644 --- a/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids.json +++ b/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids.json @@ -11,20 +11,23 @@ "User-Agent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 Node/v18.13.0 OS/(x64-Linux-5.15.90.1-microsoft-standard-WSL2)", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:10 GMT" + "x-ms-date": "Wed, 12 Jul 2023 16:29:40 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { + "Accept-Ranges": "bytes", "api-supported-versions": "2022-09-26-preview, 2023-07-12", + "Connection": "keep-alive", "Content-Length": "15", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:11 GMT", - "MS-CV": "hGFvYnCt8Um\u002BJAQA5yaRnA.0", + "Date": "Wed, 12 Jul 2023 16:29:42 GMT", + "MS-CV": "3JGu5KDu5UGpf0kiIJ4J\u002BA.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0gAWaZAAAAADZ7bQlBvurTpVFmsOZwBEAREZXMzBFREdFMTUxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "x-azure-ref": "20230712T162942Z-8y7szcdm2p25h06gxbcp527udc00000000bg000000003arc", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "448ms" + "X-Processing-Time": "522ms" }, "ResponseBody": { "alphaIds": [] @@ -41,20 +44,23 @@ "User-Agent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 Node/v18.13.0 OS/(x64-Linux-5.15.90.1-microsoft-standard-WSL2)", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:10 GMT" + "x-ms-date": "Wed, 12 Jul 2023 16:29:41 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { + "Accept-Ranges": "bytes", "api-supported-versions": "2022-09-26-preview, 2023-07-12", + "Connection": "keep-alive", "Content-Length": "15", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:12 GMT", - "MS-CV": "8sST0o/FgUWZLQbXZLhzGA.0", + "Date": "Wed, 12 Jul 2023 16:29:43 GMT", + "MS-CV": "DHCEcq\u002BQ6k6I5g/\u002B94bcWA.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0gAWaZAAAAAA5t3\u002BMPkv/QZOk21lWDP11REZXMzBFREdFMTUxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "x-azure-ref": "20230712T162942Z-8y7szcdm2p25h06gxbcp527udc00000000bg000000003asw", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "302ms" + "X-Processing-Time": "494ms" }, "ResponseBody": { "alphaIds": [] diff --git a/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids_countries.json b/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids_countries.json index 28dbb9e5f11c..e2627ded297f 100644 --- a/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids_countries.json +++ b/sdk/communication/communication-alpha-ids/recordings/node/alphaidsclient__preregistered_alpha_ids_operations/recording_can_list_all_preregistered_alpha_ids_countries.json @@ -11,20 +11,23 @@ "User-Agent": "azsdk-js-communication-alpha-ids/1.0.0-beta.2 core-rest-pipeline/1.11.1 Node/v18.13.0 OS/(x64-Linux-5.15.90.1-microsoft-standard-WSL2)", "x-ms-client-request-id": "00000000-0000-0000-0000-000000000000", "x-ms-content-sha256": "47DEQpj8HBSa\u002B/TImW\u002B5JCeuQeRkm5NMpJWZG3hSuFU=", - "x-ms-date": "Mon, 26 Jun 2023 21:39:11 GMT" + "x-ms-date": "Wed, 12 Jul 2023 16:29:41 GMT", + "x-ms-useragent": "fake-useragent" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { + "Accept-Ranges": "bytes", "api-supported-versions": "2022-09-26-preview, 2023-07-12", + "Connection": "keep-alive", "Content-Length": "50", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 26 Jun 2023 21:39:12 GMT", - "MS-CV": "\u002B/3wMuJsdkm3sZtTdEhm\u002Bg.0", + "Date": "Wed, 12 Jul 2023 16:29:44 GMT", + "MS-CV": "DdNiQqsDbkC/Zpfs/PJwRw.0", "Strict-Transport-Security": "max-age=2592000", - "X-Azure-Ref": "0gQWaZAAAAAA7JnAs2bIRRYk\u002B3ntj\u002BsxRREZXMzBFREdFMTUxNwA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=", + "x-azure-ref": "20230712T162943Z-8y7szcdm2p25h06gxbcp527udc00000000bg000000003ava", "X-Cache": "CONFIG_NOCACHE", - "X-Processing-Time": "357ms" + "X-Processing-Time": "673ms" }, "ResponseBody": { "countries": [ diff --git a/sdk/communication/communication-alpha-ids/src/alphaIdsClient.ts b/sdk/communication/communication-alpha-ids/src/alphaIdsClient.ts index 4ced71477058..a42f77e2ed28 100644 --- a/sdk/communication/communication-alpha-ids/src/alphaIdsClient.ts +++ b/sdk/communication/communication-alpha-ids/src/alphaIdsClient.ts @@ -19,6 +19,7 @@ import { createCommunicationAuthPolicy } from "@azure/communication-common"; import { logger } from "./utils"; import { tracingClient } from "./generated/src/tracing"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { createAlphaIDsPagingPolicy } from "./utils/customPipelinePolicies"; /** * Client options used to configure the AlphaIdsClient API requests. @@ -66,6 +67,9 @@ export class AlphaIdsClient { this.client = new AlphaIDsGeneratedClient(url, internalPipelineOptions); const authPolicy = createCommunicationAuthPolicy(credential); this.client.pipeline.addPolicy(authPolicy); + // This policy is a temporary workarounds to address compatibility issues with Azure Core V2. + const alphaIDsPagingPolicy = createAlphaIDsPagingPolicy(url); + this.client.pipeline.addPolicy(alphaIDsPagingPolicy); } public getDynamicAlphaIdConfiguration( diff --git a/sdk/communication/communication-alpha-ids/src/utils/customPipelinePolicies.ts b/sdk/communication/communication-alpha-ids/src/utils/customPipelinePolicies.ts new file mode 100644 index 000000000000..e9f72f02f4e7 --- /dev/null +++ b/sdk/communication/communication-alpha-ids/src/utils/customPipelinePolicies.ts @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { FullOperationResponse } from "@azure/core-client"; +import { + PipelinePolicy, + PipelineRequest, + PipelineResponse, + SendRequest, +} from "@azure/core-rest-pipeline"; + +/** + * Creates a `PipelinePolicy` that converts relative URL values in the `nextLink` property to absolute URLs. + * + * This is necessary because the Core V2 library does not support paging with relative links at time of writing. + * + * @param host - The base URL of the resource. + * @returns the `PipelinePolicy` that addresses the issue. + */ +export function createAlphaIDsPagingPolicy(host: string): PipelinePolicy { + return { + name: "alphaIDsPagingPolicy", + async sendRequest(request: PipelineRequest, next: SendRequest): Promise { + const response: FullOperationResponse = await next(request); + let nextLink: string = response?.parsedBody?.nextLink; + + if (nextLink && !nextLink.startsWith(host)) { + nextLink = host.endsWith("/") ? nextLink.substring(1) : nextLink; + const absolutePath = `${host}${nextLink}`; + response.parsedBody.nextLink = absolutePath; + } + + return response; + }, + }; +} diff --git a/sdk/communication/communication-alpha-ids/test/public/dynamicAlphaId.spec.ts b/sdk/communication/communication-alpha-ids/test/public/dynamicAlphaId.spec.ts index 81101f323bc6..9d1e6961f20f 100644 --- a/sdk/communication/communication-alpha-ids/test/public/dynamicAlphaId.spec.ts +++ b/sdk/communication/communication-alpha-ids/test/public/dynamicAlphaId.spec.ts @@ -23,16 +23,73 @@ describe(`AlphaIdsClient - manage configuration`, function () { } }); - it("can manage configuration", async function () { - let configuration: DynamicAlphaIdConfiguration; + const _upsertConfiguration = async (config: boolean): Promise => { + let configurationResponse: FullOperationResponse | undefined; + const getConfigurationRequest: OperationOptions = { + onResponse: (response) => { + configurationResponse = response; + }, + }; + try { + const newConfig = await client.upsertDynamicAlphaIdConfiguration( + config, + getConfigurationRequest + ); + return newConfig; + } catch (error) { + assert.fail( + `There was an error calling upsertDynamicAlphaIdConfiguration. MS-CV: ${configurationResponse?.headers.get( + "MS-CV" + )}, ${JSON.stringify(error)} ` + ); + } + }; + + const _getConfiguration = async (): Promise => { + let configurationResponse: FullOperationResponse | undefined; + const getConfigurationRequest: OperationOptions = { + onResponse: (response) => { + configurationResponse = response; + }, + }; + try { + const newConfig = await client.getDynamicAlphaIdConfiguration(getConfigurationRequest); + return newConfig; + } catch (error) { + assert.fail( + `There was an error calling getDynamicAlphaIdConfiguration. MS-CV: ${configurationResponse?.headers.get( + "MS-CV" + )}, ${JSON.stringify(error)}` + ); + } + }; + + const _getDynamicCountries = async (): Promise => { let configurationResponse: FullOperationResponse | undefined; const getConfigurationRequest: OperationOptions = { onResponse: (response) => { configurationResponse = response; }, }; + try { + const countries = (await client.getDynamicAlphaIdCountries(getConfigurationRequest)) + .countries; + return countries; + } catch (error) { + assert.fail( + `There was an error calling getDynamicAlphaIdCountries. MS-CV: ${configurationResponse?.headers.get( + "MS-CV" + )}, ${JSON.stringify(error)}` + ); + } + }; + + it("can manage configuration", async function () { + let configuration: DynamicAlphaIdConfiguration; + let configurationResponse: FullOperationResponse | undefined; + + configuration = await _upsertConfiguration(true); - configuration = await client.upsertDynamicAlphaIdConfiguration(true, getConfigurationRequest); assert.isOk(configuration); assert.isTrue( configuration.enabled, @@ -40,10 +97,10 @@ describe(`AlphaIdsClient - manage configuration`, function () { CV: ${configurationResponse?.headers.get("MS-CV")}` ); - configuration = await client.getDynamicAlphaIdConfiguration(getConfigurationRequest); + configuration = await _getConfiguration(); assert.isOk(configuration); - configuration = await client.upsertDynamicAlphaIdConfiguration(false, getConfigurationRequest); + configuration = await _upsertConfiguration(false); assert.isOk(configuration); assert.isFalse( configuration.enabled, @@ -53,7 +110,7 @@ describe(`AlphaIdsClient - manage configuration`, function () { }).timeout(15000); it("can list all dynamic alpha ids countries", async function () { - const countries = (await client.getDynamicAlphaIdCountries()).countries; + const countries = await _getDynamicCountries(); countries?.forEach((countryCode) => { assert.isNotNull(countryCode); }); diff --git a/sdk/communication/communication-alpha-ids/test/public/preRegisteredAlphaId.spec.ts b/sdk/communication/communication-alpha-ids/test/public/preRegisteredAlphaId.spec.ts index c1f330b1f5e8..a842fd478ad5 100644 --- a/sdk/communication/communication-alpha-ids/test/public/preRegisteredAlphaId.spec.ts +++ b/sdk/communication/communication-alpha-ids/test/public/preRegisteredAlphaId.spec.ts @@ -6,6 +6,7 @@ import { Recorder } from "@azure-tools/test-recorder"; import { AlphaIdsClient } from "../../src"; import { assert } from "chai"; import { createRecordedClient } from "./utils/recordedClient"; +import { FullOperationResponse, OperationOptions } from "@azure/core-client"; describe(`AlphaIdsClient - Preregistered Alpha Ids Operations`, function () { let recorder: Recorder; @@ -22,27 +23,71 @@ describe(`AlphaIdsClient - Preregistered Alpha Ids Operations`, function () { }); it("can list all pre-registered alpha ids", async function () { + let configurationResponse: FullOperationResponse | undefined; + const getConfigurationRequest: OperationOptions = { + onResponse: (response) => { + configurationResponse = response; + }, + }; let totalItems = 0; - for await (const alphaId of client.getAlphaIds()) { - totalItems++; - assert.isNotNull(alphaId.value); + try { + for await (const alphaId of client.getAlphaIds(getConfigurationRequest)) { + totalItems++; + assert.isNotNull(alphaId.value); + } + } catch (error) { + assert.fail( + `There was an error calling getAlphaIds. MS-CV: ${configurationResponse?.headers.get( + "MS-CV" + )}, ${JSON.stringify(error)}` + ); } // now test using pagination const itemsPerPage = totalItems > 1 ? Math.floor(totalItems / 2) : 1; - const pages = client.getAlphaIds({ top: itemsPerPage }).byPage(); - for await (const page of pages) { - // loop over each item in the page - for (const alphaId of page) { - assert.isNotNull(alphaId.value); + try { + const pages = client + .getAlphaIds({ + top: itemsPerPage, + onResponse: (response) => { + configurationResponse = response; + }, + }) + .byPage(); + for await (const page of pages) { + // loop over each item in the page + for (const alphaId of page) { + assert.isNotNull(alphaId.value); + } } + } catch (error) { + assert.fail( + `There was an error calling getAlphaIds by page. MS-CV: ${configurationResponse?.headers.get( + "MS-CV" + )}, ${JSON.stringify(error)}` + ); } }).timeout(40000); it("can list all pre-registered alpha ids countries", async function () { - const countries = (await client.getPreRegisteredAlphaIdCountries()).countries; - countries?.forEach((countryCode) => { - assert.isNotNull(countryCode); - }); + let configurationResponse: FullOperationResponse | undefined; + const getConfigurationRequest: OperationOptions = { + onResponse: (response) => { + configurationResponse = response; + }, + }; + try { + const countries = (await client.getPreRegisteredAlphaIdCountries(getConfigurationRequest)) + .countries; + countries?.forEach((countryCode) => { + assert.isNotNull(countryCode); + }); + } catch (error) { + assert.fail( + `There was an error calling getPreRegisteredAlphaIdCountries by page. MS-CV: ${configurationResponse?.headers.get( + "MS-CV" + )}, ${JSON.stringify(error)}` + ); + } }).timeout(20000); }); diff --git a/sdk/communication/communication-alpha-ids/test/public/utils/msUserAgentPolicy.ts b/sdk/communication/communication-alpha-ids/test/public/utils/msUserAgentPolicy.ts new file mode 100644 index 000000000000..50b6100c6711 --- /dev/null +++ b/sdk/communication/communication-alpha-ids/test/public/utils/msUserAgentPolicy.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + PipelinePolicy, + PipelineRequest, + PipelineResponse, + SendRequest, +} from "@azure/core-rest-pipeline"; +import { env } from "@azure-tools/test-recorder"; + +export function createMSUserAgentPolicy(): PipelinePolicy { + return { + name: "msUserAgentPolicy", + async sendRequest(request: PipelineRequest, next: SendRequest): Promise { + const useragent = env.AZURE_USERAGENT_OVERRIDE; + if (useragent) { + request.headers.set("x-ms-useragent", useragent); + } + + return next(request); + }, + }; +} diff --git a/sdk/communication/communication-alpha-ids/test/public/utils/recordedClient.ts b/sdk/communication/communication-alpha-ids/test/public/utils/recordedClient.ts index 1ee7aa118da0..aec9cfa75e78 100644 --- a/sdk/communication/communication-alpha-ids/test/public/utils/recordedClient.ts +++ b/sdk/communication/communication-alpha-ids/test/public/utils/recordedClient.ts @@ -14,6 +14,7 @@ import { AlphaIdsClient } from "../../../src"; import { Context } from "mocha"; import { isNode } from "@azure/test-utils"; import { parseConnectionString } from "@azure/communication-common"; +import { createMSUserAgentPolicy } from "./msUserAgentPolicy"; if (isNode) { dotenv.config(); @@ -29,6 +30,7 @@ const envSetupForPlayback: { [k: string]: string } = { AZURE_CLIENT_ID: "SomeClientId", AZURE_CLIENT_SECRET: "azure_client_secret", AZURE_TENANT_ID: "SomeTenantId", + AZURE_USERAGENT_OVERRIDE: "fake-useragent", }; export const recorderOptions: RecorderStartOptions = { @@ -60,7 +62,14 @@ export async function createRecordedClient( return { client: new AlphaIdsClient( assertEnvironmentVariable("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING"), - recorder.configureClientOptions({}) + recorder.configureClientOptions({ + additionalPolicies: [ + { + policy: createMSUserAgentPolicy(), + position: "perCall", + }, + ], + }) ), recorder, };