From 5fe93bddcbfd1b38301a5b22cbbe5d98ca6f1eef Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Wed, 24 Nov 2021 10:32:01 -0800 Subject: [PATCH 01/19] Add sample unified recorder tests to template --- sdk/template/template/package.json | 9 +- ...determined_setting_has_expected_value.json | 56 ------- ...redetermined_setting_has_expected_value.js | 148 ------------------ .../recording_storagequeue_create_queue.json | 35 +++++ .../recording_datatables_create_entity.json | 116 ++++++++++++++ .../test/public/configurationClient.spec.ts | 102 ------------ .../template/test/public/core-v1-test.spec.ts | 78 +++++++++ .../template/test/public/core-v2-test.spec.ts | 72 +++++++++ sdk/template/template/test/utils/utils.ts | 20 +++ 9 files changed, 327 insertions(+), 309 deletions(-) delete mode 100644 sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json delete mode 100644 sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.js create mode 100644 sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json create mode 100644 sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json delete mode 100644 sdk/template/template/test/public/configurationClient.spec.ts create mode 100644 sdk/template/template/test/public/core-v1-test.spec.ts create mode 100644 sdk/template/template/test/public/core-v2-test.spec.ts create mode 100644 sdk/template/template/test/utils/utils.ts diff --git a/sdk/template/template/package.json b/sdk/template/template/package.json index 24da0e7b10e8..2cdb3d2e6846 100644 --- a/sdk/template/template/package.json +++ b/sdk/template/template/package.json @@ -48,8 +48,8 @@ "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", "test:node": "npm run clean && tsc -p . && npm run unit-test:node && npm run integration-test:node", "test": "npm run clean && tsc -p . && npm run unit-test:node && rollup -c 2>&1 && npm run unit-test:browser && npm run integration-test", - "unit-test:browser": "karma start --single-run", - "unit-test:node": "mocha -r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"", + "unit-test:browser": "dev-tool run test:browser", + "unit-test:node": "dev-tool run test:node-ts-input --mocha=\"--timeout 1200000 'test/**/*.spec.ts'\"", "unit-test": "npm run unit-test:node && npm run unit-test:browser" }, "files": [ @@ -123,7 +123,10 @@ "source-map-support": "^0.5.9", "typedoc": "0.15.2", "typescript": "~4.2.0", - "util": "^0.12.1" + "util": "^0.12.1", + "@azure-tools/test-recorder-new": "~1.0.0", + "@azure/storage-queue": "~12.8.0-beta.2", + "@azure/data-tables": "~13.0.1" }, "//sampleConfiguration": { "skipFolder": false, diff --git a/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json b/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json deleted file mode 100644 index b1ad21521a3e..000000000000 --- a/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "recordings": [ - { - "method": "POST", - "url": "https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/oauth2/v2.0/token", - "query": {}, - "requestBody": "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fmyappconfig.azconfig.io%2F.default", - "status": 200, - "response": "{\"token_type\":\"Bearer\",\"expires_in\":3599,\"ext_expires_in\":3599,\"access_token\":\"access_token\"}", - "responseHeaders": { - "cache-control": "no-store, no-cache", - "content-length": "1491", - "content-type": "application/json; charset=utf-8", - "date": "Mon, 26 Oct 2020 21:18:44 GMT", - "expires": "-1", - "p3p": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"", - "pragma": "no-cache", - "referrer-policy": "strict-origin-when-cross-origin", - "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-content-type-options": "nosniff", - "x-ms-ests-server": "2.1.11169.11 - SCUS ProdSlices", - "x-ms-request-id": "a05c2f53-347b-43be-8e75-8adac3e40101" - } - }, - { - "method": "GET", - "url": "https://myappconfig.azconfig.io/kv/test-key", - "query": { - "api-version": "1.0" - }, - "requestBody": null, - "status": 200, - "response": "{\"etag\":\"cbARBFLodwGLL3qktvCwmLa1vet\",\"key\":\"test-key\",\"label\":null,\"content_type\":\"\",\"value\":\"test-value\",\"tags\":{},\"locked\":false,\"last_modified\":\"2020-10-16T00:08:12+00:00\"}", - "responseHeaders": { - "access-control-allow-credentials": "true", - "access-control-allow-origin": "*", - "access-control-expose-headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, WWW-Authenticate", - "content-type": "application/vnd.microsoft.appconfig.kv+json; charset=utf-8", - "date": "Mon, 26 Oct 2020 21:18:45 GMT", - "etag": "\"cbARBFLodwGLL3qktvCwmLa1vet\"", - "last-modified": "Fri, 16 Oct 2020 00:08:12 GMT", - "server": "openresty/1.17.8.2", - "status": "200", - "strict-transport-security": "max-age=15724800; includeSubDomains", - "sync-token": "zAJw6V16=MDozIzUxNTAyNjY=;sn=5150266", - "x-ms-correlation-request-id": "764e6e56-1dac-4c11-94b7-8a45c90d3bb9", - "x-ms-request-id": "764e6e56-1dac-4c11-94b7-8a45c90d3bb9" - } - } - ], - "uniqueTestInfo": { - "uniqueName": {}, - "newDate": {} - }, - "hash": "dbff5419a75940fa5401dd76cca9de72" -} diff --git a/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.js b/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.js deleted file mode 100644 index 75b93d96caa5..000000000000 --- a/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.js +++ /dev/null @@ -1,148 +0,0 @@ -let nock = require('nock'); - -module.exports.hash = "284f885078bc2c7cebc8f8ae9be8dc2c"; - -module.exports.testInfo = {"uniqueName":{},"newDate":{}} - -nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) - .get('/common/discovery/instance') - .query(true) - .reply(200, {"tenant_discovery_endpoint":"https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/v2.0/.well-known/openid-configuration","api-version":"1.1","metadata":[{"preferred_network":"login.microsoftonline.com","preferred_cache":"login.windows.net","aliases":["login.microsoftonline.com","login.windows.net","login.microsoft.com","sts.windows.net"]},{"preferred_network":"login.partner.microsoftonline.cn","preferred_cache":"login.partner.microsoftonline.cn","aliases":["login.partner.microsoftonline.cn","login.chinacloudapi.cn"]},{"preferred_network":"login.microsoftonline.de","preferred_cache":"login.microsoftonline.de","aliases":["login.microsoftonline.de"]},{"preferred_network":"login.microsoftonline.us","preferred_cache":"login.microsoftonline.us","aliases":["login.microsoftonline.us","login.usgovcloudapi.net"]},{"preferred_network":"login-us.microsoftonline.com","preferred_cache":"login-us.microsoftonline.com","aliases":["login-us.microsoftonline.com"]}]}, [ - 'Cache-Control', - 'max-age=86400, private', - 'Content-Type', - 'application/json; charset=utf-8', - 'Strict-Transport-Security', - 'max-age=31536000; includeSubDomains', - 'X-Content-Type-Options', - 'nosniff', - 'Access-Control-Allow-Origin', - '*', - 'Access-Control-Allow-Methods', - 'GET, OPTIONS', - 'P3P', - 'CP="DSP CUR OTPi IND OTRi ONL FIN"', - 'x-ms-request-id', - '07df832e-67e9-4b00-a217-88c0f83e7f00', - 'x-ms-ests-server', - '2.1.11787.14 - EUS ProdSlices', - 'Set-Cookie', - 'fpc=AklbZDuZ-z9MvbjTqYC1cm8; expires=Mon, 12-Jul-2021 01:38:57 GMT; path=/; secure; HttpOnly; SameSite=None', - 'Set-Cookie', - 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrYhrtx1chLthdEhWpdZwpobQFLC2yhGY-8rL3wgE7RjM205Ajz4xnCH8x0mUNVi1RcdQhSO79VS7W98F2Mbf6_OqjZmj7TZeFQVHtI7KnhnWFbCVEn0i_FdC6Hgat2UX1trwts4Ys0BRS98pJhrPfcw5swe5GfqxASqvnVdcDYNUgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None', - 'Set-Cookie', - 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', - 'Set-Cookie', - 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', - 'Date', - 'Sat, 12 Jun 2021 01:38:56 GMT', - 'Content-Length', - '980' -]); - -nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) - .get('/12345678-1234-1234-1234-123456789012/v2.0/.well-known/openid-configuration') - .reply(200, {"token_endpoint":"https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/oauth2/v2.0/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt","client_secret_basic"],"jwks_uri":"https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/discovery/v2.0/keys","response_modes_supported":["query","fragment","form_post"],"subject_types_supported":["pairwise"],"id_token_signing_alg_values_supported":["RS256"],"response_types_supported":["code","id_token","code id_token","id_token token"],"scopes_supported":["openid","profile","email","offline_access"],"issuer":"https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/v2.0","request_uri_parameter_supported":false,"userinfo_endpoint":"https://graph.microsoft.com/oidc/userinfo","authorization_endpoint":"https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/oauth2/v2.0/authorize","device_authorization_endpoint":"https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/oauth2/v2.0/devicecode","http_logout_supported":true,"frontchannel_logout_supported":true,"end_session_endpoint":"https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/oauth2/v2.0/logout","claims_supported":["sub","iss","cloud_instance_name","cloud_instance_host_name","cloud_graph_host_name","msgraph_host","aud","exp","iat","auth_time","acr","nonce","preferred_username","name","tid","ver","at_hash","c_hash","email"],"kerberos_endpoint":"https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/kerberos","tenant_region_scope":"WW","cloud_instance_name":"microsoftonline.com","cloud_graph_host_name":"graph.windows.net","msgraph_host":"graph.microsoft.com","rbac_url":"https://pas.windows.net"}, [ - 'Cache-Control', - 'max-age=86400, private', - 'Content-Type', - 'application/json; charset=utf-8', - 'Strict-Transport-Security', - 'max-age=31536000; includeSubDomains', - 'X-Content-Type-Options', - 'nosniff', - 'Access-Control-Allow-Origin', - '*', - 'Access-Control-Allow-Methods', - 'GET, OPTIONS', - 'P3P', - 'CP="DSP CUR OTPi IND OTRi ONL FIN"', - 'x-ms-request-id', - 'b9fedfca-792d-4092-a143-9f31d7e52c00', - 'x-ms-ests-server', - '2.1.11829.4 - NCUS ProdSlices', - 'Set-Cookie', - 'fpc=AklbZDuZ-z9MvbjTqYC1cm8; expires=Mon, 12-Jul-2021 01:38:57 GMT; path=/; secure; HttpOnly; SameSite=None', - 'Set-Cookie', - 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrurErfe2krcodjLBX3bYrJNkeQj7BF8DuCR2-j08XG0ytP_sNsxDKfhz1rhOwUoWCU2wpg9eQyutCZwjrX3KxUzp1ey7l4J7r7tZ3GMvTOB3QV8qgObPsDEUfmuZUucHJCK2qUlt_MHho9PUVhxotbi4w4SyKcAsOfe2O6UnNRDogAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None', - 'Set-Cookie', - 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', - 'Set-Cookie', - 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', - 'Date', - 'Sat, 12 Jun 2021 01:38:56 GMT', - 'Content-Length', - '1753' -]); - -nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) - .filteringRequestBody(function (body) { - return body.replace(/client-request-id=[^&]*/g, "client-request-id=client-request-id"); - }) - .post('/12345678-1234-1234-1234-123456789012/oauth2/v2.0/token', "client_id=azure_client_id&scope=https%3A%2F%2Fmyappconfig.azconfig.io%2F.default%20openid%20profile%20offline_access&grant_type=client_credentials&client-request-id=client-request-id&client_secret=azure_client_secret") - .reply(200, {"token_type":"Bearer","expires_in":86399,"ext_expires_in":86399,"access_token":"access_token"}, [ - 'Cache-Control', - 'no-store, no-cache', - 'Pragma', - 'no-cache', - 'Content-Type', - 'application/json; charset=utf-8', - 'Expires', - '-1', - 'Strict-Transport-Security', - 'max-age=31536000; includeSubDomains', - 'X-Content-Type-Options', - 'nosniff', - 'P3P', - 'CP="DSP CUR OTPi IND OTRi ONL FIN"', - 'x-ms-request-id', - 'ba53f6ce-8702-41dd-8091-90869e8f2c00', - 'x-ms-ests-server', - '2.1.11829.4 - EUS ProdSlices', - 'x-ms-clitelem', - '1,0,0,,', - 'Set-Cookie', - 'fpc=AklbZDuZ-z9MvbjTqYC1cm-WH-CrAQAAADAHVtgOAAAA; expires=Mon, 12-Jul-2021 01:38:57 GMT; path=/; secure; HttpOnly; SameSite=None', - 'Set-Cookie', - 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', - 'Set-Cookie', - 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', - 'Date', - 'Sat, 12 Jun 2021 01:38:56 GMT', - 'Content-Length', - '1335' -]); - -nock('https://myappconfig.azconfig.io:443', {"encodedQueryParams":true}) - .get('/kv/test-key') - .query(true) - .reply(200, {"etag":"FQ2XSpKRpSv2FAbNvw2sdY9Hq2G","key":"test-key","label":null,"content_type":"text/plain","value":"test-value","tags":{},"locked":false,"last_modified":"2021-02-16T18:26:35+00:00"}, [ - 'Server', - 'openresty/1.17.8.2', - 'Date', - 'Sat, 12 Jun 2021 01:38:58 GMT', - 'Content-Type', - 'application/vnd.microsoft.appconfig.kv+json; charset=utf-8', - 'Transfer-Encoding', - 'chunked', - 'Connection', - 'keep-alive', - 'Last-Modified', - 'Tue, 16 Feb 2021 18:26:35 GMT', - 'ETag', - '"FQ2XSpKRpSv2FAbNvw2sdY9Hq2G"', - 'Sync-Token', - 'zAJw6V16=MDoxNyM5MjU3MTIx;sn=9257121', - 'x-ms-request-id', - 'd24c5c59-432d-46ba-ad96-598703b18e87', - 'x-ms-correlation-request-id', - 'd24c5c59-432d-46ba-ad96-598703b18e87', - 'Access-Control-Allow-Origin', - '*', - 'Access-Control-Allow-Credentials', - 'true', - 'Access-Control-Expose-Headers', - 'DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate', - 'Strict-Transport-Security', - 'max-age=15724800; includeSubDomains' -]); diff --git a/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json b/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json new file mode 100644 index 000000000000..846dd4bf5935 --- /dev/null +++ b/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json @@ -0,0 +1,35 @@ +{ + "Entries": [ + { + "RequestUri": "https://account_name.queue.core.windows.net/queue-1937?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip,deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "Cookie": "", + "User-Agent": "azsdk-js-storagequeue/12.8.0-beta.2 (NODE-VERSION v16.13.0; Linux 5.10.60.1-microsoft-standard-WSL2)", + "x-ms-client-request-id": "7b474567-b1ee-4711-8e2e-5e9508c4fb6c", + "x-ms-version": "2020-12-06" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 24 Nov 2021 22:58:57 GMT", + "Server": [ + "Windows-Azure-Queue/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-client-request-id": "7b474567-b1ee-4711-8e2e-5e9508c4fb6c", + "x-ms-request-id": "98e8915e-3003-004a-3a86-e18f4f000000", + "x-ms-version": "2020-12-06" + }, + "ResponseBody": null + } + ], + "Variables": { + "queue-name": "queue-1937" + } +} diff --git a/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json b/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json new file mode 100644 index 000000000000..77de70ef1263 --- /dev/null +++ b/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json @@ -0,0 +1,116 @@ +{ + "Entries": [ + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip,deflate", + "Connection": "keep-alive", + "Content-Length": "25", + "Content-Type": "application/json;odata=nometadata", + "DataServiceVersion": "3.0", + "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", + "x-ms-client-request-id": "9de742f8-6db0-4d81-9abc-9796373e9bc6", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "TableName": "table1743" + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Wed, 24 Nov 2021 22:58:59 GMT", + "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1743\u0027)", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "x-ms-client-request-id": "9de742f8-6db0-4d81-9abc-9796373e9bc6", + "x-ms-request-id": "1d501063-9002-001e-2a86-e1c018000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#Tables/@Element", + "TableName": "table1743" + } + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/table1743?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip,deflate", + "Connection": "keep-alive", + "Content-Length": "366", + "Content-Type": "application/json;odata=nometadata", + "DataServiceVersion": "3.0", + "Prefer": "return-no-content", + "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", + "x-ms-client-request-id": "5bbcf084-f61b-4e96-acc9-60a06e0943fb", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "simpleEntity", + "RowKey": "03590009-4169-46ce-9e33-d011dbaf308c", + "stringTypeProperty1": "This is a string", + "stringTypeProperty2": "This is a string", + "stringTypeProperty3": "This is a string", + "stringTypeProperty4": "This is a string", + "stringTypeProperty5": "This is a string", + "stringTypeProperty6": "This is a string", + "stringTypeProperty7": "This is a string" + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1743(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Date": "Wed, 24 Nov 2021 22:58:59 GMT", + "ETag": "W/\u0022datetime\u00272021-11-24T22%3A58%3A59.6477177Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/table1743(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-client-request-id": "5bbcf084-f61b-4e96-acc9-60a06e0943fb", + "x-ms-request-id": "1d501068-9002-001e-2d86-e1c018000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1743\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip,deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", + "x-ms-client-request-id": "892e3bb7-2f91-4281-bf57-865ca74a3f30", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Wed, 24 Nov 2021 22:58:59 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-client-request-id": "892e3bb7-2f91-4281-bf57-865ca74a3f30", + "x-ms-request-id": "1d50106a-9002-001e-2f86-e1c018000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + } + ], + "Variables": { + "table-name": "table1743" + } +} diff --git a/sdk/template/template/test/public/configurationClient.spec.ts b/sdk/template/template/test/public/configurationClient.spec.ts deleted file mode 100644 index 1105de3c2ac9..000000000000 --- a/sdk/template/template/test/public/configurationClient.spec.ts +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { assert } from "chai"; -import { Context } from "mocha"; - -import { ConfigurationClient } from "../../src"; - -import { ClientSecretCredential } from "@azure/identity"; -import { env, record, Recorder } from "@azure-tools/test-recorder"; - -// When the recorder observes the values of these environment variables in any -// recorded HTTP request or response, it will replace them with the values they -// are mapped to below. -const replaceableVariables: Record = { - APPCONFIG_ENDPOINT: "https://myappconfig.azconfig.io", - APPCONFIG_TEST_SETTING_KEY: "test-key", - APPCONFIG_TEST_SETTING_EXPECTED_VALUE: "test-value", - AZURE_TENANT_ID: "12345678-1234-1234-1234-123456789012", - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret" -}; - -function createConfigurationClient(): ConfigurationClient { - // Retrieve the endpoint from the environment variable - // we saved to the .env file earlier - const endpoint = env.APPCONFIG_ENDPOINT; - - // We use ClientSecretCredential instead of DefaultAzureCredential in order - // to ensure that the requests made to the AAD server are always the same. If - // we used DefaultAzureCredential, they might be different on some machines - // than on others, depending on which credentials are available (such as - // Managed Identity or developer credentials). - const credential = new ClientSecretCredential( - env.AZURE_TENANT_ID, - env.AZURE_CLIENT_ID, - env.AZURE_CLIENT_SECRET - ); - - return new ConfigurationClient(endpoint, credential); -} - -// You want to give the test suite a descriptive name. Here, I add [AAD] to -// indicate that the tests are authenticating with the service using Azure -// Active Directory. -describe("[AAD] ConfigurationClient functional tests", function() { - // Declare the client and recorder instances. We will set them using the - // beforeEach hook. - let client: ConfigurationClient; - let recorder: Recorder; - - // NOTE: use of "function" and not ES6 arrow-style functions with the - // beforeEach hook is IMPORTANT due to the use of `this` in the function - // body. - beforeEach(function(this: Context) { - // The recorder has some convenience methods, and we need to store a - // reference to it so that we can `stop()` the recorder later in the - // `afterEach` hook. - recorder = record(this, { - // == Recorder Environment Setup == Add the replaceable variables from - // above - replaceableVariables, - - // We don't use this in the template, but if we had any query parameters - // we wished to discard, we could add them here - queryParametersToSkip: [], - - // Finally, we need to remove the AAD `access_token` from any requests. - // This is very important, as it cannot be removed using environment - // variable or query parameter replacement. The - // `customizationsOnRecordings` field allows us to make arbitrary - // replacements within recordings. - customizationsOnRecordings: [ - (recording: any): any => - recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`) - ] - }); - - // We'll be able to refer to the instantiated `client` in tests, since we - // initialize it before each test - client = createConfigurationClient(); - }); - - // After each test, we need to stop the recording. - afterEach(async function() { - await recorder.stop(); - }); - - it("predetermined setting has expected value", async () => { - const key = env.APPCONFIG_TEST_SETTING_KEY; - const expectedValue = env.APPCONFIG_TEST_SETTING_EXPECTED_VALUE; - - const setting = await client.getConfigurationSetting(key); - - // Make sure the key returned is the same as the key we asked for - assert.equal(key, setting.key); - - // Make sure the value of the setting is the same as the value we entered - // on the environment - assert.equal(expectedValue, setting.value); - }); -}); diff --git a/sdk/template/template/test/public/core-v1-test.spec.ts b/sdk/template/template/test/public/core-v1-test.spec.ts new file mode 100644 index 000000000000..7fb54cfadc32 --- /dev/null +++ b/sdk/template/template/test/public/core-v1-test.spec.ts @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { env, isPlaybackMode } from "@azure-tools/test-recorder"; +import { QueueServiceClient } from "@azure/storage-queue"; +import { TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new"; +import { config } from "dotenv"; +config(); + +// This fake URL will be used in the recording. We use a general regex sanitizer +// (below) to replace the real SAS URL from when we record the test with this +// fake version. +const fakeSASUrl = + "https://account_name.queue.core.windows.net/?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2026-07-10T07:00:24Z&st=2021-07-09T23:00:24Z&spr=https&sig=fake_sig"; + +// These options are passed to the recorder for playback. +const recorderOptions = { + envSetupForPlayback: { + // In playback, we use the fake SAS URL instead of a real one which would have + // been provided via the .env file or otherwise. + STORAGE_SAS_URL: fakeSASUrl, + }, +}; + +const sanitizers = { + // There are several different sanitzers that can be used. A general regex sanitizer + // allows for a simple find and replace based on a given regular expression. This is + // used here to strip out the sensitive and dynamic parts of the SAS URL in the recording, + // replacing them with their corresponding components from the fake SAS URL defined above. + generalRegexSanitizers: [ + // This one replaces the host portion of the URL, which is dynamic based on the storage account... + { + regex: env.STORAGE_SAS_URL.split("/")[2], + value: fakeSASUrl.split("/")[2], + }, + // ...and this one replaces the query string which contains sensitive information relating to + // the SAS token. + { + regex: env.STORAGE_SAS_URL.split("/")[3].split("?")[1], + value: fakeSASUrl.split("/")[3].split("?")[1], + }, + ], +}; + +describe("Core V1 tests using unified recorder", () => { + let recorder: TestProxyHttpClientCoreV1; + + // Note the use of function() instead of an arrow function. This is important + // since we pass `this.currentTest` to the client. + beforeEach(async function () { + // Create an instance of recorder. We pass the current test as required by the client; + // this value is used to determine the recording's location. + recorder = new TestProxyHttpClientCoreV1(this.currentTest); + + // Configure the recorder and start it up prior to each test... + await recorder.start(recorderOptions); + await recorder.addSanitizers(sanitizers); + }); + + afterEach(async () => { + // ...and stop it when each test wraps up. + await recorder.stop(); + }); + + it("storage-queue create queue", async function () { + // Along with specifying the necessary parameters for the QueueServiceClient, we pass through + // the test proxy HTTP client, which mean that the client will use the recorder when making requests. + const client = new QueueServiceClient(env.STORAGE_SAS_URL, undefined, { httpClient: recorder }); + + // Variables can be generated in record mode, and are stored with the recording to be reused + // in playback mode. + if (!isPlaybackMode()) { + recorder.variables["queue-name"] = `queue-${Math.ceil(Math.random() * 1000 + 1000)}`; + } + + await client.createQueue(recorder.variables["queue-name"]); + }); +}); diff --git a/sdk/template/template/test/public/core-v2-test.spec.ts b/sdk/template/template/test/public/core-v2-test.spec.ts new file mode 100644 index 000000000000..c5c816641874 --- /dev/null +++ b/sdk/template/template/test/public/core-v2-test.spec.ts @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { env, isPlaybackMode } from "@azure-tools/test-recorder"; +import { TableEntity, TableClient } from "@azure/data-tables"; +import { TestProxyHttpClient, recorderHttpPolicy } from "@azure-tools/test-recorder-new"; +import { config } from "dotenv"; +import { createSimpleEntity } from "../utils/utils"; +import { SanitizerOptions } from "@azure-tools/test-recorder-new"; +config(); + +// A fake connection string which replaces the actual connection string in the recording. +const fakeConnString = + "TableEndpoint=https://fakeaccountname.table.core.windows.net/;SharedAccessSignature=st=2021-08-03T08:52:15Z&spr=https&sig=fakesigval"; +const sanitizerOptions: SanitizerOptions = { + // We use a connection string sanitizer to remove the real connection string in the recording. + connectionStringSanitizers: [ + { + actualConnString: env.TABLES_SAS_CONNECTION_STRING, + fakeConnString, + }, + ], + // The removeHeaderSanitizer can be used to remove certain headers before saving a recording. + removeHeaderSanitizer: { headersForRemoval: ["X-Content-Type-Options"] }, +}; + +const recorderOptions = { + envSetupForPlayback: { + TABLES_SAS_CONNECTION_STRING: fakeConnString, + }, + sanitizerOptions, +}; + +describe("Core V2 tests using unified recorder", () => { + let recorder: TestProxyHttpClient; + + // Note the use of function() instead of an arrow function. This is important + // since we pass `this.currentTest` to the client. + beforeEach(async function () { + // Create an instance of recorder. We pass the current test as required by the client; + // this value is used to determine the recording's location. + recorder = new TestProxyHttpClient(this.currentTest); + + // Start the recorder using the options before each test. + await recorder.start(recorderOptions); + }); + + afterEach(async () => { + await recorder.stop(); + }); + + it("data-tables create entity", async function () { + // Variables can be generated in record mode, and are stored with the recording to be reused + // in playback mode. + if (!isPlaybackMode()) { + recorder.variables["table-name"] = `table${Math.ceil(Math.random() * 1000 + 1000)}`; + } + const client = TableClient.fromConnectionString( + env.TABLES_SAS_CONNECTION_STRING, + recorder.variables["table-name"] + ); + + // To set up the recorder with the core v2 pipeline, we add a HTTP policy which + // redirects requests to use the proxy tool recorder. + client.pipeline.addPolicy(recorderHttpPolicy(recorder)); + + await client.createTable(); + const simpleEntity: TableEntity = createSimpleEntity(); + await client.createEntity(simpleEntity); + await client.deleteTable(); + }); +}); diff --git a/sdk/template/template/test/utils/utils.ts b/sdk/template/template/test/utils/utils.ts new file mode 100644 index 000000000000..5b89447513be --- /dev/null +++ b/sdk/template/template/test/utils/utils.ts @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { TableEntity } from "@azure/data-tables"; + +const stringValue = "This is a string"; + +export function createSimpleEntity(): TableEntity { + return { + partitionKey: "simpleEntity", + rowKey: "03590009-4169-46ce-9e33-d011dbaf308c", //uuid(), + stringTypeProperty1: stringValue, + stringTypeProperty2: stringValue, + stringTypeProperty3: stringValue, + stringTypeProperty4: stringValue, + stringTypeProperty5: stringValue, + stringTypeProperty6: stringValue, + stringTypeProperty7: stringValue + }; +} From d52f4cf2763bac67bd3dc2c30cfdfe3c64fbbb77 Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Tue, 30 Nov 2021 11:40:51 -0800 Subject: [PATCH 02/19] Fix lint issues --- .../template/src/configurationClient.ts | 13 ++++++------ .../template/test/public/core-v1-test.spec.ts | 18 +++++++++------- .../template/test/public/core-v2-test.spec.ts | 21 ++++++++++--------- sdk/template/template/test/utils/utils.ts | 2 +- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/sdk/template/template/src/configurationClient.ts b/sdk/template/template/src/configurationClient.ts index 0cae1c9f3c49..4c0b44cc3035 100644 --- a/sdk/template/template/src/configurationClient.ts +++ b/sdk/template/template/src/configurationClient.ts @@ -1,20 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { ConfigurationSetting, GeneratedClient } from "./generated"; import { + InternalPipelineOptions, + OperationOptions, PipelineOptions, TokenCredential, - OperationOptions, bearerTokenAuthenticationPolicy, - createPipelineFromOptions, - InternalPipelineOptions + createPipelineFromOptions } from "@azure/core-http"; -import { SpanStatusCode } from "@azure/core-tracing"; - import { SDK_VERSION } from "./constants"; -import { logger } from "./logger"; -import { ConfigurationSetting, GeneratedClient } from "./generated"; +import { SpanStatusCode } from "@azure/core-tracing"; import { createSpan } from "./tracing"; +import { logger } from "./logger"; import { quoteETag } from "./util"; // re-export generated types that are used as public interfaces. diff --git a/sdk/template/template/test/public/core-v1-test.spec.ts b/sdk/template/template/test/public/core-v1-test.spec.ts index 7fb54cfadc32..1bc28b7915ce 100644 --- a/sdk/template/template/test/public/core-v1-test.spec.ts +++ b/sdk/template/template/test/public/core-v1-test.spec.ts @@ -1,7 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +// import { env, isPlaybackMode } from "@azure-tools/test-recorder"; +import { Context } from "mocha"; import { QueueServiceClient } from "@azure/storage-queue"; import { TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new"; import { config } from "dotenv"; @@ -18,8 +20,8 @@ const recorderOptions = { envSetupForPlayback: { // In playback, we use the fake SAS URL instead of a real one which would have // been provided via the .env file or otherwise. - STORAGE_SAS_URL: fakeSASUrl, - }, + STORAGE_SAS_URL: fakeSASUrl + } }; const sanitizers = { @@ -31,15 +33,15 @@ const sanitizers = { // This one replaces the host portion of the URL, which is dynamic based on the storage account... { regex: env.STORAGE_SAS_URL.split("/")[2], - value: fakeSASUrl.split("/")[2], + value: fakeSASUrl.split("/")[2] }, // ...and this one replaces the query string which contains sensitive information relating to // the SAS token. { regex: env.STORAGE_SAS_URL.split("/")[3].split("?")[1], - value: fakeSASUrl.split("/")[3].split("?")[1], - }, - ], + value: fakeSASUrl.split("/")[3].split("?")[1] + } + ] }; describe("Core V1 tests using unified recorder", () => { @@ -47,7 +49,7 @@ describe("Core V1 tests using unified recorder", () => { // Note the use of function() instead of an arrow function. This is important // since we pass `this.currentTest` to the client. - beforeEach(async function () { + beforeEach(async function(this: Context) { // Create an instance of recorder. We pass the current test as required by the client; // this value is used to determine the recording's location. recorder = new TestProxyHttpClientCoreV1(this.currentTest); @@ -62,7 +64,7 @@ describe("Core V1 tests using unified recorder", () => { await recorder.stop(); }); - it("storage-queue create queue", async function () { + it("storage-queue create queue", async function() { // Along with specifying the necessary parameters for the QueueServiceClient, we pass through // the test proxy HTTP client, which mean that the client will use the recorder when making requests. const client = new QueueServiceClient(env.STORAGE_SAS_URL, undefined, { httpClient: recorder }); diff --git a/sdk/template/template/test/public/core-v2-test.spec.ts b/sdk/template/template/test/public/core-v2-test.spec.ts index c5c816641874..04271b68807a 100644 --- a/sdk/template/template/test/public/core-v2-test.spec.ts +++ b/sdk/template/template/test/public/core-v2-test.spec.ts @@ -1,12 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { env, isPlaybackMode } from "@azure-tools/test-recorder"; -import { TableEntity, TableClient } from "@azure/data-tables"; +import { TableClient, TableEntity } from "@azure/data-tables"; import { TestProxyHttpClient, recorderHttpPolicy } from "@azure-tools/test-recorder-new"; +import { env, isPlaybackMode } from "@azure-tools/test-recorder"; +import { Context } from "mocha"; +import { SanitizerOptions } from "@azure-tools/test-recorder-new"; import { config } from "dotenv"; import { createSimpleEntity } from "../utils/utils"; -import { SanitizerOptions } from "@azure-tools/test-recorder-new"; config(); // A fake connection string which replaces the actual connection string in the recording. @@ -17,18 +18,18 @@ const sanitizerOptions: SanitizerOptions = { connectionStringSanitizers: [ { actualConnString: env.TABLES_SAS_CONNECTION_STRING, - fakeConnString, - }, + fakeConnString + } ], // The removeHeaderSanitizer can be used to remove certain headers before saving a recording. - removeHeaderSanitizer: { headersForRemoval: ["X-Content-Type-Options"] }, + removeHeaderSanitizer: { headersForRemoval: ["X-Content-Type-Options"] } }; const recorderOptions = { envSetupForPlayback: { - TABLES_SAS_CONNECTION_STRING: fakeConnString, + TABLES_SAS_CONNECTION_STRING: fakeConnString }, - sanitizerOptions, + sanitizerOptions }; describe("Core V2 tests using unified recorder", () => { @@ -36,7 +37,7 @@ describe("Core V2 tests using unified recorder", () => { // Note the use of function() instead of an arrow function. This is important // since we pass `this.currentTest` to the client. - beforeEach(async function () { + beforeEach(async function(this: Context) { // Create an instance of recorder. We pass the current test as required by the client; // this value is used to determine the recording's location. recorder = new TestProxyHttpClient(this.currentTest); @@ -49,7 +50,7 @@ describe("Core V2 tests using unified recorder", () => { await recorder.stop(); }); - it("data-tables create entity", async function () { + it("data-tables create entity", async function() { // Variables can be generated in record mode, and are stored with the recording to be reused // in playback mode. if (!isPlaybackMode()) { diff --git a/sdk/template/template/test/utils/utils.ts b/sdk/template/template/test/utils/utils.ts index 5b89447513be..9479b6d0621f 100644 --- a/sdk/template/template/test/utils/utils.ts +++ b/sdk/template/template/test/utils/utils.ts @@ -8,7 +8,7 @@ const stringValue = "This is a string"; export function createSimpleEntity(): TableEntity { return { partitionKey: "simpleEntity", - rowKey: "03590009-4169-46ce-9e33-d011dbaf308c", //uuid(), + rowKey: "03590009-4169-46ce-9e33-d011dbaf308c", // uuid(), stringTypeProperty1: stringValue, stringTypeProperty2: stringValue, stringTypeProperty3: stringValue, From eee8f214d5188eca35458ad79a69d708450db988 Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Mon, 6 Dec 2021 09:48:40 -0800 Subject: [PATCH 03/19] Fix tests to work in browser --- sdk/template/template/karma.conf.js | 6 +- sdk/template/template/package.json | 12 +- ...determined_setting_has_expected_value.json | 54 +++++++ .../recording_storagequeue_create_queue.json | 42 +++++ .../recording_datatables_create_entity.json | 143 ++++++++++++++++++ ...determined_setting_has_expected_value.json | 46 ++++++ .../recording_storagequeue_create_queue.json | 12 +- .../recording_datatables_create_entity.json | 42 ++--- .../test/public/configurationClient.spec.ts | 92 +++++++++++ .../template/test/public/core-v1-test.spec.ts | 2 - .../template/test/public/core-v2-test.spec.ts | 2 - 11 files changed, 415 insertions(+), 38 deletions(-) create mode 100644 sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json create mode 100644 sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json create mode 100644 sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json create mode 100644 sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json create mode 100644 sdk/template/template/test/public/configurationClient.spec.ts diff --git a/sdk/template/template/karma.conf.js b/sdk/template/template/karma.conf.js index 68297cc53778..a7389edf7002 100644 --- a/sdk/template/template/karma.conf.js +++ b/sdk/template/template/karma.conf.js @@ -3,6 +3,7 @@ // https://github.com/karma-runner/karma-chrome-launcher process.env.CHROME_BIN = require("puppeteer").executablePath(); +process.env.RECORDINGS_RELATIVE_PATH = require("@azure-tools/test-recorder-new").relativeRecordingsPath(); require("dotenv").config(); const { jsonRecordingFilterFunction, @@ -60,7 +61,10 @@ module.exports = function(config) { "APPCONFIG_TEST_SETTING_EXPECTED_VALUE", "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET", - "AZURE_TENANT_ID" + "AZURE_TENANT_ID", + "TABLES_SAS_CONNECTION_STRING", + "RECORDINGS_RELATIVE_PATH", + "STORAGE_SAS_URL" ], // test results reporter to use diff --git a/sdk/template/template/package.json b/sdk/template/template/package.json index 2cdb3d2e6846..1a0d08589a19 100644 --- a/sdk/template/template/package.json +++ b/sdk/template/template/package.json @@ -39,17 +39,17 @@ "extract-api": "tsc -p . && api-extractor run --local", "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", "generate:client": "autorest --typescript ./swagger/README.md", - "integration-test:browser": "karma start --single-run", - "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace \"dist-esm/test/{,!(browser)/**/}/*.spec.js\"", + "integration-test:browser": "dev-tool run test:browser", + "integration-test:node":"dev-tool run test:node-ts-input --mocha=\"--timeout 1200000 'test/**/*.spec.ts'\"", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", "lint": "eslint package.json api-extractor.json src test --ext .ts", "pack": "npm pack 2>&1", - "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", - "test:node": "npm run clean && tsc -p . && npm run unit-test:node && npm run integration-test:node", + "test:browser": "npm run clean && npm run build:test && npm run integration-test:browser", + "test:node": "npm run clean && tsc -p . && npm run integration-test:node", "test": "npm run clean && tsc -p . && npm run unit-test:node && rollup -c 2>&1 && npm run unit-test:browser && npm run integration-test", - "unit-test:browser": "dev-tool run test:browser", - "unit-test:node": "dev-tool run test:node-ts-input --mocha=\"--timeout 1200000 'test/**/*.spec.ts'\"", + "unit-test:browser": "npm run integration-test:browser", + "unit-test:node": "npm run integration-test:node", "unit-test": "npm run unit-test:node && npm run unit-test:browser" }, "files": [ diff --git a/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json b/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json new file mode 100644 index 000000000000..5b735837dd88 --- /dev/null +++ b/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json @@ -0,0 +1,54 @@ +{ + "Entries": [ + { + "RequestUri": "https://myappconfig.azconfig.io/kv/test-key?api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kv\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Authorization": "Sanitized", + "Connection": "keep-alive", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", + "x-ms-client-request-id": "19b1aa0e-c3d3-485c-8e79-aaf0d40af467", + "x-ms-useragent": "azsdk-js-template-template/1.0.11-beta.1 core-http/2.2.3 OS/Linuxx86_64" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8", + "Date": "Wed, 08 Dec 2021 23:33:51 GMT", + "ETag": "\u0022gjZGC5V4il31mi6AuO1zeP24P55\u0022", + "Last-Modified": "Mon, 22 Nov 2021 20:21:05 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NToxOSM4NDY5NjA4;sn=8469608", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "738bf7d2-a8a1-404c-9be4-d136568905e3", + "x-ms-request-id": "738bf7d2-a8a1-404c-9be4-d136568905e3" + }, + "ResponseBody": { + "etag": "gjZGC5V4il31mi6AuO1zeP24P55", + "key": "test-key", + "label": null, + "content_type": "", + "value": "test-value", + "tags": {}, + "locked": false, + "last_modified": "2021-11-22T20:21:05\u002B00:00" + } + } + ], + "Variables": {} +} diff --git a/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json b/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json new file mode 100644 index 000000000000..bea28f76ad2a --- /dev/null +++ b/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json @@ -0,0 +1,42 @@ +{ + "Entries": [ + { + "RequestUri": "https://account_name.queue.core.windows.net/queue-1642?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Connection": "keep-alive", + "Content-Length": "0", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", + "x-ms-client-request-id": "16b07f33-052f-4b08-aa9f-b12036d00440", + "x-ms-version": "2020-12-06" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 08 Dec 2021 23:33:52 GMT", + "Server": [ + "Windows-Azure-Queue/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-client-request-id": "16b07f33-052f-4b08-aa9f-b12036d00440", + "x-ms-request-id": "4a44112e-1003-0000-278c-ec2cc0000000", + "x-ms-version": "2020-12-06" + }, + "ResponseBody": null + } + ], + "Variables": { + "queue-name": "queue-1642" + } +} diff --git a/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json b/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json new file mode 100644 index 000000000000..5add85b2eeef --- /dev/null +++ b/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json @@ -0,0 +1,143 @@ +{ + "Entries": [ + { + "RequestUri": "https://timovperftestplayground.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Connection": "keep-alive", + "Content-Length": "25", + "Content-Type": "application/json;odata=nometadata", + "DataServiceVersion": "3.0", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", + "x-ms-client-request-id": "61accadc-531d-41b3-a6d7-065c31f1e532", + "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "TableName": "table1677" + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Wed, 08 Dec 2021 23:33:52 GMT", + "Location": "https://timovperftestplayground.table.core.windows.net/Tables(\u0027table1677\u0027)", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "x-ms-client-request-id": "61accadc-531d-41b3-a6d7-065c31f1e532", + "x-ms-request-id": "78f16486-f002-0045-228c-ecf923000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.metadata": "https://timovperftestplayground.table.core.windows.net/$metadata#Tables/@Element", + "TableName": "table1677" + } + }, + { + "RequestUri": "https://timovperftestplayground.table.core.windows.net/table1677?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Connection": "keep-alive", + "Content-Length": "366", + "Content-Type": "application/json;odata=nometadata", + "DataServiceVersion": "3.0", + "Prefer": "return-no-content", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", + "x-ms-client-request-id": "0639a734-766d-4501-8539-2265ac062c61", + "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "simpleEntity", + "RowKey": "03590009-4169-46ce-9e33-d011dbaf308c", + "stringTypeProperty1": "This is a string", + "stringTypeProperty2": "This is a string", + "stringTypeProperty3": "This is a string", + "stringTypeProperty4": "This is a string", + "stringTypeProperty5": "This is a string", + "stringTypeProperty6": "This is a string", + "stringTypeProperty7": "This is a string" + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://timovperftestplayground.table.core.windows.net/table1677(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Date": "Wed, 08 Dec 2021 23:33:52 GMT", + "ETag": "W/\u0022datetime\u00272021-12-08T23%3A33%3A52.9431909Z\u0027\u0022", + "Location": "https://timovperftestplayground.table.core.windows.net/table1677(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-client-request-id": "0639a734-766d-4501-8539-2265ac062c61", + "x-ms-request-id": "78f16489-f002-0045-238c-ecf923000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://timovperftestplayground.table.core.windows.net/Tables(\u0027table1677\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Connection": "keep-alive", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", + "x-ms-client-request-id": "e66e88f4-7b20-4893-a15c-a5f4812045ce", + "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Wed, 08 Dec 2021 23:33:52 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-client-request-id": "e66e88f4-7b20-4893-a15c-a5f4812045ce", + "x-ms-request-id": "78f1648c-f002-0045-268c-ecf923000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + } + ], + "Variables": { + "table-name": "table1677" + } +} diff --git a/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json b/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json new file mode 100644 index 000000000000..5d4401b95b3a --- /dev/null +++ b/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json @@ -0,0 +1,46 @@ +{ + "Entries": [ + { + "RequestUri": "https://myappconfig.azconfig.io/kv/test-key?api-version=1.0", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/vnd.microsoft.appconfig.kv\u002Bjson, application/json, application/problem\u002Bjson", + "Accept-Encoding": "gzip,deflate", + "Authorization": "Sanitized", + "Connection": "keep-alive", + "Cookie": "", + "User-Agent": "azsdk-js-template-template/1.0.11-beta.1 core-http/2.2.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", + "x-ms-client-request-id": "ea5d9008-3c76-4603-8e3e-4384babe4f7e" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", + "Connection": "keep-alive", + "Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8", + "Date": "Wed, 08 Dec 2021 23:33:45 GMT", + "ETag": "\u0022gjZGC5V4il31mi6AuO1zeP24P55\u0022", + "Last-Modified": "Mon, 22 Nov 2021 20:21:05 GMT", + "Server": "openresty/1.17.8.2", + "Strict-Transport-Security": "max-age=15724800; includeSubDomains", + "Sync-Token": "zAJw6V16=NToxOSM4NDY5NjA4;sn=8469608", + "Transfer-Encoding": "chunked", + "x-ms-correlation-request-id": "e0aeadef-c05e-419a-92c5-673501fb4ac6", + "x-ms-request-id": "e0aeadef-c05e-419a-92c5-673501fb4ac6" + }, + "ResponseBody": { + "etag": "gjZGC5V4il31mi6AuO1zeP24P55", + "key": "test-key", + "label": null, + "content_type": "", + "value": "test-key setting", + "tags": {}, + "locked": false, + "last_modified": "2021-11-22T20:21:05\u002B00:00" + } + } + ], + "Variables": {} +} diff --git a/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json b/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json index 846dd4bf5935..00874eaebc90 100644 --- a/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json +++ b/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://account_name.queue.core.windows.net/queue-1937?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", + "RequestUri": "https://account_name.queue.core.windows.net/queue-1776?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", "RequestMethod": "PUT", "RequestHeaders": { "Accept": "application/xml", @@ -10,26 +10,26 @@ "Content-Length": "0", "Cookie": "", "User-Agent": "azsdk-js-storagequeue/12.8.0-beta.2 (NODE-VERSION v16.13.0; Linux 5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "7b474567-b1ee-4711-8e2e-5e9508c4fb6c", + "x-ms-client-request-id": "5560c48b-036c-4f71-9856-e015d34fb118", "x-ms-version": "2020-12-06" }, "RequestBody": null, "StatusCode": 201, "ResponseHeaders": { "Content-Length": "0", - "Date": "Wed, 24 Nov 2021 22:58:57 GMT", + "Date": "Wed, 08 Dec 2021 23:33:45 GMT", "Server": [ "Windows-Azure-Queue/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "7b474567-b1ee-4711-8e2e-5e9508c4fb6c", - "x-ms-request-id": "98e8915e-3003-004a-3a86-e18f4f000000", + "x-ms-client-request-id": "5560c48b-036c-4f71-9856-e015d34fb118", + "x-ms-request-id": "fd76e8be-7003-0006-708c-ec1f7f000000", "x-ms-version": "2020-12-06" }, "ResponseBody": null } ], "Variables": { - "queue-name": "queue-1937" + "queue-name": "queue-1776" } } diff --git a/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json b/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json index 77de70ef1263..a530ea559fa1 100644 --- a/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json +++ b/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json @@ -11,34 +11,34 @@ "Content-Type": "application/json;odata=nometadata", "DataServiceVersion": "3.0", "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "9de742f8-6db0-4d81-9abc-9796373e9bc6", + "x-ms-client-request-id": "0d757246-bbac-4b44-aee9-0b43961d7fd9", "x-ms-version": "2019-02-02" }, "RequestBody": { - "TableName": "table1743" + "TableName": "table1380" }, "StatusCode": 201, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Wed, 24 Nov 2021 22:58:59 GMT", - "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1743\u0027)", + "Date": "Wed, 08 Dec 2021 23:33:45 GMT", + "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1380\u0027)", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], "Transfer-Encoding": "chunked", - "x-ms-client-request-id": "9de742f8-6db0-4d81-9abc-9796373e9bc6", - "x-ms-request-id": "1d501063-9002-001e-2a86-e1c018000000", + "x-ms-client-request-id": "0d757246-bbac-4b44-aee9-0b43961d7fd9", + "x-ms-request-id": "49e80c25-7002-0006-078c-ec1f7f000000", "x-ms-version": "2019-02-02" }, "ResponseBody": { "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#Tables/@Element", - "TableName": "table1743" + "TableName": "table1380" } }, { - "RequestUri": "https://fakeaccountname.table.core.windows.net/table1743?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/table1380?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -49,7 +49,7 @@ "DataServiceVersion": "3.0", "Prefer": "return-no-content", "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "5bbcf084-f61b-4e96-acc9-60a06e0943fb", + "x-ms-client-request-id": "224d5228-4bc2-478c-bedd-4c16eb8e99b6", "x-ms-version": "2019-02-02" }, "RequestBody": { @@ -67,30 +67,30 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1743(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Date": "Wed, 24 Nov 2021 22:58:59 GMT", - "ETag": "W/\u0022datetime\u00272021-11-24T22%3A58%3A59.6477177Z\u0027\u0022", - "Location": "https://fakeaccountname.table.core.windows.net/table1743(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1380(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Date": "Wed, 08 Dec 2021 23:33:46 GMT", + "ETag": "W/\u0022datetime\u00272021-12-08T23%3A33%3A46.0599927Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/table1380(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", "Preference-Applied": "return-no-content", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "5bbcf084-f61b-4e96-acc9-60a06e0943fb", - "x-ms-request-id": "1d501068-9002-001e-2d86-e1c018000000", + "x-ms-client-request-id": "224d5228-4bc2-478c-bedd-4c16eb8e99b6", + "x-ms-request-id": "49e80c2d-7002-0006-0d8c-ec1f7f000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null }, { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1743\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1380\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "DELETE", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip,deflate", "Connection": "keep-alive", "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "892e3bb7-2f91-4281-bf57-865ca74a3f30", + "x-ms-client-request-id": "85dc6a5f-cc2e-4891-bff2-7ce851ba7df5", "x-ms-version": "2019-02-02" }, "RequestBody": null, @@ -98,19 +98,19 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 24 Nov 2021 22:58:59 GMT", + "Date": "Wed, 08 Dec 2021 23:33:46 GMT", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "892e3bb7-2f91-4281-bf57-865ca74a3f30", - "x-ms-request-id": "1d50106a-9002-001e-2f86-e1c018000000", + "x-ms-client-request-id": "85dc6a5f-cc2e-4891-bff2-7ce851ba7df5", + "x-ms-request-id": "49e80c31-7002-0006-118c-ec1f7f000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null } ], "Variables": { - "table-name": "table1743" + "table-name": "table1380" } } diff --git a/sdk/template/template/test/public/configurationClient.spec.ts b/sdk/template/template/test/public/configurationClient.spec.ts new file mode 100644 index 000000000000..9cd7b8aa3edb --- /dev/null +++ b/sdk/template/template/test/public/configurationClient.spec.ts @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { assert } from "chai"; +import { Context } from "mocha"; + +import { ConfigurationClient } from "../../src"; + +import { env, isPlaybackMode } from "@azure-tools/test-recorder"; +import { NoOpCredential, TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new"; +import { TokenCredential } from "@azure/core-http"; +import { ClientSecretCredential } from "@azure/identity"; + +// When the recorder observes the values of these environment variables in any +// recorded HTTP request or response, it will replace them with the values they +// are mapped to below. +const replaceableVariables: Record = { + APPCONFIG_ENDPOINT: "https://myappconfig.azconfig.io", + APPCONFIG_TEST_SETTING_KEY: "test-key", + APPCONFIG_TEST_SETTING_EXPECTED_VALUE: "test-value", + AZURE_TENANT_ID: "12345678-1234-1234-1234-123456789012", + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret" +}; + +function createConfigurationClient(recorder: TestProxyHttpClientCoreV1): ConfigurationClient { + // Retrieve the endpoint from the environment variable + // we saved to the .env file earlier + const endpoint = env.APPCONFIG_ENDPOINT; + + // We use ClientSecretCredential instead of DefaultAzureCredential in order + // to ensure that the requests made to the AAD server are always the same. If + // we used DefaultAzureCredential, they might be different on some machines + // than on others, depending on which credentials are available (such as + // Managed Identity or developer credentials). + let credential: TokenCredential; + if (isPlaybackMode()) { + credential = new NoOpCredential(); + } else { + credential = new ClientSecretCredential( + env.AZURE_TENANT_ID, + env.AZURE_CLIENT_ID, + env.AZURE_CLIENT_SECRET + ); + } + return new ConfigurationClient(endpoint, credential, { httpClient: recorder }); +} + +// You want to give the test suite a descriptive name. Here, I add [AAD] to +// indicate that the tests are authenticating with the service using Azure +// Active Directory. +describe("[AAD] ConfigurationClient functional tests", function() { + // Declare the client and recorder instances. We will set them using the + // beforeEach hook. + let client: ConfigurationClient; + let recorder: TestProxyHttpClientCoreV1; + + // NOTE: use of "function" and not ES6 arrow-style functions with the + // beforeEach hook is IMPORTANT due to the use of `this` in the function + // body. + beforeEach(async function(this: Context) { + // The recorder has some convenience methods, and we need to store a + // reference to it so that we can `stop()` the recorder later in the + // `afterEach` hook. + recorder = new TestProxyHttpClientCoreV1(this.currentTest); + + // We'll be able to refer to the instantiated `client` in tests, since we + // initialize it before each test + client = createConfigurationClient(recorder); + + await recorder.start({ envSetupForPlayback: replaceableVariables }); + }); + + // After each test, we need to stop the recording. + afterEach(async function() { + await recorder.stop(); + }); + + it("predetermined setting has expected value", async () => { + const key = env.APPCONFIG_TEST_SETTING_KEY; + const expectedValue = env.APPCONFIG_TEST_SETTING_EXPECTED_VALUE; + + const setting = await client.getConfigurationSetting(key); + + // Make sure the key returned is the same as the key we asked for + assert.equal(key, setting.key); + + // Make sure the value of the setting is the same as the value we entered + // on the environment + assert.equal(expectedValue, setting.value); + }); +}); diff --git a/sdk/template/template/test/public/core-v1-test.spec.ts b/sdk/template/template/test/public/core-v1-test.spec.ts index 1bc28b7915ce..af7d4aa82409 100644 --- a/sdk/template/template/test/public/core-v1-test.spec.ts +++ b/sdk/template/template/test/public/core-v1-test.spec.ts @@ -6,8 +6,6 @@ import { env, isPlaybackMode } from "@azure-tools/test-recorder"; import { Context } from "mocha"; import { QueueServiceClient } from "@azure/storage-queue"; import { TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new"; -import { config } from "dotenv"; -config(); // This fake URL will be used in the recording. We use a general regex sanitizer // (below) to replace the real SAS URL from when we record the test with this diff --git a/sdk/template/template/test/public/core-v2-test.spec.ts b/sdk/template/template/test/public/core-v2-test.spec.ts index 04271b68807a..7f1bf2b015d0 100644 --- a/sdk/template/template/test/public/core-v2-test.spec.ts +++ b/sdk/template/template/test/public/core-v2-test.spec.ts @@ -6,9 +6,7 @@ import { TestProxyHttpClient, recorderHttpPolicy } from "@azure-tools/test-recor import { env, isPlaybackMode } from "@azure-tools/test-recorder"; import { Context } from "mocha"; import { SanitizerOptions } from "@azure-tools/test-recorder-new"; -import { config } from "dotenv"; import { createSimpleEntity } from "../utils/utils"; -config(); // A fake connection string which replaces the actual connection string in the recording. const fakeConnString = From a806c32e2c9703de60a45fbc3ede24be28657bcd Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Wed, 8 Dec 2021 16:22:53 -0800 Subject: [PATCH 04/19] Provide environment variable export --- sdk/test-utils/recorder-new/package.json | 1 + sdk/test-utils/recorder-new/src/index.ts | 1 + sdk/test-utils/recorder-new/src/utils/env.browser.ts | 4 ++++ sdk/test-utils/recorder-new/src/utils/env.ts | 8 ++++++++ 4 files changed, 14 insertions(+) create mode 100644 sdk/test-utils/recorder-new/src/utils/env.browser.ts create mode 100644 sdk/test-utils/recorder-new/src/utils/env.ts diff --git a/sdk/test-utils/recorder-new/package.json b/sdk/test-utils/recorder-new/package.json index dc9545a18785..ab355cbd09e3 100644 --- a/sdk/test-utils/recorder-new/package.json +++ b/sdk/test-utils/recorder-new/package.json @@ -8,6 +8,7 @@ "types": "./types/src/index.d.ts", "browser": { "./dist-esm/src/utils/relativePathCalculator.js": "./dist-esm/src/utils/relativePathCalculator.browser.js", + "./dist-esm/src/utils/env.js": "./dist-esm/src/utils/env.browser.js", "./dist-esm/test/utils/server.js": "./dist-esm/test/utils/server.browser.js" }, "scripts": { diff --git a/sdk/test-utils/recorder-new/src/index.ts b/sdk/test-utils/recorder-new/src/index.ts index 9edaf4d68f7e..ad346f007e16 100644 --- a/sdk/test-utils/recorder-new/src/index.ts +++ b/sdk/test-utils/recorder-new/src/index.ts @@ -6,3 +6,4 @@ export { TestProxyHttpClientCoreV1 } from "./core-v1-recorder"; export { relativeRecordingsPath } from "./utils/relativePathCalculator"; export { SanitizerOptions, RecorderStartOptions } from "./utils/utils"; export { NoOpCredential } from "./recorderAADCredential"; +export { env } from "./utils/env"; diff --git a/sdk/test-utils/recorder-new/src/utils/env.browser.ts b/sdk/test-utils/recorder-new/src/utils/env.browser.ts new file mode 100644 index 000000000000..c738aa78abda --- /dev/null +++ b/sdk/test-utils/recorder-new/src/utils/env.browser.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +export const env = (window as any).__env__; diff --git a/sdk/test-utils/recorder-new/src/utils/env.ts b/sdk/test-utils/recorder-new/src/utils/env.ts new file mode 100644 index 000000000000..c8288e232b55 --- /dev/null +++ b/sdk/test-utils/recorder-new/src/utils/env.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as dotenv from "dotenv"; + +dotenv.config(); + +export const env = process.env as any; From bf68caaaa20d9a183a4be7ba6182e82aca197aa4 Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Wed, 8 Dec 2021 17:26:28 -0800 Subject: [PATCH 05/19] Make the new recorder use its own env export --- .../recorder-new/src/utils/envSetupForPlayback.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sdk/test-utils/recorder-new/src/utils/envSetupForPlayback.ts b/sdk/test-utils/recorder-new/src/utils/envSetupForPlayback.ts index af1d99465b7b..bd9a44deff19 100644 --- a/sdk/test-utils/recorder-new/src/utils/envSetupForPlayback.ts +++ b/sdk/test-utils/recorder-new/src/utils/envSetupForPlayback.ts @@ -1,12 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { - env, - isPlaybackMode, - isRecordMode, - setEnvironmentVariables -} from "@azure-tools/test-recorder"; +import { isPlaybackMode, isRecordMode, setEnvironmentVariables } from "@azure-tools/test-recorder"; +import { env } from "./env"; import { Sanitizer } from "../sanitizer"; /** From e1b9139e05a52746d662c8e49c73137fd78c356a Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Wed, 8 Dec 2021 17:26:36 -0800 Subject: [PATCH 06/19] Fix up the tests a little bit --- ...determined_setting_has_expected_value.json | 18 ++++---- .../recording_storagequeue_create_queue.json | 12 ++--- .../recording_datatables_create_entity.json | 46 +++++++++---------- ...determined_setting_has_expected_value.json | 20 ++++---- .../recording_storagequeue_create_queue.json | 12 ++--- .../recording_datatables_create_entity.json | 42 ++++++++--------- .../test/public/configurationClient.spec.ts | 8 ++-- .../template/test/public/core-v1-test.spec.ts | 4 +- .../template/test/public/core-v2-test.spec.ts | 4 +- 9 files changed, 83 insertions(+), 83 deletions(-) diff --git a/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json b/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json index 5b735837dd88..ccc9561bb452 100644 --- a/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json +++ b/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json @@ -17,7 +17,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "19b1aa0e-c3d3-485c-8e79-aaf0d40af467", + "x-ms-client-request-id": "f574af18-7e18-4257-aa9d-4c81bef33fdc", "x-ms-useragent": "azsdk-js-template-template/1.0.11-beta.1 core-http/2.2.3 OS/Linuxx86_64" }, "RequestBody": null, @@ -28,25 +28,25 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8", - "Date": "Wed, 08 Dec 2021 23:33:51 GMT", - "ETag": "\u0022gjZGC5V4il31mi6AuO1zeP24P55\u0022", - "Last-Modified": "Mon, 22 Nov 2021 20:21:05 GMT", + "Date": "Thu, 09 Dec 2021 01:06:33 GMT", + "ETag": "\u0022jRXE6grlhA98vbDBE98P9JDaMPm\u0022", + "Last-Modified": "Thu, 09 Dec 2021 01:05:58 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NToxOSM4NDY5NjA4;sn=8469608", + "Sync-Token": "zAJw6V16=NToxOSM4NDcxODQ4;sn=8471848", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "738bf7d2-a8a1-404c-9be4-d136568905e3", - "x-ms-request-id": "738bf7d2-a8a1-404c-9be4-d136568905e3" + "x-ms-correlation-request-id": "aa7c5881-eb30-4689-8b7b-34b4adb1b51e", + "x-ms-request-id": "aa7c5881-eb30-4689-8b7b-34b4adb1b51e" }, "ResponseBody": { - "etag": "gjZGC5V4il31mi6AuO1zeP24P55", + "etag": "jRXE6grlhA98vbDBE98P9JDaMPm", "key": "test-key", "label": null, "content_type": "", "value": "test-value", "tags": {}, "locked": false, - "last_modified": "2021-11-22T20:21:05\u002B00:00" + "last_modified": "2021-12-09T01:05:58\u002B00:00" } } ], diff --git a/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json b/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json index bea28f76ad2a..15ab1404b6b0 100644 --- a/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json +++ b/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://account_name.queue.core.windows.net/queue-1642?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", + "RequestUri": "https://account_name.queue.core.windows.net/queue-1660?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacupitfx\u0026se=2022-11-24T06:36:20Z\u0026st=2021-11-23T22:36:20Z\u0026spr=https\u0026sig=LVfIG7n%2Bx8bXQIPfh3OHd6kxTLxbRz70xo9ejm05oE0%3D\u0026timeout=30", "RequestMethod": "PUT", "RequestHeaders": { "Accept": "application/xml", @@ -17,26 +17,26 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "16b07f33-052f-4b08-aa9f-b12036d00440", + "x-ms-client-request-id": "ea90776a-0217-4e92-8159-2468cad1c6fe", "x-ms-version": "2020-12-06" }, "RequestBody": null, "StatusCode": 201, "ResponseHeaders": { "Content-Length": "0", - "Date": "Wed, 08 Dec 2021 23:33:52 GMT", + "Date": "Thu, 09 Dec 2021 01:06:33 GMT", "Server": [ "Windows-Azure-Queue/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "16b07f33-052f-4b08-aa9f-b12036d00440", - "x-ms-request-id": "4a44112e-1003-0000-278c-ec2cc0000000", + "x-ms-client-request-id": "ea90776a-0217-4e92-8159-2468cad1c6fe", + "x-ms-request-id": "d8e7fabb-a003-0058-6399-ecf49f000000", "x-ms-version": "2020-12-06" }, "ResponseBody": null } ], "Variables": { - "queue-name": "queue-1642" + "queue-name": "queue-1660" } } diff --git a/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json b/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json index 5add85b2eeef..9d44bf686cf9 100644 --- a/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json +++ b/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://timovperftestplayground.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacupitfx\u0026se=2022-11-24T06:36:20Z\u0026st=2021-11-23T22:36:20Z\u0026spr=https\u0026sig=LVfIG7n%2Bx8bXQIPfh3OHd6kxTLxbRz70xo9ejm05oE0%3D", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -19,35 +19,35 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "61accadc-531d-41b3-a6d7-065c31f1e532", + "x-ms-client-request-id": "eed6bd7d-c75b-4504-8be4-3743fb45adbb", "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, "RequestBody": { - "TableName": "table1677" + "TableName": "table1334" }, "StatusCode": 201, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Wed, 08 Dec 2021 23:33:52 GMT", - "Location": "https://timovperftestplayground.table.core.windows.net/Tables(\u0027table1677\u0027)", + "Date": "Thu, 09 Dec 2021 01:06:34 GMT", + "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1334\u0027)", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], "Transfer-Encoding": "chunked", - "x-ms-client-request-id": "61accadc-531d-41b3-a6d7-065c31f1e532", - "x-ms-request-id": "78f16486-f002-0045-228c-ecf923000000", + "x-ms-client-request-id": "eed6bd7d-c75b-4504-8be4-3743fb45adbb", + "x-ms-request-id": "a010c469-9002-0031-7a99-eccdd3000000", "x-ms-version": "2019-02-02" }, "ResponseBody": { - "odata.metadata": "https://timovperftestplayground.table.core.windows.net/$metadata#Tables/@Element", - "TableName": "table1677" + "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#Tables/@Element", + "TableName": "table1334" } }, { - "RequestUri": "https://timovperftestplayground.table.core.windows.net/table1677?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/table1334?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacupitfx\u0026se=2022-11-24T06:36:20Z\u0026st=2021-11-23T22:36:20Z\u0026spr=https\u0026sig=LVfIG7n%2Bx8bXQIPfh3OHd6kxTLxbRz70xo9ejm05oE0%3D", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -66,7 +66,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "0639a734-766d-4501-8539-2265ac062c61", + "x-ms-client-request-id": "fd20e0a1-6897-4a09-acae-ff2bb5e2a9f7", "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, @@ -85,23 +85,23 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "DataServiceId": "https://timovperftestplayground.table.core.windows.net/table1677(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Date": "Wed, 08 Dec 2021 23:33:52 GMT", - "ETag": "W/\u0022datetime\u00272021-12-08T23%3A33%3A52.9431909Z\u0027\u0022", - "Location": "https://timovperftestplayground.table.core.windows.net/table1677(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1334(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Date": "Thu, 09 Dec 2021 01:06:34 GMT", + "ETag": "W/\u0022datetime\u00272021-12-09T01%3A06%3A34.4169059Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/table1334(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", "Preference-Applied": "return-no-content", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "0639a734-766d-4501-8539-2265ac062c61", - "x-ms-request-id": "78f16489-f002-0045-238c-ecf923000000", + "x-ms-client-request-id": "fd20e0a1-6897-4a09-acae-ff2bb5e2a9f7", + "x-ms-request-id": "a010c472-9002-0031-0199-eccdd3000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null }, { - "RequestUri": "https://timovperftestplayground.table.core.windows.net/Tables(\u0027table1677\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1334\u0027)?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacupitfx\u0026se=2022-11-24T06:36:20Z\u0026st=2021-11-23T22:36:20Z\u0026spr=https\u0026sig=LVfIG7n%2Bx8bXQIPfh3OHd6kxTLxbRz70xo9ejm05oE0%3D", "RequestMethod": "DELETE", "RequestHeaders": { "Accept": "application/json", @@ -116,7 +116,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "e66e88f4-7b20-4893-a15c-a5f4812045ce", + "x-ms-client-request-id": "a2d5b720-9e46-46e7-81e3-5c2307451777", "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, @@ -125,19 +125,19 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 08 Dec 2021 23:33:52 GMT", + "Date": "Thu, 09 Dec 2021 01:06:34 GMT", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "e66e88f4-7b20-4893-a15c-a5f4812045ce", - "x-ms-request-id": "78f1648c-f002-0045-268c-ecf923000000", + "x-ms-client-request-id": "a2d5b720-9e46-46e7-81e3-5c2307451777", + "x-ms-request-id": "a010c475-9002-0031-0499-eccdd3000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null } ], "Variables": { - "table-name": "table1677" + "table-name": "table1334" } } diff --git a/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json b/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json index 5d4401b95b3a..deeaf1112752 100644 --- a/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json +++ b/sdk/template/template/recordings/node/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json @@ -10,7 +10,7 @@ "Connection": "keep-alive", "Cookie": "", "User-Agent": "azsdk-js-template-template/1.0.11-beta.1 core-http/2.2.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "ea5d9008-3c76-4603-8e3e-4384babe4f7e" + "x-ms-client-request-id": "f6f68ce8-5b02-461d-bdf1-2af09b79624a" }, "RequestBody": null, "StatusCode": 200, @@ -20,25 +20,25 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8", - "Date": "Wed, 08 Dec 2021 23:33:45 GMT", - "ETag": "\u0022gjZGC5V4il31mi6AuO1zeP24P55\u0022", - "Last-Modified": "Mon, 22 Nov 2021 20:21:05 GMT", + "Date": "Thu, 09 Dec 2021 01:06:27 GMT", + "ETag": "\u0022jRXE6grlhA98vbDBE98P9JDaMPm\u0022", + "Last-Modified": "Thu, 09 Dec 2021 01:05:58 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NToxOSM4NDY5NjA4;sn=8469608", + "Sync-Token": "zAJw6V16=NToxOSM4NDcxODQ4;sn=8471848", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "e0aeadef-c05e-419a-92c5-673501fb4ac6", - "x-ms-request-id": "e0aeadef-c05e-419a-92c5-673501fb4ac6" + "x-ms-correlation-request-id": "5625011c-719c-4adc-ab86-a0b59fda97dd", + "x-ms-request-id": "5625011c-719c-4adc-ab86-a0b59fda97dd" }, "ResponseBody": { - "etag": "gjZGC5V4il31mi6AuO1zeP24P55", + "etag": "jRXE6grlhA98vbDBE98P9JDaMPm", "key": "test-key", "label": null, "content_type": "", - "value": "test-key setting", + "value": "test-value", "tags": {}, "locked": false, - "last_modified": "2021-11-22T20:21:05\u002B00:00" + "last_modified": "2021-12-09T01:05:58\u002B00:00" } } ], diff --git a/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json b/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json index 00874eaebc90..7d284ab95e78 100644 --- a/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json +++ b/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://account_name.queue.core.windows.net/queue-1776?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", + "RequestUri": "https://account_name.queue.core.windows.net/queue-1688?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", "RequestMethod": "PUT", "RequestHeaders": { "Accept": "application/xml", @@ -10,26 +10,26 @@ "Content-Length": "0", "Cookie": "", "User-Agent": "azsdk-js-storagequeue/12.8.0-beta.2 (NODE-VERSION v16.13.0; Linux 5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "5560c48b-036c-4f71-9856-e015d34fb118", + "x-ms-client-request-id": "a5109e66-067d-42d9-a07e-896282f4b170", "x-ms-version": "2020-12-06" }, "RequestBody": null, "StatusCode": 201, "ResponseHeaders": { "Content-Length": "0", - "Date": "Wed, 08 Dec 2021 23:33:45 GMT", + "Date": "Thu, 09 Dec 2021 01:06:27 GMT", "Server": [ "Windows-Azure-Queue/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "5560c48b-036c-4f71-9856-e015d34fb118", - "x-ms-request-id": "fd76e8be-7003-0006-708c-ec1f7f000000", + "x-ms-client-request-id": "a5109e66-067d-42d9-a07e-896282f4b170", + "x-ms-request-id": "041ed824-d003-006d-6398-ec988b000000", "x-ms-version": "2020-12-06" }, "ResponseBody": null } ], "Variables": { - "queue-name": "queue-1776" + "queue-name": "queue-1688" } } diff --git a/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json b/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json index a530ea559fa1..241374b703f5 100644 --- a/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json +++ b/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json @@ -11,34 +11,34 @@ "Content-Type": "application/json;odata=nometadata", "DataServiceVersion": "3.0", "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "0d757246-bbac-4b44-aee9-0b43961d7fd9", + "x-ms-client-request-id": "988d7b28-fa5f-48a1-8556-c20f1c71ba1f", "x-ms-version": "2019-02-02" }, "RequestBody": { - "TableName": "table1380" + "TableName": "table1213" }, "StatusCode": 201, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Wed, 08 Dec 2021 23:33:45 GMT", - "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1380\u0027)", + "Date": "Thu, 09 Dec 2021 01:06:28 GMT", + "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1213\u0027)", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], "Transfer-Encoding": "chunked", - "x-ms-client-request-id": "0d757246-bbac-4b44-aee9-0b43961d7fd9", - "x-ms-request-id": "49e80c25-7002-0006-078c-ec1f7f000000", + "x-ms-client-request-id": "988d7b28-fa5f-48a1-8556-c20f1c71ba1f", + "x-ms-request-id": "78b87427-8002-004f-7f98-ec5d94000000", "x-ms-version": "2019-02-02" }, "ResponseBody": { "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#Tables/@Element", - "TableName": "table1380" + "TableName": "table1213" } }, { - "RequestUri": "https://fakeaccountname.table.core.windows.net/table1380?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/table1213?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -49,7 +49,7 @@ "DataServiceVersion": "3.0", "Prefer": "return-no-content", "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "224d5228-4bc2-478c-bedd-4c16eb8e99b6", + "x-ms-client-request-id": "1e6dc024-14cd-4371-bf49-bb2063de2eb2", "x-ms-version": "2019-02-02" }, "RequestBody": { @@ -67,30 +67,30 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1380(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Date": "Wed, 08 Dec 2021 23:33:46 GMT", - "ETag": "W/\u0022datetime\u00272021-12-08T23%3A33%3A46.0599927Z\u0027\u0022", - "Location": "https://fakeaccountname.table.core.windows.net/table1380(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1213(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Date": "Thu, 09 Dec 2021 01:06:28 GMT", + "ETag": "W/\u0022datetime\u00272021-12-09T01%3A06%3A28.8513848Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/table1213(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", "Preference-Applied": "return-no-content", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "224d5228-4bc2-478c-bedd-4c16eb8e99b6", - "x-ms-request-id": "49e80c2d-7002-0006-0d8c-ec1f7f000000", + "x-ms-client-request-id": "1e6dc024-14cd-4371-bf49-bb2063de2eb2", + "x-ms-request-id": "78b87437-8002-004f-0b98-ec5d94000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null }, { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1380\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1213\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "DELETE", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip,deflate", "Connection": "keep-alive", "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "85dc6a5f-cc2e-4891-bff2-7ce851ba7df5", + "x-ms-client-request-id": "154df0c4-5aa4-42f1-8d44-d439e48dcb36", "x-ms-version": "2019-02-02" }, "RequestBody": null, @@ -98,19 +98,19 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 08 Dec 2021 23:33:46 GMT", + "Date": "Thu, 09 Dec 2021 01:06:28 GMT", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "85dc6a5f-cc2e-4891-bff2-7ce851ba7df5", - "x-ms-request-id": "49e80c31-7002-0006-118c-ec1f7f000000", + "x-ms-client-request-id": "154df0c4-5aa4-42f1-8d44-d439e48dcb36", + "x-ms-request-id": "78b87441-8002-004f-1598-ec5d94000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null } ], "Variables": { - "table-name": "table1380" + "table-name": "table1213" } } diff --git a/sdk/template/template/test/public/configurationClient.spec.ts b/sdk/template/template/test/public/configurationClient.spec.ts index 9cd7b8aa3edb..21d27c8ce408 100644 --- a/sdk/template/template/test/public/configurationClient.spec.ts +++ b/sdk/template/template/test/public/configurationClient.spec.ts @@ -6,8 +6,8 @@ import { Context } from "mocha"; import { ConfigurationClient } from "../../src"; -import { env, isPlaybackMode } from "@azure-tools/test-recorder"; -import { NoOpCredential, TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new"; +import { isPlaybackMode } from "@azure-tools/test-recorder"; +import { NoOpCredential, TestProxyHttpClientCoreV1, env } from "@azure-tools/test-recorder-new"; import { TokenCredential } from "@azure/core-http"; import { ClientSecretCredential } from "@azure/identity"; @@ -64,11 +64,11 @@ describe("[AAD] ConfigurationClient functional tests", function() { // `afterEach` hook. recorder = new TestProxyHttpClientCoreV1(this.currentTest); + await recorder.start({ envSetupForPlayback: replaceableVariables }); + // We'll be able to refer to the instantiated `client` in tests, since we // initialize it before each test client = createConfigurationClient(recorder); - - await recorder.start({ envSetupForPlayback: replaceableVariables }); }); // After each test, we need to stop the recording. diff --git a/sdk/template/template/test/public/core-v1-test.spec.ts b/sdk/template/template/test/public/core-v1-test.spec.ts index af7d4aa82409..8a3d30a0313c 100644 --- a/sdk/template/template/test/public/core-v1-test.spec.ts +++ b/sdk/template/template/test/public/core-v1-test.spec.ts @@ -2,10 +2,10 @@ // Licensed under the MIT license. // -import { env, isPlaybackMode } from "@azure-tools/test-recorder"; +import { isPlaybackMode } from "@azure-tools/test-recorder"; import { Context } from "mocha"; import { QueueServiceClient } from "@azure/storage-queue"; -import { TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new"; +import { TestProxyHttpClientCoreV1, env } from "@azure-tools/test-recorder-new"; // This fake URL will be used in the recording. We use a general regex sanitizer // (below) to replace the real SAS URL from when we record the test with this diff --git a/sdk/template/template/test/public/core-v2-test.spec.ts b/sdk/template/template/test/public/core-v2-test.spec.ts index 7f1bf2b015d0..55e9ccf4708d 100644 --- a/sdk/template/template/test/public/core-v2-test.spec.ts +++ b/sdk/template/template/test/public/core-v2-test.spec.ts @@ -3,9 +3,9 @@ import { TableClient, TableEntity } from "@azure/data-tables"; import { TestProxyHttpClient, recorderHttpPolicy } from "@azure-tools/test-recorder-new"; -import { env, isPlaybackMode } from "@azure-tools/test-recorder"; +import { isPlaybackMode } from "@azure-tools/test-recorder"; import { Context } from "mocha"; -import { SanitizerOptions } from "@azure-tools/test-recorder-new"; +import { SanitizerOptions, env } from "@azure-tools/test-recorder-new"; import { createSimpleEntity } from "../utils/utils"; // A fake connection string which replaces the actual connection string in the recording. From ff90778f3d0857f8b0f5449d4def164e9ba94d00 Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Thu, 9 Dec 2021 16:01:39 -0800 Subject: [PATCH 07/19] WIP -- trying to fix browser tests --- .../template/test/public/core-v1-test.spec.ts | 2 + .../recorder-new/test/testProxyTests.spec.ts | 24 ++++- .../testing-recorder-new/karma.conf.js | 2 +- .../recording_storagequeue_create_queue.json | 15 ++- .../recording_datatables_create_entity.json | 61 ++++++------ ...g_should_create_new_table_then_delete.json | 93 +------------------ 6 files changed, 56 insertions(+), 141 deletions(-) diff --git a/sdk/template/template/test/public/core-v1-test.spec.ts b/sdk/template/template/test/public/core-v1-test.spec.ts index 8a3d30a0313c..d119a8a2dee2 100644 --- a/sdk/template/template/test/public/core-v1-test.spec.ts +++ b/sdk/template/template/test/public/core-v1-test.spec.ts @@ -42,6 +42,8 @@ const sanitizers = { ] }; +console.log(env.STORAGE_SAS_URL.split("/")[3].split("?")[1]); + describe("Core V1 tests using unified recorder", () => { let recorder: TestProxyHttpClientCoreV1; diff --git a/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts b/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts index e71d4ca23ed9..e27b3bacf055 100644 --- a/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts +++ b/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts @@ -118,23 +118,37 @@ function getTestServerUrl() { describe("Sanitizers", () => { it("GeneralRegexSanitizer", async () => { - env.SECRET_INFO = "abcdef"; - const fakeSecretInfo = "fake_secret_info"; + const fakeSASUrl = + "sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2026-07-10T07:00:24Z&st=2021-07-09T23:00:24Z&spr=https&sig=fake_sig"; + + env.STORAGE_SAS_URL = "sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacupitfx&se=2022-11-24T06:36:20Z&st=2021-11-23T22:36:20Z&spr=https&sig=[[SECRET]]"; + + const getSanitizerOptions = () => { + return { + generalRegexSanitizers: [ + { + regex: env.STORAGE_SAS_URL, + value: fakeSASUrl, + } + ] + }; + }; await recorder.start({ envSetupForPlayback: { - SECRET_INFO: fakeSecretInfo + STORAGE_SAS_URL: fakeSASUrl } }); // Adds generalRegexSanitizers by default based on envSetupForPlayback + await recorder.addSanitizers(getSanitizerOptions()); await makeRequestAndVerifyResponse( { - path: `/sample_response/${env.SECRET_INFO}`, + path: `/sample_response/"${env.STORAGE_SAS_URL}"`, method: "GET" }, { val: "I am the answer!" } ); }); - it("RemoveHeaderSanitizer", async () => { + it.only("RemoveHeaderSanitizer", async () => { await recorder.start({ envSetupForPlayback: {}, sanitizerOptions: { diff --git a/sdk/test-utils/testing-recorder-new/karma.conf.js b/sdk/test-utils/testing-recorder-new/karma.conf.js index 03cc5f7b47ea..2e98fd66ad02 100644 --- a/sdk/test-utils/testing-recorder-new/karma.conf.js +++ b/sdk/test-utils/testing-recorder-new/karma.conf.js @@ -103,7 +103,7 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher // 'ChromeHeadless', 'Chrome', 'Firefox', 'Edge', 'IE' - browsers: ["ChromeHeadlessNoSandbox"], + browsers: ["ChromeHeadless"], customLaunchers: { ChromeHeadlessNoSandbox: { base: "ChromeHeadless", diff --git a/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v1_tests/recording_storagequeue_create_queue.json b/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v1_tests/recording_storagequeue_create_queue.json index 7b144b1703ab..514b5698f424 100644 --- a/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v1_tests/recording_storagequeue_create_queue.json +++ b/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v1_tests/recording_storagequeue_create_queue.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://account_name.queue.core.windows.net/queue-1836?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", + "RequestUri": "https://account_name.queue.core.windows.net/queue-1527?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", "RequestMethod": "PUT", "RequestHeaders": { "Accept": "application/xml", @@ -9,7 +9,6 @@ "Accept-Language": "en-US", "Connection": "keep-alive", "Content-Length": "0", - "Origin": "http://localhost:9328", "Referer": "http://localhost:9328/", "sec-ch-ua": "", "sec-ch-ua-mobile": "?0", @@ -18,28 +17,26 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "ed753236-f065-4292-912d-db14a14f03ab", + "x-ms-client-request-id": "c21186a7-d7e4-45bf-88aa-dd9b8cc38655", "x-ms-version": "2020-10-02" }, "RequestBody": null, "StatusCode": 201, "ResponseHeaders": { - "Access-Control-Allow-Origin": "*", - "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Content-Length,Date,Transfer-Encoding", "Content-Length": "0", - "Date": "Tue, 09 Nov 2021 00:35:21 GMT", + "Date": "Thu, 09 Dec 2021 22:47:55 GMT", "Server": [ "Windows-Azure-Queue/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "ed753236-f065-4292-912d-db14a14f03ab", - "x-ms-request-id": "2f6fe14f-4003-003e-0a01-d5d0dd000000", + "x-ms-client-request-id": "c21186a7-d7e4-45bf-88aa-dd9b8cc38655", + "x-ms-request-id": "b7f17d39-0003-006e-564e-ed79ef000000", "x-ms-version": "2020-10-02" }, "ResponseBody": null } ], "Variables": { - "queue-name": "queue-1836" + "queue-name": "queue-1527" } } diff --git a/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v2_tests/recording_datatables_create_entity.json b/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v2_tests/recording_datatables_create_entity.json index 08cb5a28a034..c23e1fc16971 100644 --- a/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v2_tests/recording_datatables_create_entity.json +++ b/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v2_tests/recording_datatables_create_entity.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://timovperftestplayground.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -11,7 +11,6 @@ "Content-Length": "25", "Content-Type": "application/json;odata=nometadata", "dataserviceversion": "3.0", - "Origin": "http://localhost:9328", "Referer": "http://localhost:9328/", "sec-ch-ua": "", "sec-ch-ua-mobile": "?0", @@ -20,37 +19,35 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "abacc0eb-947c-417e-954a-7ffc7eb177c2", - "x-ms-useragent": "azsdk-js-data-tables/12.2.0 core-rest-pipeline/1.3.3 OS/Linuxx86_64", + "x-ms-client-request-id": "354dcb7b-541b-4182-a751-25b0e10d74d4", + "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, "RequestBody": { - "TableName": "table1099" + "TableName": "table1760" }, "StatusCode": 201, "ResponseHeaders": { - "Access-Control-Allow-Origin": "*", - "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,X-Content-Type-Options,Cache-Control,Location,Content-Type,Content-Length,Date,Transfer-Encoding", "Cache-Control": "no-cache", "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Tue, 09 Nov 2021 00:35:21 GMT", - "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1099\u0027)", + "Date": "Thu, 09 Dec 2021 22:47:55 GMT", + "Location": "https://timovperftestplayground.table.core.windows.net/Tables(\u0027table1760\u0027)", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], "Transfer-Encoding": "chunked", - "x-ms-client-request-id": "abacc0eb-947c-417e-954a-7ffc7eb177c2", - "x-ms-request-id": "0fb4188a-0002-0010-6a01-d5501a000000", + "x-ms-client-request-id": "354dcb7b-541b-4182-a751-25b0e10d74d4", + "x-ms-request-id": "fd439e64-7002-0064-4f4e-eddd58000000", "x-ms-version": "2019-02-02" }, "ResponseBody": { - "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#Tables/@Element", - "TableName": "table1099" + "odata.metadata": "https://timovperftestplayground.table.core.windows.net/$metadata#Tables/@Element", + "TableName": "table1760" } }, { - "RequestUri": "https://fakeaccountname.table.core.windows.net/table1099?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://timovperftestplayground.table.core.windows.net/table1760?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -60,7 +57,6 @@ "Content-Length": "366", "Content-Type": "application/json;odata=nometadata", "dataserviceversion": "3.0", - "Origin": "http://localhost:9328", "prefer": "return-no-content", "Referer": "http://localhost:9328/", "sec-ch-ua": "", @@ -70,8 +66,8 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "4c8bce23-dac7-4910-b422-6d023fe1f84d", - "x-ms-useragent": "azsdk-js-data-tables/12.2.0 core-rest-pipeline/1.3.3 OS/Linuxx86_64", + "x-ms-client-request-id": "27ba3bf7-fccd-4f32-8216-4b8c5a1b4800", + "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, "RequestBody": { @@ -87,34 +83,31 @@ }, "StatusCode": 204, "ResponseHeaders": { - "Access-Control-Allow-Origin": "*", - "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,X-Content-Type-Options,Cache-Control,Preference-Applied,Location,DataServiceId,ETag,Content-Length,Date,Transfer-Encoding", "Cache-Control": "no-cache", "Content-Length": "0", - "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1099(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Date": "Tue, 09 Nov 2021 00:35:22 GMT", - "ETag": "W/\u0022datetime\u00272021-11-09T00%3A35%3A22.767648Z\u0027\u0022", - "Location": "https://fakeaccountname.table.core.windows.net/table1099(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "DataServiceId": "https://timovperftestplayground.table.core.windows.net/table1760(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Date": "Thu, 09 Dec 2021 22:47:56 GMT", + "ETag": "W/\u0022datetime\u00272021-12-09T22%3A47%3A56.4498903Z\u0027\u0022", + "Location": "https://timovperftestplayground.table.core.windows.net/table1760(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", "Preference-Applied": "return-no-content", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "4c8bce23-dac7-4910-b422-6d023fe1f84d", - "x-ms-request-id": "0fb4189c-0002-0010-7a01-d5501a000000", + "x-ms-client-request-id": "27ba3bf7-fccd-4f32-8216-4b8c5a1b4800", + "x-ms-request-id": "fd439e79-7002-0064-624e-eddd58000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null }, { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1099\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://timovperftestplayground.table.core.windows.net/Tables(\u0027table1760\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "DELETE", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "en-US", "Connection": "keep-alive", - "Origin": "http://localhost:9328", "Referer": "http://localhost:9328/", "sec-ch-ua": "", "sec-ch-ua-mobile": "?0", @@ -123,30 +116,28 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "48071f12-8913-4acc-b6f9-414d0b5df23a", - "x-ms-useragent": "azsdk-js-data-tables/12.2.0 core-rest-pipeline/1.3.3 OS/Linuxx86_64", + "x-ms-client-request-id": "ace68096-3520-4ac0-a48e-b75ac7cf9ec0", + "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, "RequestBody": null, "StatusCode": 204, "ResponseHeaders": { - "Access-Control-Allow-Origin": "*", - "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,X-Content-Type-Options,Cache-Control,Content-Length,Date,Transfer-Encoding", "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Tue, 09 Nov 2021 00:35:22 GMT", + "Date": "Thu, 09 Dec 2021 22:47:56 GMT", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "48071f12-8913-4acc-b6f9-414d0b5df23a", - "x-ms-request-id": "0fb418af-0002-0010-0b01-d5501a000000", + "x-ms-client-request-id": "ace68096-3520-4ac0-a48e-b75ac7cf9ec0", + "x-ms-request-id": "fd439e85-7002-0064-6e4e-eddd58000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null } ], "Variables": { - "table-name": "table1099" + "table-name": "table1760" } } diff --git a/sdk/test-utils/testing-recorder-new/recordings/browsers/noop_credential_with_tables/recording_should_create_new_table_then_delete.json b/sdk/test-utils/testing-recorder-new/recordings/browsers/noop_credential_with_tables/recording_should_create_new_table_then_delete.json index 60888ca95608..5eedf02b315b 100644 --- a/sdk/test-utils/testing-recorder-new/recordings/browsers/noop_credential_with_tables/recording_should_create_new_table_then_delete.json +++ b/sdk/test-utils/testing-recorder-new/recordings/browsers/noop_credential_with_tables/recording_should_create_new_table_then_delete.json @@ -1,95 +1,6 @@ { - "Entries": [ - { - "RequestUri": "https://fakeaccount.table.core.windows.net/Tables", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json;odata=minimalmetadata", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "en-US", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "Content-Length": "25", - "Content-Type": "application/json;odata=nometadata", - "dataserviceversion": "3.0", - "prefer": "return-content", - "Referer": "http://localhost:9328/", - "sec-ch-ua": "", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Fetch-Site": "same-site", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "73505eb1-249a-4907-a923-31a56ecb6ab2", - "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", - "x-ms-version": "2019-02-02" - }, - "RequestBody": { - "TableName": "table1678" - }, - "StatusCode": 201, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Wed, 01 Dec 2021 03:33:59 GMT", - "Location": "https://fakeaccount.table.core.windows.net/Tables(\u0027table1678\u0027)", - "Preference-Applied": "return-content", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "73505eb1-249a-4907-a923-31a56ecb6ab2", - "x-ms-request-id": "f4a38afa-9002-0015-7164-e64326000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": { - "odata.metadata": "https://fakeaccount.table.core.windows.net/$metadata#Tables/@Element", - "TableName": "table1678" - } - }, - { - "RequestUri": "https://fakeaccount.table.core.windows.net/Tables(\u0027table1678\u0027)", - "RequestMethod": "DELETE", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "en-US", - "Authorization": "Sanitized", - "Connection": "keep-alive", - "Referer": "http://localhost:9328/", - "sec-ch-ua": "", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Fetch-Site": "same-site", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "4a1c3793-6746-42a4-9c4c-24957e49217d", - "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", - "x-ms-version": "2019-02-02" - }, - "RequestBody": null, - "StatusCode": 204, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "0", - "Date": "Wed, 01 Dec 2021 03:33:59 GMT", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "4a1c3793-6746-42a4-9c4c-24957e49217d", - "x-ms-request-id": "f4a38b1c-9002-0015-1164-e64326000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": null - } - ], + "Entries": [], "Variables": { - "table-name": "table1678" + "table-name": "table1977" } } From bf61f7546fcceb7c2101203c732f53b563a7485e Mon Sep 17 00:00:00 2001 From: Harsha Nalluru Date: Fri, 10 Dec 2021 09:54:00 +0000 Subject: [PATCH 08/19] load the env file by default --- sdk/test-utils/recorder-new/src/index.ts | 4 ++++ sdk/test-utils/testing-recorder-new/src/index.ts | 2 ++ sdk/test-utils/testing-recorder-new/test/core-v1-test.spec.ts | 2 -- sdk/test-utils/testing-recorder-new/test/core-v2-test.spec.ts | 2 -- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/test-utils/recorder-new/src/index.ts b/sdk/test-utils/recorder-new/src/index.ts index 9edaf4d68f7e..40cee129bbc2 100644 --- a/sdk/test-utils/recorder-new/src/index.ts +++ b/sdk/test-utils/recorder-new/src/index.ts @@ -6,3 +6,7 @@ export { TestProxyHttpClientCoreV1 } from "./core-v1-recorder"; export { relativeRecordingsPath } from "./utils/relativePathCalculator"; export { SanitizerOptions, RecorderStartOptions } from "./utils/utils"; export { NoOpCredential } from "./recorderAADCredential"; + +// Initialize the environment +import { config } from "dotenv"; +config(); diff --git a/sdk/test-utils/testing-recorder-new/src/index.ts b/sdk/test-utils/testing-recorder-new/src/index.ts index e69de29bb2d1..fd2aca680c7b 100644 --- a/sdk/test-utils/testing-recorder-new/src/index.ts +++ b/sdk/test-utils/testing-recorder-new/src/index.ts @@ -0,0 +1,2 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. diff --git a/sdk/test-utils/testing-recorder-new/test/core-v1-test.spec.ts b/sdk/test-utils/testing-recorder-new/test/core-v1-test.spec.ts index b57952b9e892..4e865d600cbe 100644 --- a/sdk/test-utils/testing-recorder-new/test/core-v1-test.spec.ts +++ b/sdk/test-utils/testing-recorder-new/test/core-v1-test.spec.ts @@ -4,9 +4,7 @@ import { env, isPlaybackMode } from "@azure-tools/test-recorder"; import { QueueServiceClient } from "@azure/storage-queue"; import { TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new"; -import { config } from "dotenv"; import { RecorderStartOptions } from "@azure-tools/test-recorder-new"; -config(); const fakeSASUrl = "https://account_name.queue.core.windows.net/?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2026-07-10T07:00:24Z&st=2021-07-09T23:00:24Z&spr=https&sig=fake_sig"; diff --git a/sdk/test-utils/testing-recorder-new/test/core-v2-test.spec.ts b/sdk/test-utils/testing-recorder-new/test/core-v2-test.spec.ts index 137aa6a3c0f3..1a376f1e669d 100644 --- a/sdk/test-utils/testing-recorder-new/test/core-v2-test.spec.ts +++ b/sdk/test-utils/testing-recorder-new/test/core-v2-test.spec.ts @@ -8,10 +8,8 @@ import { recorderHttpPolicy, RecorderStartOptions } from "@azure-tools/test-recorder-new"; -import { config } from "dotenv"; import { createSimpleEntity } from "./utils/utils"; import { SanitizerOptions } from "@azure-tools/test-recorder-new"; -config(); const fakeConnString = "TableEndpoint=https://fakeaccountname.table.core.windows.net/;SharedAccessSignature=st=2021-08-03T08:52:15Z&spr=https&sig=fakesigval"; From a774935d2ee8ad92708c17133a4e6df35835ccd1 Mon Sep 17 00:00:00 2001 From: Harsha Nalluru Date: Fri, 10 Dec 2021 09:57:00 +0000 Subject: [PATCH 09/19] changelog --- sdk/test-utils/recorder-new/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/test-utils/recorder-new/CHANGELOG.md b/sdk/test-utils/recorder-new/CHANGELOG.md index 6ef667c8d0ee..91c015597130 100644 --- a/sdk/test-utils/recorder-new/CHANGELOG.md +++ b/sdk/test-utils/recorder-new/CHANGELOG.md @@ -2,6 +2,11 @@ ## 1.0.0 (Unreleased) +## 2021-12-10 + +- Loads the .env file using with the help of "dotenv" by default. + [#19139](https://github.com/Azure/azure-sdk-for-js/pull/19139) + ## 2021-11-30 - Adds NoOp AAD Credential for playback `NoOpCredential`. Using this as your AAD credential in playback mode would avoid the AAD traffic in playback. From b2a88fb3d3a3c7d89038d67f2789def3410ecf7f Mon Sep 17 00:00:00 2001 From: Harsha Nalluru Date: Fri, 10 Dec 2021 11:10:08 +0000 Subject: [PATCH 10/19] fix template project --- ...determined_setting_has_expected_value.json | 20 ++--- .../recording_storagequeue_create_queue.json | 12 +-- .../recording_datatables_create_entity.json | 44 +++++------ .../test/public/configurationClient.spec.ts | 4 +- .../template/test/public/core-v1-test.spec.ts | 75 ++++++++++++------- .../template/test/public/core-v2-test.spec.ts | 4 +- sdk/test-utils/recorder-new/src/index.ts | 5 +- .../recorder-new/src/utils/env.browser.ts | 4 + sdk/test-utils/recorder-new/src/utils/env.ts | 8 ++ .../src/utils/envSetupForPlayback.ts | 8 +- 10 files changed, 107 insertions(+), 77 deletions(-) create mode 100644 sdk/test-utils/recorder-new/src/utils/env.browser.ts create mode 100644 sdk/test-utils/recorder-new/src/utils/env.ts diff --git a/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json b/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json index ccc9561bb452..f3cf4b7feef0 100644 --- a/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json +++ b/sdk/template/template/recordings/browsers/aad_configurationclient_functional_tests/recording_predetermined_setting_has_expected_value.json @@ -17,7 +17,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "f574af18-7e18-4257-aa9d-4c81bef33fdc", + "x-ms-client-request-id": "0a240cc2-fffd-45da-9a4c-fe8cebdff715", "x-ms-useragent": "azsdk-js-template-template/1.0.11-beta.1 core-http/2.2.3 OS/Linuxx86_64" }, "RequestBody": null, @@ -28,25 +28,25 @@ "Access-Control-Expose-Headers": "DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-useragent, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, retry-after-ms, x-ms-request-id, x-ms-client-session-id, x-ms-effective-locale, WWW-Authenticate, traceparent, tracestate", "Connection": "keep-alive", "Content-Type": "application/vnd.microsoft.appconfig.kv\u002Bjson; charset=utf-8", - "Date": "Thu, 09 Dec 2021 01:06:33 GMT", - "ETag": "\u0022jRXE6grlhA98vbDBE98P9JDaMPm\u0022", - "Last-Modified": "Thu, 09 Dec 2021 01:05:58 GMT", + "Date": "Fri, 10 Dec 2021 11:09:32 GMT", + "ETag": "\u0022jHnSsNSkboEWJFD7nnfzHgnZjRA\u0022", + "Last-Modified": "Wed, 01 Dec 2021 02:23:41 GMT", "Server": "openresty/1.17.8.2", "Strict-Transport-Security": "max-age=15724800; includeSubDomains", - "Sync-Token": "zAJw6V16=NToxOSM4NDcxODQ4;sn=8471848", + "Sync-Token": "zAJw6V16=NDoxOSM1MjM0MTM4;sn=5234138", "Transfer-Encoding": "chunked", - "x-ms-correlation-request-id": "aa7c5881-eb30-4689-8b7b-34b4adb1b51e", - "x-ms-request-id": "aa7c5881-eb30-4689-8b7b-34b4adb1b51e" + "x-ms-correlation-request-id": "cb5d6844-d7dd-48e7-866f-dcb2331ed70f", + "x-ms-request-id": "cb5d6844-d7dd-48e7-866f-dcb2331ed70f" }, "ResponseBody": { - "etag": "jRXE6grlhA98vbDBE98P9JDaMPm", + "etag": "jHnSsNSkboEWJFD7nnfzHgnZjRA", "key": "test-key", "label": null, - "content_type": "", + "content_type": null, "value": "test-value", "tags": {}, "locked": false, - "last_modified": "2021-12-09T01:05:58\u002B00:00" + "last_modified": "2021-12-01T02:23:41\u002B00:00" } } ], diff --git a/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json b/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json index 15ab1404b6b0..af9ee26357c0 100644 --- a/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json +++ b/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://account_name.queue.core.windows.net/queue-1660?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacupitfx\u0026se=2022-11-24T06:36:20Z\u0026st=2021-11-23T22:36:20Z\u0026spr=https\u0026sig=LVfIG7n%2Bx8bXQIPfh3OHd6kxTLxbRz70xo9ejm05oE0%3D\u0026timeout=30", + "RequestUri": "https://account_name.queue.core.windows.net/queue-1326?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", "RequestMethod": "PUT", "RequestHeaders": { "Accept": "application/xml", @@ -17,26 +17,26 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "ea90776a-0217-4e92-8159-2468cad1c6fe", + "x-ms-client-request-id": "dbad8518-70bf-415e-add0-bafaeb9591c8", "x-ms-version": "2020-12-06" }, "RequestBody": null, "StatusCode": 201, "ResponseHeaders": { "Content-Length": "0", - "Date": "Thu, 09 Dec 2021 01:06:33 GMT", + "Date": "Fri, 10 Dec 2021 11:09:31 GMT", "Server": [ "Windows-Azure-Queue/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "ea90776a-0217-4e92-8159-2468cad1c6fe", - "x-ms-request-id": "d8e7fabb-a003-0058-6399-ecf49f000000", + "x-ms-client-request-id": "dbad8518-70bf-415e-add0-bafaeb9591c8", + "x-ms-request-id": "39e9dcc7-1003-004b-7fb6-ed5766000000", "x-ms-version": "2020-12-06" }, "ResponseBody": null } ], "Variables": { - "queue-name": "queue-1660" + "queue-name": "queue-1326" } } diff --git a/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json b/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json index 9d44bf686cf9..3488562226b7 100644 --- a/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json +++ b/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacupitfx\u0026se=2022-11-24T06:36:20Z\u0026st=2021-11-23T22:36:20Z\u0026spr=https\u0026sig=LVfIG7n%2Bx8bXQIPfh3OHd6kxTLxbRz70xo9ejm05oE0%3D", + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -19,35 +19,35 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "eed6bd7d-c75b-4504-8be4-3743fb45adbb", + "x-ms-client-request-id": "e248395e-2039-4985-82b8-1966333e3a55", "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, "RequestBody": { - "TableName": "table1334" + "TableName": "table1891" }, "StatusCode": 201, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Thu, 09 Dec 2021 01:06:34 GMT", - "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1334\u0027)", + "Date": "Fri, 10 Dec 2021 11:09:32 GMT", + "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1891\u0027)", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], "Transfer-Encoding": "chunked", - "x-ms-client-request-id": "eed6bd7d-c75b-4504-8be4-3743fb45adbb", - "x-ms-request-id": "a010c469-9002-0031-7a99-eccdd3000000", + "x-ms-client-request-id": "e248395e-2039-4985-82b8-1966333e3a55", + "x-ms-request-id": "53bdc585-1002-004b-4bb6-ed5766000000", "x-ms-version": "2019-02-02" }, "ResponseBody": { "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#Tables/@Element", - "TableName": "table1334" + "TableName": "table1891" } }, { - "RequestUri": "https://fakeaccountname.table.core.windows.net/table1334?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacupitfx\u0026se=2022-11-24T06:36:20Z\u0026st=2021-11-23T22:36:20Z\u0026spr=https\u0026sig=LVfIG7n%2Bx8bXQIPfh3OHd6kxTLxbRz70xo9ejm05oE0%3D", + "RequestUri": "https://fakeaccountname.table.core.windows.net/table1891?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -66,7 +66,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "fd20e0a1-6897-4a09-acae-ff2bb5e2a9f7", + "x-ms-client-request-id": "483bcdfe-ed56-442d-b747-01efa4ad9d38", "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, @@ -85,23 +85,23 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1334(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Date": "Thu, 09 Dec 2021 01:06:34 GMT", - "ETag": "W/\u0022datetime\u00272021-12-09T01%3A06%3A34.4169059Z\u0027\u0022", - "Location": "https://fakeaccountname.table.core.windows.net/table1334(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1891(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Date": "Fri, 10 Dec 2021 11:09:32 GMT", + "ETag": "W/\u0022datetime\u00272021-12-10T11%3A09%3A32.9281617Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/table1891(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", "Preference-Applied": "return-no-content", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "fd20e0a1-6897-4a09-acae-ff2bb5e2a9f7", - "x-ms-request-id": "a010c472-9002-0031-0199-eccdd3000000", + "x-ms-client-request-id": "483bcdfe-ed56-442d-b747-01efa4ad9d38", + "x-ms-request-id": "53bdc5a3-1002-004b-66b6-ed5766000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null }, { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1334\u0027)?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacupitfx\u0026se=2022-11-24T06:36:20Z\u0026st=2021-11-23T22:36:20Z\u0026spr=https\u0026sig=LVfIG7n%2Bx8bXQIPfh3OHd6kxTLxbRz70xo9ejm05oE0%3D", + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1891\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "DELETE", "RequestHeaders": { "Accept": "application/json", @@ -116,7 +116,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "a2d5b720-9e46-46e7-81e3-5c2307451777", + "x-ms-client-request-id": "bc134a07-fb02-4ed0-b66d-bd8e24f3596c", "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, @@ -125,19 +125,19 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Thu, 09 Dec 2021 01:06:34 GMT", + "Date": "Fri, 10 Dec 2021 11:09:32 GMT", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "a2d5b720-9e46-46e7-81e3-5c2307451777", - "x-ms-request-id": "a010c475-9002-0031-0499-eccdd3000000", + "x-ms-client-request-id": "bc134a07-fb02-4ed0-b66d-bd8e24f3596c", + "x-ms-request-id": "53bdc5c5-1002-004b-05b6-ed5766000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null } ], "Variables": { - "table-name": "table1334" + "table-name": "table1891" } } diff --git a/sdk/template/template/test/public/configurationClient.spec.ts b/sdk/template/template/test/public/configurationClient.spec.ts index 21d27c8ce408..b9e306b30f2d 100644 --- a/sdk/template/template/test/public/configurationClient.spec.ts +++ b/sdk/template/template/test/public/configurationClient.spec.ts @@ -6,8 +6,8 @@ import { Context } from "mocha"; import { ConfigurationClient } from "../../src"; -import { isPlaybackMode } from "@azure-tools/test-recorder"; -import { NoOpCredential, TestProxyHttpClientCoreV1, env } from "@azure-tools/test-recorder-new"; +import { isPlaybackMode, env } from "@azure-tools/test-recorder"; +import { NoOpCredential, TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new"; import { TokenCredential } from "@azure/core-http"; import { ClientSecretCredential } from "@azure/identity"; diff --git a/sdk/template/template/test/public/core-v1-test.spec.ts b/sdk/template/template/test/public/core-v1-test.spec.ts index d119a8a2dee2..5c64658ff8af 100644 --- a/sdk/template/template/test/public/core-v1-test.spec.ts +++ b/sdk/template/template/test/public/core-v1-test.spec.ts @@ -5,7 +5,12 @@ import { isPlaybackMode } from "@azure-tools/test-recorder"; import { Context } from "mocha"; import { QueueServiceClient } from "@azure/storage-queue"; -import { TestProxyHttpClientCoreV1, env } from "@azure-tools/test-recorder-new"; +import { + TestProxyHttpClientCoreV1, + env, + RecorderStartOptions, + SanitizerOptions +} from "@azure-tools/test-recorder-new"; // This fake URL will be used in the recording. We use a general regex sanitizer // (below) to replace the real SAS URL from when we record the test with this @@ -13,36 +18,46 @@ import { TestProxyHttpClientCoreV1, env } from "@azure-tools/test-recorder-new"; const fakeSASUrl = "https://account_name.queue.core.windows.net/?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2026-07-10T07:00:24Z&st=2021-07-09T23:00:24Z&spr=https&sig=fake_sig"; -// These options are passed to the recorder for playback. -const recorderOptions = { - envSetupForPlayback: { +function getRecorderStartOptions(): RecorderStartOptions { + // These options are passed to the recorder for playback. + const envSetupForPlayback: Record = { // In playback, we use the fake SAS URL instead of a real one which would have // been provided via the .env file or otherwise. STORAGE_SAS_URL: fakeSASUrl - } -}; + }; -const sanitizers = { - // There are several different sanitzers that can be used. A general regex sanitizer - // allows for a simple find and replace based on a given regular expression. This is - // used here to strip out the sensitive and dynamic parts of the SAS URL in the recording, - // replacing them with their corresponding components from the fake SAS URL defined above. - generalRegexSanitizers: [ - // This one replaces the host portion of the URL, which is dynamic based on the storage account... - { - regex: env.STORAGE_SAS_URL.split("/")[2], - value: fakeSASUrl.split("/")[2] - }, - // ...and this one replaces the query string which contains sensitive information relating to - // the SAS token. - { - regex: env.STORAGE_SAS_URL.split("/")[3].split("?")[1], - value: fakeSASUrl.split("/")[3].split("?")[1] - } - ] -}; + let sanitizerOptions: SanitizerOptions | undefined; + + if (env.STORAGE_SAS_URL) { + const realSASParts = env.STORAGE_SAS_URL.split("/"); + const fakeSASParts = fakeSASUrl.split("/"); -console.log(env.STORAGE_SAS_URL.split("/")[3].split("?")[1]); + sanitizerOptions = { + // There are several different sanitzers that can be used. A general regex sanitizer + // allows for a simple find and replace based on a given regular expression. This is + // used here to strip out the sensitive and dynamic parts of the SAS URL in the recording, + // replacing them with their corresponding components from the fake SAS URL defined above. + generalRegexSanitizers: [ + // This one replaces the host portion of the URL, which is dynamic based on the storage account... + { + regex: realSASParts[2], + value: fakeSASParts[2] + }, + // ...and this one replaces the query string which contains sensitive information relating to + // the SAS token. + { + regex: realSASParts[3].split("?")[1], + value: fakeSASParts[3].split("?")[1] + } + ] + }; + } + + return { + envSetupForPlayback, + sanitizerOptions + }; +} describe("Core V1 tests using unified recorder", () => { let recorder: TestProxyHttpClientCoreV1; @@ -55,8 +70,7 @@ describe("Core V1 tests using unified recorder", () => { recorder = new TestProxyHttpClientCoreV1(this.currentTest); // Configure the recorder and start it up prior to each test... - await recorder.start(recorderOptions); - await recorder.addSanitizers(sanitizers); + await recorder.start(getRecorderStartOptions()); }); afterEach(async () => { @@ -67,7 +81,10 @@ describe("Core V1 tests using unified recorder", () => { it("storage-queue create queue", async function() { // Along with specifying the necessary parameters for the QueueServiceClient, we pass through // the test proxy HTTP client, which mean that the client will use the recorder when making requests. - const client = new QueueServiceClient(env.STORAGE_SAS_URL, undefined, { httpClient: recorder }); + + const client = new QueueServiceClient(env.STORAGE_SAS_URL ?? "", undefined, { + httpClient: recorder + }); // Variables can be generated in record mode, and are stored with the recording to be reused // in playback mode. diff --git a/sdk/template/template/test/public/core-v2-test.spec.ts b/sdk/template/template/test/public/core-v2-test.spec.ts index 55e9ccf4708d..9564ec6ca2d2 100644 --- a/sdk/template/template/test/public/core-v2-test.spec.ts +++ b/sdk/template/template/test/public/core-v2-test.spec.ts @@ -3,9 +3,9 @@ import { TableClient, TableEntity } from "@azure/data-tables"; import { TestProxyHttpClient, recorderHttpPolicy } from "@azure-tools/test-recorder-new"; -import { isPlaybackMode } from "@azure-tools/test-recorder"; +import { isPlaybackMode, env } from "@azure-tools/test-recorder"; import { Context } from "mocha"; -import { SanitizerOptions, env } from "@azure-tools/test-recorder-new"; +import { SanitizerOptions } from "@azure-tools/test-recorder-new"; import { createSimpleEntity } from "../utils/utils"; // A fake connection string which replaces the actual connection string in the recording. diff --git a/sdk/test-utils/recorder-new/src/index.ts b/sdk/test-utils/recorder-new/src/index.ts index 40cee129bbc2..ad346f007e16 100644 --- a/sdk/test-utils/recorder-new/src/index.ts +++ b/sdk/test-utils/recorder-new/src/index.ts @@ -6,7 +6,4 @@ export { TestProxyHttpClientCoreV1 } from "./core-v1-recorder"; export { relativeRecordingsPath } from "./utils/relativePathCalculator"; export { SanitizerOptions, RecorderStartOptions } from "./utils/utils"; export { NoOpCredential } from "./recorderAADCredential"; - -// Initialize the environment -import { config } from "dotenv"; -config(); +export { env } from "./utils/env"; diff --git a/sdk/test-utils/recorder-new/src/utils/env.browser.ts b/sdk/test-utils/recorder-new/src/utils/env.browser.ts new file mode 100644 index 000000000000..c738aa78abda --- /dev/null +++ b/sdk/test-utils/recorder-new/src/utils/env.browser.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +export const env = (window as any).__env__; diff --git a/sdk/test-utils/recorder-new/src/utils/env.ts b/sdk/test-utils/recorder-new/src/utils/env.ts new file mode 100644 index 000000000000..49e8758c046b --- /dev/null +++ b/sdk/test-utils/recorder-new/src/utils/env.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as dotenv from "dotenv"; + +dotenv.config(); + +export const env = process.env; diff --git a/sdk/test-utils/recorder-new/src/utils/envSetupForPlayback.ts b/sdk/test-utils/recorder-new/src/utils/envSetupForPlayback.ts index bd9a44deff19..af1d99465b7b 100644 --- a/sdk/test-utils/recorder-new/src/utils/envSetupForPlayback.ts +++ b/sdk/test-utils/recorder-new/src/utils/envSetupForPlayback.ts @@ -1,8 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { isPlaybackMode, isRecordMode, setEnvironmentVariables } from "@azure-tools/test-recorder"; -import { env } from "./env"; +import { + env, + isPlaybackMode, + isRecordMode, + setEnvironmentVariables +} from "@azure-tools/test-recorder"; import { Sanitizer } from "../sanitizer"; /** From 52e3d69afa784d873fca437c43273a5ca3bef9f7 Mon Sep 17 00:00:00 2001 From: Harsha Nalluru Date: Fri, 10 Dec 2021 03:11:42 -0800 Subject: [PATCH 11/19] Update sdk/test-utils/recorder-new/test/testProxyTests.spec.ts --- sdk/test-utils/recorder-new/test/testProxyTests.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts b/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts index e27b3bacf055..5d6aee0a6f2a 100644 --- a/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts +++ b/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts @@ -148,7 +148,7 @@ function getTestServerUrl() { ); }); - it.only("RemoveHeaderSanitizer", async () => { + it("RemoveHeaderSanitizer", async () => { await recorder.start({ envSetupForPlayback: {}, sanitizerOptions: { From 9a05a69754067edd66cd94e7279d0e8c7198a250 Mon Sep 17 00:00:00 2001 From: Harsha Nalluru Date: Fri, 10 Dec 2021 03:25:36 -0800 Subject: [PATCH 12/19] Update sdk/test-utils/recorder-new/test/testProxyTests.spec.ts --- sdk/test-utils/recorder-new/test/testProxyTests.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts b/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts index 5d6aee0a6f2a..f05a205f05a6 100644 --- a/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts +++ b/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts @@ -117,7 +117,7 @@ function getTestServerUrl() { }); describe("Sanitizers", () => { - it("GeneralRegexSanitizer", async () => { + it.skip("GeneralRegexSanitizer", async () => { const fakeSASUrl = "sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2026-07-10T07:00:24Z&st=2021-07-09T23:00:24Z&spr=https&sig=fake_sig"; From 0ae993590021ea33b8a6aba103357d210ed6e9f8 Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Fri, 10 Dec 2021 23:28:42 +0000 Subject: [PATCH 13/19] revert testing things --- sdk/template/template/package.json | 2 +- .../recorder-new/test/testProxyTests.spec.ts | 31 ++++--------------- .../testing-recorder-new/karma.conf.js | 2 +- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/sdk/template/template/package.json b/sdk/template/template/package.json index 1a0d08589a19..453de4c02975 100644 --- a/sdk/template/template/package.json +++ b/sdk/template/template/package.json @@ -40,7 +40,7 @@ "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", "generate:client": "autorest --typescript ./swagger/README.md", "integration-test:browser": "dev-tool run test:browser", - "integration-test:node":"dev-tool run test:node-ts-input --mocha=\"--timeout 1200000 'test/**/*.spec.ts'\"", + "integration-test:node": "dev-tool run test:node-ts-input --mocha=\"--timeout 1200000 'test/**/*.spec.ts'\"", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", "lint": "eslint package.json api-extractor.json src test --ext .ts", diff --git a/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts b/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts index f05a205f05a6..cc283a96f079 100644 --- a/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts +++ b/sdk/test-utils/recorder-new/test/testProxyTests.spec.ts @@ -117,31 +117,17 @@ function getTestServerUrl() { }); describe("Sanitizers", () => { - it.skip("GeneralRegexSanitizer", async () => { - const fakeSASUrl = - "sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2026-07-10T07:00:24Z&st=2021-07-09T23:00:24Z&spr=https&sig=fake_sig"; - - env.STORAGE_SAS_URL = "sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacupitfx&se=2022-11-24T06:36:20Z&st=2021-11-23T22:36:20Z&spr=https&sig=[[SECRET]]"; - - const getSanitizerOptions = () => { - return { - generalRegexSanitizers: [ - { - regex: env.STORAGE_SAS_URL, - value: fakeSASUrl, - } - ] - }; - }; + it("GeneralRegexSanitizer", async () => { + env.SECRET_INFO = "abcdef"; + const fakeSecretInfo = "fake_secret_info"; await recorder.start({ envSetupForPlayback: { - STORAGE_SAS_URL: fakeSASUrl + SECRET_INFO: fakeSecretInfo } }); // Adds generalRegexSanitizers by default based on envSetupForPlayback - await recorder.addSanitizers(getSanitizerOptions()); await makeRequestAndVerifyResponse( { - path: `/sample_response/"${env.STORAGE_SAS_URL}"`, + path: `/sample_response/${env.SECRET_INFO}`, method: "GET" }, { val: "I am the answer!" } @@ -273,7 +259,7 @@ function getTestServerUrl() { ); }); - it.skip("ContinuationSanitizer", async () => { + it("ContinuationSanitizer", async () => { await recorder.start({ envSetupForPlayback: {}, sanitizerOptions: { @@ -296,11 +282,6 @@ function getTestServerUrl() { undefined ); - // Seems to fail with - // Unable to find a record for the request GET http://host.docker.internal:8080/sample_response - // Header differences: - // values differ, request <985e1725-6d96-467c-89fc-fe45ef0409e4>, record <7460db09-3140-4f76-b59c-16f23e91bc4c> - // TODO: Scott is working on fixing the sanitizer await makeRequestAndVerifyResponse( { path: `/sample_response`, diff --git a/sdk/test-utils/testing-recorder-new/karma.conf.js b/sdk/test-utils/testing-recorder-new/karma.conf.js index 2e98fd66ad02..03cc5f7b47ea 100644 --- a/sdk/test-utils/testing-recorder-new/karma.conf.js +++ b/sdk/test-utils/testing-recorder-new/karma.conf.js @@ -103,7 +103,7 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher // 'ChromeHeadless', 'Chrome', 'Firefox', 'Edge', 'IE' - browsers: ["ChromeHeadless"], + browsers: ["ChromeHeadlessNoSandbox"], customLaunchers: { ChromeHeadlessNoSandbox: { base: "ChromeHeadless", From 04ea0076de125806794c37fdde3c2b2d4feee789 Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Mon, 13 Dec 2021 16:06:12 -0800 Subject: [PATCH 14/19] Revert accidental changes to testing-recorder-new recordings --- .../recording_storagequeue_create_queue.json | 15 +-- .../recording_datatables_create_entity.json | 61 ++++++------ ...g_should_create_new_table_then_delete.json | 93 ++++++++++++++++++- 3 files changed, 135 insertions(+), 34 deletions(-) diff --git a/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v1_tests/recording_storagequeue_create_queue.json b/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v1_tests/recording_storagequeue_create_queue.json index 514b5698f424..7b144b1703ab 100644 --- a/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v1_tests/recording_storagequeue_create_queue.json +++ b/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v1_tests/recording_storagequeue_create_queue.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://account_name.queue.core.windows.net/queue-1527?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", + "RequestUri": "https://account_name.queue.core.windows.net/queue-1836?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", "RequestMethod": "PUT", "RequestHeaders": { "Accept": "application/xml", @@ -9,6 +9,7 @@ "Accept-Language": "en-US", "Connection": "keep-alive", "Content-Length": "0", + "Origin": "http://localhost:9328", "Referer": "http://localhost:9328/", "sec-ch-ua": "", "sec-ch-ua-mobile": "?0", @@ -17,26 +18,28 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "c21186a7-d7e4-45bf-88aa-dd9b8cc38655", + "x-ms-client-request-id": "ed753236-f065-4292-912d-db14a14f03ab", "x-ms-version": "2020-10-02" }, "RequestBody": null, "StatusCode": 201, "ResponseHeaders": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Content-Length,Date,Transfer-Encoding", "Content-Length": "0", - "Date": "Thu, 09 Dec 2021 22:47:55 GMT", + "Date": "Tue, 09 Nov 2021 00:35:21 GMT", "Server": [ "Windows-Azure-Queue/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "c21186a7-d7e4-45bf-88aa-dd9b8cc38655", - "x-ms-request-id": "b7f17d39-0003-006e-564e-ed79ef000000", + "x-ms-client-request-id": "ed753236-f065-4292-912d-db14a14f03ab", + "x-ms-request-id": "2f6fe14f-4003-003e-0a01-d5d0dd000000", "x-ms-version": "2020-10-02" }, "ResponseBody": null } ], "Variables": { - "queue-name": "queue-1527" + "queue-name": "queue-1836" } } diff --git a/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v2_tests/recording_datatables_create_entity.json b/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v2_tests/recording_datatables_create_entity.json index c23e1fc16971..08cb5a28a034 100644 --- a/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v2_tests/recording_datatables_create_entity.json +++ b/sdk/test-utils/testing-recorder-new/recordings/browsers/core_v2_tests/recording_datatables_create_entity.json @@ -1,7 +1,7 @@ { "Entries": [ { - "RequestUri": "https://timovperftestplayground.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -11,6 +11,7 @@ "Content-Length": "25", "Content-Type": "application/json;odata=nometadata", "dataserviceversion": "3.0", + "Origin": "http://localhost:9328", "Referer": "http://localhost:9328/", "sec-ch-ua": "", "sec-ch-ua-mobile": "?0", @@ -19,35 +20,37 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "354dcb7b-541b-4182-a751-25b0e10d74d4", - "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", + "x-ms-client-request-id": "abacc0eb-947c-417e-954a-7ffc7eb177c2", + "x-ms-useragent": "azsdk-js-data-tables/12.2.0 core-rest-pipeline/1.3.3 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, "RequestBody": { - "TableName": "table1760" + "TableName": "table1099" }, "StatusCode": 201, "ResponseHeaders": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,X-Content-Type-Options,Cache-Control,Location,Content-Type,Content-Length,Date,Transfer-Encoding", "Cache-Control": "no-cache", "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Thu, 09 Dec 2021 22:47:55 GMT", - "Location": "https://timovperftestplayground.table.core.windows.net/Tables(\u0027table1760\u0027)", + "Date": "Tue, 09 Nov 2021 00:35:21 GMT", + "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1099\u0027)", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], "Transfer-Encoding": "chunked", - "x-ms-client-request-id": "354dcb7b-541b-4182-a751-25b0e10d74d4", - "x-ms-request-id": "fd439e64-7002-0064-4f4e-eddd58000000", + "x-ms-client-request-id": "abacc0eb-947c-417e-954a-7ffc7eb177c2", + "x-ms-request-id": "0fb4188a-0002-0010-6a01-d5501a000000", "x-ms-version": "2019-02-02" }, "ResponseBody": { - "odata.metadata": "https://timovperftestplayground.table.core.windows.net/$metadata#Tables/@Element", - "TableName": "table1760" + "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#Tables/@Element", + "TableName": "table1099" } }, { - "RequestUri": "https://timovperftestplayground.table.core.windows.net/table1760?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/table1099?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", "RequestHeaders": { "Accept": "application/json;odata=minimalmetadata", @@ -57,6 +60,7 @@ "Content-Length": "366", "Content-Type": "application/json;odata=nometadata", "dataserviceversion": "3.0", + "Origin": "http://localhost:9328", "prefer": "return-no-content", "Referer": "http://localhost:9328/", "sec-ch-ua": "", @@ -66,8 +70,8 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "27ba3bf7-fccd-4f32-8216-4b8c5a1b4800", - "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", + "x-ms-client-request-id": "4c8bce23-dac7-4910-b422-6d023fe1f84d", + "x-ms-useragent": "azsdk-js-data-tables/12.2.0 core-rest-pipeline/1.3.3 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, "RequestBody": { @@ -83,31 +87,34 @@ }, "StatusCode": 204, "ResponseHeaders": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,X-Content-Type-Options,Cache-Control,Preference-Applied,Location,DataServiceId,ETag,Content-Length,Date,Transfer-Encoding", "Cache-Control": "no-cache", "Content-Length": "0", - "DataServiceId": "https://timovperftestplayground.table.core.windows.net/table1760(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Date": "Thu, 09 Dec 2021 22:47:56 GMT", - "ETag": "W/\u0022datetime\u00272021-12-09T22%3A47%3A56.4498903Z\u0027\u0022", - "Location": "https://timovperftestplayground.table.core.windows.net/table1760(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1099(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", + "Date": "Tue, 09 Nov 2021 00:35:22 GMT", + "ETag": "W/\u0022datetime\u00272021-11-09T00%3A35%3A22.767648Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/table1099(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", "Preference-Applied": "return-no-content", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "27ba3bf7-fccd-4f32-8216-4b8c5a1b4800", - "x-ms-request-id": "fd439e79-7002-0064-624e-eddd58000000", + "x-ms-client-request-id": "4c8bce23-dac7-4910-b422-6d023fe1f84d", + "x-ms-request-id": "0fb4189c-0002-0010-7a01-d5501a000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null }, { - "RequestUri": "https://timovperftestplayground.table.core.windows.net/Tables(\u0027table1760\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1099\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "DELETE", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "en-US", "Connection": "keep-alive", + "Origin": "http://localhost:9328", "Referer": "http://localhost:9328/", "sec-ch-ua": "", "sec-ch-ua-mobile": "?0", @@ -116,28 +123,30 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "ace68096-3520-4ac0-a48e-b75ac7cf9ec0", - "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", + "x-ms-client-request-id": "48071f12-8913-4acc-b6f9-414d0b5df23a", + "x-ms-useragent": "azsdk-js-data-tables/12.2.0 core-rest-pipeline/1.3.3 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, "RequestBody": null, "StatusCode": 204, "ResponseHeaders": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,X-Content-Type-Options,Cache-Control,Content-Length,Date,Transfer-Encoding", "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Thu, 09 Dec 2021 22:47:56 GMT", + "Date": "Tue, 09 Nov 2021 00:35:22 GMT", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], - "x-ms-client-request-id": "ace68096-3520-4ac0-a48e-b75ac7cf9ec0", - "x-ms-request-id": "fd439e85-7002-0064-6e4e-eddd58000000", + "x-ms-client-request-id": "48071f12-8913-4acc-b6f9-414d0b5df23a", + "x-ms-request-id": "0fb418af-0002-0010-0b01-d5501a000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null } ], "Variables": { - "table-name": "table1760" + "table-name": "table1099" } } diff --git a/sdk/test-utils/testing-recorder-new/recordings/browsers/noop_credential_with_tables/recording_should_create_new_table_then_delete.json b/sdk/test-utils/testing-recorder-new/recordings/browsers/noop_credential_with_tables/recording_should_create_new_table_then_delete.json index 5eedf02b315b..60888ca95608 100644 --- a/sdk/test-utils/testing-recorder-new/recordings/browsers/noop_credential_with_tables/recording_should_create_new_table_then_delete.json +++ b/sdk/test-utils/testing-recorder-new/recordings/browsers/noop_credential_with_tables/recording_should_create_new_table_then_delete.json @@ -1,6 +1,95 @@ { - "Entries": [], + "Entries": [ + { + "RequestUri": "https://fakeaccount.table.core.windows.net/Tables", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Authorization": "Sanitized", + "Connection": "keep-alive", + "Content-Length": "25", + "Content-Type": "application/json;odata=nometadata", + "dataserviceversion": "3.0", + "prefer": "return-content", + "Referer": "http://localhost:9328/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", + "x-ms-client-request-id": "73505eb1-249a-4907-a923-31a56ecb6ab2", + "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "TableName": "table1678" + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Wed, 01 Dec 2021 03:33:59 GMT", + "Location": "https://fakeaccount.table.core.windows.net/Tables(\u0027table1678\u0027)", + "Preference-Applied": "return-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "73505eb1-249a-4907-a923-31a56ecb6ab2", + "x-ms-request-id": "f4a38afa-9002-0015-7164-e64326000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.metadata": "https://fakeaccount.table.core.windows.net/$metadata#Tables/@Element", + "TableName": "table1678" + } + }, + { + "RequestUri": "https://fakeaccount.table.core.windows.net/Tables(\u0027table1678\u0027)", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Authorization": "Sanitized", + "Connection": "keep-alive", + "Referer": "http://localhost:9328/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", + "x-ms-client-request-id": "4a1c3793-6746-42a4-9c4c-24957e49217d", + "x-ms-useragent": "azsdk-js-data-tables/12.1.2 core-rest-pipeline/1.3.2 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Wed, 01 Dec 2021 03:33:59 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "4a1c3793-6746-42a4-9c4c-24957e49217d", + "x-ms-request-id": "f4a38b1c-9002-0015-1164-e64326000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + } + ], "Variables": { - "table-name": "table1977" + "table-name": "table1678" } } From a3fb7cfa6d7181c9726a79bf40a436ced4e983f5 Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Tue, 14 Dec 2021 16:37:10 -0800 Subject: [PATCH 15/19] Remove the storage-queue/data-tables tests --- sdk/template/template/karma.conf.js | 4 +- sdk/template/template/package.json | 4 +- .../template/test/public/core-v1-test.spec.ts | 97 ------------------- .../template/test/public/core-v2-test.spec.ts | 71 -------------- sdk/template/template/test/utils/utils.ts | 20 ---- 5 files changed, 2 insertions(+), 194 deletions(-) delete mode 100644 sdk/template/template/test/public/core-v1-test.spec.ts delete mode 100644 sdk/template/template/test/public/core-v2-test.spec.ts delete mode 100644 sdk/template/template/test/utils/utils.ts diff --git a/sdk/template/template/karma.conf.js b/sdk/template/template/karma.conf.js index a7389edf7002..3fc81f97f738 100644 --- a/sdk/template/template/karma.conf.js +++ b/sdk/template/template/karma.conf.js @@ -62,9 +62,7 @@ module.exports = function(config) { "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET", "AZURE_TENANT_ID", - "TABLES_SAS_CONNECTION_STRING", - "RECORDINGS_RELATIVE_PATH", - "STORAGE_SAS_URL" + "RECORDINGS_RELATIVE_PATH" ], // test results reporter to use diff --git a/sdk/template/template/package.json b/sdk/template/template/package.json index 453de4c02975..4a6a14e66508 100644 --- a/sdk/template/template/package.json +++ b/sdk/template/template/package.json @@ -124,9 +124,7 @@ "typedoc": "0.15.2", "typescript": "~4.2.0", "util": "^0.12.1", - "@azure-tools/test-recorder-new": "~1.0.0", - "@azure/storage-queue": "~12.8.0-beta.2", - "@azure/data-tables": "~13.0.1" + "@azure-tools/test-recorder-new": "~1.0.0" }, "//sampleConfiguration": { "skipFolder": false, diff --git a/sdk/template/template/test/public/core-v1-test.spec.ts b/sdk/template/template/test/public/core-v1-test.spec.ts deleted file mode 100644 index 5c64658ff8af..000000000000 --- a/sdk/template/template/test/public/core-v1-test.spec.ts +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -// - -import { isPlaybackMode } from "@azure-tools/test-recorder"; -import { Context } from "mocha"; -import { QueueServiceClient } from "@azure/storage-queue"; -import { - TestProxyHttpClientCoreV1, - env, - RecorderStartOptions, - SanitizerOptions -} from "@azure-tools/test-recorder-new"; - -// This fake URL will be used in the recording. We use a general regex sanitizer -// (below) to replace the real SAS URL from when we record the test with this -// fake version. -const fakeSASUrl = - "https://account_name.queue.core.windows.net/?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2026-07-10T07:00:24Z&st=2021-07-09T23:00:24Z&spr=https&sig=fake_sig"; - -function getRecorderStartOptions(): RecorderStartOptions { - // These options are passed to the recorder for playback. - const envSetupForPlayback: Record = { - // In playback, we use the fake SAS URL instead of a real one which would have - // been provided via the .env file or otherwise. - STORAGE_SAS_URL: fakeSASUrl - }; - - let sanitizerOptions: SanitizerOptions | undefined; - - if (env.STORAGE_SAS_URL) { - const realSASParts = env.STORAGE_SAS_URL.split("/"); - const fakeSASParts = fakeSASUrl.split("/"); - - sanitizerOptions = { - // There are several different sanitzers that can be used. A general regex sanitizer - // allows for a simple find and replace based on a given regular expression. This is - // used here to strip out the sensitive and dynamic parts of the SAS URL in the recording, - // replacing them with their corresponding components from the fake SAS URL defined above. - generalRegexSanitizers: [ - // This one replaces the host portion of the URL, which is dynamic based on the storage account... - { - regex: realSASParts[2], - value: fakeSASParts[2] - }, - // ...and this one replaces the query string which contains sensitive information relating to - // the SAS token. - { - regex: realSASParts[3].split("?")[1], - value: fakeSASParts[3].split("?")[1] - } - ] - }; - } - - return { - envSetupForPlayback, - sanitizerOptions - }; -} - -describe("Core V1 tests using unified recorder", () => { - let recorder: TestProxyHttpClientCoreV1; - - // Note the use of function() instead of an arrow function. This is important - // since we pass `this.currentTest` to the client. - beforeEach(async function(this: Context) { - // Create an instance of recorder. We pass the current test as required by the client; - // this value is used to determine the recording's location. - recorder = new TestProxyHttpClientCoreV1(this.currentTest); - - // Configure the recorder and start it up prior to each test... - await recorder.start(getRecorderStartOptions()); - }); - - afterEach(async () => { - // ...and stop it when each test wraps up. - await recorder.stop(); - }); - - it("storage-queue create queue", async function() { - // Along with specifying the necessary parameters for the QueueServiceClient, we pass through - // the test proxy HTTP client, which mean that the client will use the recorder when making requests. - - const client = new QueueServiceClient(env.STORAGE_SAS_URL ?? "", undefined, { - httpClient: recorder - }); - - // Variables can be generated in record mode, and are stored with the recording to be reused - // in playback mode. - if (!isPlaybackMode()) { - recorder.variables["queue-name"] = `queue-${Math.ceil(Math.random() * 1000 + 1000)}`; - } - - await client.createQueue(recorder.variables["queue-name"]); - }); -}); diff --git a/sdk/template/template/test/public/core-v2-test.spec.ts b/sdk/template/template/test/public/core-v2-test.spec.ts deleted file mode 100644 index 9564ec6ca2d2..000000000000 --- a/sdk/template/template/test/public/core-v2-test.spec.ts +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { TableClient, TableEntity } from "@azure/data-tables"; -import { TestProxyHttpClient, recorderHttpPolicy } from "@azure-tools/test-recorder-new"; -import { isPlaybackMode, env } from "@azure-tools/test-recorder"; -import { Context } from "mocha"; -import { SanitizerOptions } from "@azure-tools/test-recorder-new"; -import { createSimpleEntity } from "../utils/utils"; - -// A fake connection string which replaces the actual connection string in the recording. -const fakeConnString = - "TableEndpoint=https://fakeaccountname.table.core.windows.net/;SharedAccessSignature=st=2021-08-03T08:52:15Z&spr=https&sig=fakesigval"; -const sanitizerOptions: SanitizerOptions = { - // We use a connection string sanitizer to remove the real connection string in the recording. - connectionStringSanitizers: [ - { - actualConnString: env.TABLES_SAS_CONNECTION_STRING, - fakeConnString - } - ], - // The removeHeaderSanitizer can be used to remove certain headers before saving a recording. - removeHeaderSanitizer: { headersForRemoval: ["X-Content-Type-Options"] } -}; - -const recorderOptions = { - envSetupForPlayback: { - TABLES_SAS_CONNECTION_STRING: fakeConnString - }, - sanitizerOptions -}; - -describe("Core V2 tests using unified recorder", () => { - let recorder: TestProxyHttpClient; - - // Note the use of function() instead of an arrow function. This is important - // since we pass `this.currentTest` to the client. - beforeEach(async function(this: Context) { - // Create an instance of recorder. We pass the current test as required by the client; - // this value is used to determine the recording's location. - recorder = new TestProxyHttpClient(this.currentTest); - - // Start the recorder using the options before each test. - await recorder.start(recorderOptions); - }); - - afterEach(async () => { - await recorder.stop(); - }); - - it("data-tables create entity", async function() { - // Variables can be generated in record mode, and are stored with the recording to be reused - // in playback mode. - if (!isPlaybackMode()) { - recorder.variables["table-name"] = `table${Math.ceil(Math.random() * 1000 + 1000)}`; - } - const client = TableClient.fromConnectionString( - env.TABLES_SAS_CONNECTION_STRING, - recorder.variables["table-name"] - ); - - // To set up the recorder with the core v2 pipeline, we add a HTTP policy which - // redirects requests to use the proxy tool recorder. - client.pipeline.addPolicy(recorderHttpPolicy(recorder)); - - await client.createTable(); - const simpleEntity: TableEntity = createSimpleEntity(); - await client.createEntity(simpleEntity); - await client.deleteTable(); - }); -}); diff --git a/sdk/template/template/test/utils/utils.ts b/sdk/template/template/test/utils/utils.ts deleted file mode 100644 index 9479b6d0621f..000000000000 --- a/sdk/template/template/test/utils/utils.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { TableEntity } from "@azure/data-tables"; - -const stringValue = "This is a string"; - -export function createSimpleEntity(): TableEntity { - return { - partitionKey: "simpleEntity", - rowKey: "03590009-4169-46ce-9e33-d011dbaf308c", // uuid(), - stringTypeProperty1: stringValue, - stringTypeProperty2: stringValue, - stringTypeProperty3: stringValue, - stringTypeProperty4: stringValue, - stringTypeProperty5: stringValue, - stringTypeProperty6: stringValue, - stringTypeProperty7: stringValue - }; -} From 6676616995204608c02304d7e5271289123a1776 Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Wed, 15 Dec 2021 10:42:59 -0800 Subject: [PATCH 16/19] Remove recordings we don't need any more --- .../recording_storagequeue_create_queue.json | 42 ----- .../recording_datatables_create_entity.json | 143 ------------------ .../recording_storagequeue_create_queue.json | 35 ----- .../recording_datatables_create_entity.json | 116 -------------- 4 files changed, 336 deletions(-) delete mode 100644 sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json delete mode 100644 sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json delete mode 100644 sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json delete mode 100644 sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json diff --git a/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json b/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json deleted file mode 100644 index af9ee26357c0..000000000000 --- a/sdk/template/template/recordings/browsers/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://account_name.queue.core.windows.net/queue-1326?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", - "RequestMethod": "PUT", - "RequestHeaders": { - "Accept": "application/xml", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "en-US", - "Connection": "keep-alive", - "Content-Length": "0", - "Referer": "http://localhost:9876/", - "sec-ch-ua": "", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Fetch-Site": "same-site", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "dbad8518-70bf-415e-add0-bafaeb9591c8", - "x-ms-version": "2020-12-06" - }, - "RequestBody": null, - "StatusCode": 201, - "ResponseHeaders": { - "Content-Length": "0", - "Date": "Fri, 10 Dec 2021 11:09:31 GMT", - "Server": [ - "Windows-Azure-Queue/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "x-ms-client-request-id": "dbad8518-70bf-415e-add0-bafaeb9591c8", - "x-ms-request-id": "39e9dcc7-1003-004b-7fb6-ed5766000000", - "x-ms-version": "2020-12-06" - }, - "ResponseBody": null - } - ], - "Variables": { - "queue-name": "queue-1326" - } -} diff --git a/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json b/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json deleted file mode 100644 index 3488562226b7..000000000000 --- a/sdk/template/template/recordings/browsers/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json;odata=minimalmetadata", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "en-US", - "Connection": "keep-alive", - "Content-Length": "25", - "Content-Type": "application/json;odata=nometadata", - "DataServiceVersion": "3.0", - "Referer": "http://localhost:9876/", - "sec-ch-ua": "", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Fetch-Site": "same-site", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "e248395e-2039-4985-82b8-1966333e3a55", - "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", - "x-ms-version": "2019-02-02" - }, - "RequestBody": { - "TableName": "table1891" - }, - "StatusCode": 201, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Fri, 10 Dec 2021 11:09:32 GMT", - "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1891\u0027)", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "Transfer-Encoding": "chunked", - "x-ms-client-request-id": "e248395e-2039-4985-82b8-1966333e3a55", - "x-ms-request-id": "53bdc585-1002-004b-4bb6-ed5766000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": { - "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#Tables/@Element", - "TableName": "table1891" - } - }, - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/table1891?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json;odata=minimalmetadata", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "en-US", - "Connection": "keep-alive", - "Content-Length": "366", - "Content-Type": "application/json;odata=nometadata", - "DataServiceVersion": "3.0", - "Prefer": "return-no-content", - "Referer": "http://localhost:9876/", - "sec-ch-ua": "", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Fetch-Site": "same-site", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "483bcdfe-ed56-442d-b747-01efa4ad9d38", - "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", - "x-ms-version": "2019-02-02" - }, - "RequestBody": { - "PartitionKey": "simpleEntity", - "RowKey": "03590009-4169-46ce-9e33-d011dbaf308c", - "stringTypeProperty1": "This is a string", - "stringTypeProperty2": "This is a string", - "stringTypeProperty3": "This is a string", - "stringTypeProperty4": "This is a string", - "stringTypeProperty5": "This is a string", - "stringTypeProperty6": "This is a string", - "stringTypeProperty7": "This is a string" - }, - "StatusCode": 204, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "0", - "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1891(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Date": "Fri, 10 Dec 2021 11:09:32 GMT", - "ETag": "W/\u0022datetime\u00272021-12-10T11%3A09%3A32.9281617Z\u0027\u0022", - "Location": "https://fakeaccountname.table.core.windows.net/table1891(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Preference-Applied": "return-no-content", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "x-ms-client-request-id": "483bcdfe-ed56-442d-b747-01efa4ad9d38", - "x-ms-request-id": "53bdc5a3-1002-004b-66b6-ed5766000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": null - }, - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1891\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "DELETE", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "en-US", - "Connection": "keep-alive", - "Referer": "http://localhost:9876/", - "sec-ch-ua": "", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Fetch-Site": "same-site", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/93.0.4577.0 Safari/537.36", - "x-ms-client-request-id": "bc134a07-fb02-4ed0-b66d-bd8e24f3596c", - "x-ms-useragent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 OS/Linuxx86_64", - "x-ms-version": "2019-02-02" - }, - "RequestBody": null, - "StatusCode": 204, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "0", - "Date": "Fri, 10 Dec 2021 11:09:32 GMT", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "x-ms-client-request-id": "bc134a07-fb02-4ed0-b66d-bd8e24f3596c", - "x-ms-request-id": "53bdc5c5-1002-004b-05b6-ed5766000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": null - } - ], - "Variables": { - "table-name": "table1891" - } -} diff --git a/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json b/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json deleted file mode 100644 index 7d284ab95e78..000000000000 --- a/sdk/template/template/recordings/node/core_v1_tests_using_unified_recorder/recording_storagequeue_create_queue.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://account_name.queue.core.windows.net/queue-1688?sv=2020-08-04\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacuptfx\u0026se=2026-07-10T07:00:24Z\u0026st=2021-07-09T23:00:24Z\u0026spr=https\u0026sig=fake_sig\u0026timeout=30", - "RequestMethod": "PUT", - "RequestHeaders": { - "Accept": "application/xml", - "Accept-Encoding": "gzip,deflate", - "Connection": "keep-alive", - "Content-Length": "0", - "Cookie": "", - "User-Agent": "azsdk-js-storagequeue/12.8.0-beta.2 (NODE-VERSION v16.13.0; Linux 5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "a5109e66-067d-42d9-a07e-896282f4b170", - "x-ms-version": "2020-12-06" - }, - "RequestBody": null, - "StatusCode": 201, - "ResponseHeaders": { - "Content-Length": "0", - "Date": "Thu, 09 Dec 2021 01:06:27 GMT", - "Server": [ - "Windows-Azure-Queue/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "x-ms-client-request-id": "a5109e66-067d-42d9-a07e-896282f4b170", - "x-ms-request-id": "041ed824-d003-006d-6398-ec988b000000", - "x-ms-version": "2020-12-06" - }, - "ResponseBody": null - } - ], - "Variables": { - "queue-name": "queue-1688" - } -} diff --git a/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json b/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json deleted file mode 100644 index 241374b703f5..000000000000 --- a/sdk/template/template/recordings/node/core_v2_tests_using_unified_recorder/recording_datatables_create_entity.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json;odata=minimalmetadata", - "Accept-Encoding": "gzip,deflate", - "Connection": "keep-alive", - "Content-Length": "25", - "Content-Type": "application/json;odata=nometadata", - "DataServiceVersion": "3.0", - "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "988d7b28-fa5f-48a1-8556-c20f1c71ba1f", - "x-ms-version": "2019-02-02" - }, - "RequestBody": { - "TableName": "table1213" - }, - "StatusCode": 201, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Thu, 09 Dec 2021 01:06:28 GMT", - "Location": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1213\u0027)", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "Transfer-Encoding": "chunked", - "x-ms-client-request-id": "988d7b28-fa5f-48a1-8556-c20f1c71ba1f", - "x-ms-request-id": "78b87427-8002-004f-7f98-ec5d94000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": { - "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#Tables/@Element", - "TableName": "table1213" - } - }, - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/table1213?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json;odata=minimalmetadata", - "Accept-Encoding": "gzip,deflate", - "Connection": "keep-alive", - "Content-Length": "366", - "Content-Type": "application/json;odata=nometadata", - "DataServiceVersion": "3.0", - "Prefer": "return-no-content", - "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "1e6dc024-14cd-4371-bf49-bb2063de2eb2", - "x-ms-version": "2019-02-02" - }, - "RequestBody": { - "PartitionKey": "simpleEntity", - "RowKey": "03590009-4169-46ce-9e33-d011dbaf308c", - "stringTypeProperty1": "This is a string", - "stringTypeProperty2": "This is a string", - "stringTypeProperty3": "This is a string", - "stringTypeProperty4": "This is a string", - "stringTypeProperty5": "This is a string", - "stringTypeProperty6": "This is a string", - "stringTypeProperty7": "This is a string" - }, - "StatusCode": 204, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "0", - "DataServiceId": "https://fakeaccountname.table.core.windows.net/table1213(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Date": "Thu, 09 Dec 2021 01:06:28 GMT", - "ETag": "W/\u0022datetime\u00272021-12-09T01%3A06%3A28.8513848Z\u0027\u0022", - "Location": "https://fakeaccountname.table.core.windows.net/table1213(PartitionKey=\u0027simpleEntity\u0027,RowKey=\u002703590009-4169-46ce-9e33-d011dbaf308c\u0027)", - "Preference-Applied": "return-no-content", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "x-ms-client-request-id": "1e6dc024-14cd-4371-bf49-bb2063de2eb2", - "x-ms-request-id": "78b87437-8002-004f-0b98-ec5d94000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": null - }, - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027table1213\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "DELETE", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "Connection": "keep-alive", - "User-Agent": "azsdk-js-data-tables/13.0.1 core-rest-pipeline/1.3.3 Node/v16.13.0 OS/(x64-Linux-5.10.60.1-microsoft-standard-WSL2)", - "x-ms-client-request-id": "154df0c4-5aa4-42f1-8d44-d439e48dcb36", - "x-ms-version": "2019-02-02" - }, - "RequestBody": null, - "StatusCode": 204, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "0", - "Date": "Thu, 09 Dec 2021 01:06:28 GMT", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "x-ms-client-request-id": "154df0c4-5aa4-42f1-8d44-d439e48dcb36", - "x-ms-request-id": "78b87441-8002-004f-1598-ec5d94000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": null - } - ], - "Variables": { - "table-name": "table1213" - } -} From 52ab72bc5e9d5542fe39c7e755a1097e9a1029eb Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Tue, 21 Dec 2021 10:01:48 -0800 Subject: [PATCH 17/19] Updates to template based on new refactor --- sdk/template/template/package.json | 3 +- .../test/public/configurationClient.spec.ts | 42 +++++++++---------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/sdk/template/template/package.json b/sdk/template/template/package.json index 0b64cee6ddb5..cdb746ac808b 100644 --- a/sdk/template/template/package.json +++ b/sdk/template/template/package.json @@ -122,7 +122,8 @@ "source-map-support": "^0.5.9", "typescript": "~4.2.0", "util": "^0.12.1", - "@azure-tools/test-recorder-new": "~1.0.0" + "@azure-tools/test-recorder-new": "~1.0.0", + "@azure-tools/test-credential": "~1.0.0" }, "//sampleConfiguration": { "skipFolder": false, diff --git a/sdk/template/template/test/public/configurationClient.spec.ts b/sdk/template/template/test/public/configurationClient.spec.ts index b9e306b30f2d..63f97011e6c3 100644 --- a/sdk/template/template/test/public/configurationClient.spec.ts +++ b/sdk/template/template/test/public/configurationClient.spec.ts @@ -6,10 +6,9 @@ import { Context } from "mocha"; import { ConfigurationClient } from "../../src"; -import { isPlaybackMode, env } from "@azure-tools/test-recorder"; -import { NoOpCredential, TestProxyHttpClientCoreV1 } from "@azure-tools/test-recorder-new"; -import { TokenCredential } from "@azure/core-http"; -import { ClientSecretCredential } from "@azure/identity"; +import { env } from "@azure-tools/test-recorder"; +import { Recorder } from "@azure-tools/test-recorder-new"; +import { createTestCredential } from "@azure-tools/test-credential"; // When the recorder observes the values of these environment variables in any // recorded HTTP request or response, it will replace them with the values they @@ -23,27 +22,24 @@ const replaceableVariables: Record = { AZURE_CLIENT_SECRET: "azure_client_secret" }; -function createConfigurationClient(recorder: TestProxyHttpClientCoreV1): ConfigurationClient { +function createConfigurationClient(recorder: Recorder): ConfigurationClient { // Retrieve the endpoint from the environment variable // we saved to the .env file earlier const endpoint = env.APPCONFIG_ENDPOINT; - // We use ClientSecretCredential instead of DefaultAzureCredential in order - // to ensure that the requests made to the AAD server are always the same. If - // we used DefaultAzureCredential, they might be different on some machines - // than on others, depending on which credentials are available (such as - // Managed Identity or developer credentials). - let credential: TokenCredential; - if (isPlaybackMode()) { - credential = new NoOpCredential(); - } else { - credential = new ClientSecretCredential( - env.AZURE_TENANT_ID, - env.AZURE_CLIENT_ID, - env.AZURE_CLIENT_SECRET - ); - } - return new ConfigurationClient(endpoint, credential, { httpClient: recorder }); + // We use the createTestCredential helper from the test-credential tools package. + // This function returns the special NoOpCredential in playback mode, which + // is a special TokenCredential implementation that does not make any requests + // to AAD. + + // recorder.configureClientOptionsCoreV1 mixes in the necessary options that + // need to be passed to the corev1 ConfigurationClient for the recorder to + // capture requests. + return new ConfigurationClient( + endpoint, + createTestCredential(), + recorder.configureClientOptionsCoreV1({}) + ); } // You want to give the test suite a descriptive name. Here, I add [AAD] to @@ -53,7 +49,7 @@ describe("[AAD] ConfigurationClient functional tests", function() { // Declare the client and recorder instances. We will set them using the // beforeEach hook. let client: ConfigurationClient; - let recorder: TestProxyHttpClientCoreV1; + let recorder: Recorder; // NOTE: use of "function" and not ES6 arrow-style functions with the // beforeEach hook is IMPORTANT due to the use of `this` in the function @@ -62,7 +58,7 @@ describe("[AAD] ConfigurationClient functional tests", function() { // The recorder has some convenience methods, and we need to store a // reference to it so that we can `stop()` the recorder later in the // `afterEach` hook. - recorder = new TestProxyHttpClientCoreV1(this.currentTest); + recorder = new Recorder(this.currentTest); await recorder.start({ envSetupForPlayback: replaceableVariables }); From 9239f0d453863ecabf4bff433ed5bb152c4769ce Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Wed, 22 Dec 2021 10:52:05 -0800 Subject: [PATCH 18/19] New syntax for dev-tool run --- sdk/template/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/template/template/package.json b/sdk/template/template/package.json index cdb746ac808b..eda5285998b6 100644 --- a/sdk/template/template/package.json +++ b/sdk/template/template/package.json @@ -39,7 +39,7 @@ "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", "generate:client": "autorest --typescript ./swagger/README.md", "integration-test:browser": "dev-tool run test:browser", - "integration-test:node": "dev-tool run test:node-ts-input --mocha=\"--timeout 1200000 'test/**/*.spec.ts'\"", + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/**/*.spec.ts'", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", "lint": "eslint package.json api-extractor.json src test --ext .ts", From c30f41997419b1e1ec60fdc1349f9f0730fca00c Mon Sep 17 00:00:00 2001 From: Timo van Veenendaal Date: Tue, 4 Jan 2022 11:57:28 -0800 Subject: [PATCH 19/19] Formatting --- sdk/template/template/karma.conf.js | 33 ++++++++++--------- .../template/src/configurationClient.ts | 16 ++++----- .../test/public/configurationClient.spec.ts | 8 ++--- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/sdk/template/template/karma.conf.js b/sdk/template/template/karma.conf.js index 3fc81f97f738..30b25eb3ebe8 100644 --- a/sdk/template/template/karma.conf.js +++ b/sdk/template/template/karma.conf.js @@ -3,16 +3,17 @@ // https://github.com/karma-runner/karma-chrome-launcher process.env.CHROME_BIN = require("puppeteer").executablePath(); -process.env.RECORDINGS_RELATIVE_PATH = require("@azure-tools/test-recorder-new").relativeRecordingsPath(); +process.env.RECORDINGS_RELATIVE_PATH = + require("@azure-tools/test-recorder-new").relativeRecordingsPath(); require("dotenv").config(); const { jsonRecordingFilterFunction, isPlaybackMode, isSoftRecordMode, - isRecordMode + isRecordMode, } = require("@azure-tools/test-recorder"); -module.exports = function(config) { +module.exports = function (config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "./", @@ -32,13 +33,13 @@ module.exports = function(config) { "karma-coverage", "karma-junit-reporter", "karma-json-to-file-reporter", - "karma-json-preprocessor" + "karma-json-preprocessor", ], // list of files / patterns to load in the browser files: [ "dist-test/index.browser.js", - { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true } + { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true }, ].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []), // list of files / patterns to exclude @@ -48,7 +49,7 @@ module.exports = function(config) { // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { "**/*.js": ["env"], - "recordings/browsers/**/*.json": ["json"] + "recordings/browsers/**/*.json": ["json"], // IMPORTANT: COMMENT following line if you want to debug in your browsers!! // Preprocess source file to calculate code coverage, however this will make source file unreadable //"dist-test/index.browser.js": ["coverage"] @@ -62,7 +63,7 @@ module.exports = function(config) { "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET", "AZURE_TENANT_ID", - "RECORDINGS_RELATIVE_PATH" + "RECORDINGS_RELATIVE_PATH", ], // test results reporter to use @@ -73,7 +74,7 @@ module.exports = function(config) { coverageReporter: { // specify a common output directory dir: "coverage-browser/", - reporters: [{ type: "json", subdir: ".", file: "coverage.json" }] + reporters: [{ type: "json", subdir: ".", file: "coverage.json" }], }, junitReporter: { @@ -83,12 +84,12 @@ module.exports = function(config) { useBrowserName: false, // add browser name to report and classes names nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element - properties: {} // key value pair of properties to add to the section of the report + properties: {}, // key value pair of properties to add to the section of the report }, jsonToFileReporter: { filter: jsonRecordingFilterFunction, - outputPath: "." + outputPath: ".", }, // web server port @@ -110,8 +111,8 @@ module.exports = function(config) { customLaunchers: { ChromeHeadlessNoSandbox: { base: "ChromeHeadless", - flags: ["--no-sandbox", "--disable-web-security"] - } + flags: ["--no-sandbox", "--disable-web-security"], + }, }, // Continuous Integration mode @@ -126,15 +127,15 @@ module.exports = function(config) { browserDisconnectTimeout: 10000, browserDisconnectTolerance: 3, browserConsoleLogOptions: { - terminal: !isRecordMode() + terminal: !isRecordMode(), }, client: { mocha: { // change Karma's debug.html to the mocha web reporter reporter: "html", - timeout: "600000" - } - } + timeout: "600000", + }, + }, }); }; diff --git a/sdk/template/template/src/configurationClient.ts b/sdk/template/template/src/configurationClient.ts index 4c0b44cc3035..0a8f3ca1ca9d 100644 --- a/sdk/template/template/src/configurationClient.ts +++ b/sdk/template/template/src/configurationClient.ts @@ -8,7 +8,7 @@ import { PipelineOptions, TokenCredential, bearerTokenAuthenticationPolicy, - createPipelineFromOptions + createPipelineFromOptions, } from "@azure/core-http"; import { SDK_VERSION } from "./constants"; import { SpanStatusCode } from "@azure/core-tracing"; @@ -93,18 +93,18 @@ export class ConfigurationClient { "application/vnd.microsoft.appconfig.kv+json", "application/vnd.microsoft.appconfig.kvs+json", "application/vnd.microsoft.appconfig.keyset+json", - "application/vnd.microsoft.appconfig.revs+json" - ] - } + "application/vnd.microsoft.appconfig.revs+json", + ], + }, }, ...{ loggingOptions: { logger: logger.info, // This array contains header names we want to log that are not already // included as safe. Unknown/unsafe headers are logged as "". - allowedHeaderNames: ["x-ms-correlation-request-id"] - } - } + allowedHeaderNames: ["x-ms-correlation-request-id"], + }, + }, }; const pipeline = createPipelineFromOptions(internalPipelineOptions, authPolicy); @@ -165,7 +165,7 @@ export class ConfigurationClient { try { const result = await this.client.getKeyValue(key, { ...updatedOptions, - ifNoneMatch + ifNoneMatch, }); return result; } catch (e) { diff --git a/sdk/template/template/test/public/configurationClient.spec.ts b/sdk/template/template/test/public/configurationClient.spec.ts index 63f97011e6c3..7f57f2f161b9 100644 --- a/sdk/template/template/test/public/configurationClient.spec.ts +++ b/sdk/template/template/test/public/configurationClient.spec.ts @@ -19,7 +19,7 @@ const replaceableVariables: Record = { APPCONFIG_TEST_SETTING_EXPECTED_VALUE: "test-value", AZURE_TENANT_ID: "12345678-1234-1234-1234-123456789012", AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret" + AZURE_CLIENT_SECRET: "azure_client_secret", }; function createConfigurationClient(recorder: Recorder): ConfigurationClient { @@ -45,7 +45,7 @@ function createConfigurationClient(recorder: Recorder): ConfigurationClient { // You want to give the test suite a descriptive name. Here, I add [AAD] to // indicate that the tests are authenticating with the service using Azure // Active Directory. -describe("[AAD] ConfigurationClient functional tests", function() { +describe("[AAD] ConfigurationClient functional tests", function () { // Declare the client and recorder instances. We will set them using the // beforeEach hook. let client: ConfigurationClient; @@ -54,7 +54,7 @@ describe("[AAD] ConfigurationClient functional tests", function() { // NOTE: use of "function" and not ES6 arrow-style functions with the // beforeEach hook is IMPORTANT due to the use of `this` in the function // body. - beforeEach(async function(this: Context) { + beforeEach(async function (this: Context) { // The recorder has some convenience methods, and we need to store a // reference to it so that we can `stop()` the recorder later in the // `afterEach` hook. @@ -68,7 +68,7 @@ describe("[AAD] ConfigurationClient functional tests", function() { }); // After each test, we need to stop the recording. - afterEach(async function() { + afterEach(async function () { await recorder.stop(); });