diff --git a/sdk/synapse/synapse-managed-private-endpoints/karma.conf.js b/sdk/synapse/synapse-managed-private-endpoints/karma.conf.js index e93dbd46c059..b4040ae0a4ca 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/karma.conf.js +++ b/sdk/synapse/synapse-managed-private-endpoints/karma.conf.js @@ -4,12 +4,8 @@ // https://github.com/karma-runner/karma-chrome-launcher process.env.CHROME_BIN = require("puppeteer").executablePath(); require("dotenv").config(); -const { - jsonRecordingFilterFunction, - isPlaybackMode, - isSoftRecordMode, - isRecordMode -} = require("@azure-tools/test-recorder"); +const { relativeRecordingsPath } = require("@azure-tools/test-recorder"); +process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath(); module.exports = function(config) { config.set({ @@ -31,16 +27,14 @@ module.exports = function(config) { "karma-coverage", "karma-sourcemap-loader", "karma-junit-reporter", - "karma-json-to-file-reporter", - "karma-source-map-support", - "karma-json-preprocessor" + "karma-source-map-support" ], // 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 } - ].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []), + ], // list of files / patterns to exclude exclude: [], @@ -48,8 +42,7 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - "**/*.js": ["sourcemap", "env"], - "recordings/browsers/**/*.json": ["json"] + "**/*.js": ["sourcemap", "env"] // 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.js": ["coverage"] @@ -60,13 +53,14 @@ module.exports = function(config) { "ENDPOINT", "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET", - "AZURE_TENANT_ID" + "AZURE_TENANT_ID", + "RECORDINGS_RELATIVE_PATH", ], // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ["mocha", "coverage", "junit", "json-to-file"], + reporters: ["mocha", "coverage", "junit"], coverageReporter: { // specify a common output directory @@ -89,11 +83,6 @@ module.exports = function(config) { properties: {} // key value pair of properties to add to the section of the report }, - jsonToFileReporter: { - filter: jsonRecordingFilterFunction, - outputPath: "." - }, - // web server port port: 9876, @@ -128,9 +117,6 @@ module.exports = function(config) { browserNoActivityTimeout: 60000000, browserDisconnectTimeout: 10000, browserDisconnectTolerance: 3, - browserConsoleLogOptions: { - terminal: !isRecordMode() - }, client: { mocha: { diff --git a/sdk/synapse/synapse-managed-private-endpoints/package.json b/sdk/synapse/synapse-managed-private-endpoints/package.json index 6bf9639248c5..08c3e2ee3ecb 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/package.json +++ b/sdk/synapse/synapse-managed-private-endpoints/package.json @@ -45,9 +45,9 @@ "module": "./dist-esm/src/index.js", "types": "./types/synapse-managed-private-endpoints.d.ts", "devDependencies": { - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-credential": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", "@azure/test-utils": "^1.0.0", - "@azure/identity": "^2.0.1", "typescript": "~4.8.0", "eslint": "^8.0.0", "@azure/eslint-plugin-azure-sdk": "^3.0.0", @@ -77,8 +77,6 @@ "chai-as-promised": "^7.1.1", "cross-env": "^7.0.2", "karma-edge-launcher": "^0.4.2", - "karma-json-preprocessor": "^0.3.3", - "karma-json-to-file-reporter": "^1.0.1", "karma-source-map-support": "~1.4.0" }, "bugs": { @@ -108,8 +106,8 @@ "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", "test:node": "npm run clean && npm run build:test && npm run unit-test:node", "test": "npm run clean && npm run build:test && npm run unit-test", - "unit-test:browser": "karma start --single-run", - "unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"", + "unit-test:browser": "dev-tool run test:browser", + "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "extract-api": "api-extractor run --local", "clean": "rimraf dist dist-* temp types *.tgz *.log", diff --git a/sdk/synapse/synapse-managed-private-endpoints/recordings/browsers/synapse_managed_private_endpoints/recording_should_list_endpoints.json b/sdk/synapse/synapse-managed-private-endpoints/recordings/browsers/synapse_managed_private_endpoints/recording_should_list_endpoints.json index 24defdf3cd32..114d4a8b0c9f 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/recordings/browsers/synapse_managed_private_endpoints/recording_should_list_endpoints.json +++ b/sdk/synapse/synapse-managed-private-endpoints/recordings/browsers/synapse_managed_private_endpoints/recording_should_list_endpoints.json @@ -1,51 +1,100 @@ { - "recordings": [ - { - "method": "POST", - "url": "https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/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%2Fsanitized%2F", - "status": 200, - "response": "{\"token_type\":\"Bearer\",\"expires_in\":86399,\"ext_expires_in\":86399,\"access_token\":\"access_token\"}", - "responseHeaders": { - "cache-control": "no-store, no-cache", - "content-length": "1322", - "content-type": "application/json; charset=utf-8", - "date": "Tue, 07 Sep 2021 19:30:46 GMT", - "expires": "-1", - "nel": "{\"report_to\":\"network-errors\",\"max_age\":86400,\"success_fraction\":0.001,\"failure_fraction\":1.0}", - "p3p": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"", - "pragma": "no-cache", - "referrer-policy": "strict-origin-when-cross-origin", - "report-to": "{\"group\":\"network-errors\",\"max_age\":86400,\"endpoints\":[{\"url\":\"https://identity.nel.measure.office.net/api/report?catId=GW+estsfd+bno\"}]}", - "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-content-type-options": "nosniff", - "x-ms-ests-server": "2.1.12025.12 - SCUS ProdSlices", - "x-ms-request-id": "50acb96a-18bc-4cdc-8d8a-383d9003ee00" - } - }, - { - "method": "GET", - "url": "https://testaccount.dev.azuresynapse.net/managedVirtualNetworks/default/managedPrivateEndpoints", - "query": { - "api-version": "2020-12-01" - }, - "requestBody": null, - "status": 200, - "response": "{\"value\":[{\"name\":\"synapse-ws-sql--synapse-test-vnet\",\"id\":\"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/xiangyan/providers/Microsoft.Synapse/workspaces/synapse-test-vnet/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sql--synapse-test-vnet\",\"type\":\"Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints\",\"properties\":{\"privateLinkResourceId\":\"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/xiangyan/providers/Microsoft.Synapse/workspaces/synapse-test-vnet\",\"groupId\":\"sql\",\"provisioningState\":\"Succeeded\",\"connectionState\":{\"status\":\"Approved\",\"description\":\"Approved by Microsoft.Synapse Resource Provider\",\"actionsRequired\":\"\"},\"isReserved\":true,\"fqdns\":[\"synapse-test-vnet.31a8e776-91cd-482c-a26a-6f05d478d273.sql.azuresynapse.net\"],\"isCompliant\":false}},{\"name\":\"synapse-ws-sqlOnDemand--synapse-test-vnet\",\"id\":\"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/xiangyan/providers/Microsoft.Synapse/workspaces/synapse-test-vnet/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sqlOnDemand--synapse-test-vnet\",\"type\":\"Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints\",\"properties\":{\"privateLinkResourceId\":\"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/xiangyan/providers/Microsoft.Synapse/workspaces/synapse-test-vnet\",\"groupId\":\"sqlOnDemand\",\"provisioningState\":\"Succeeded\",\"connectionState\":{\"status\":\"Approved\",\"description\":\"Approved by Microsoft.Synapse Resource Provider\",\"actionsRequired\":\"\"},\"isReserved\":true,\"fqdns\":[\"synapse-test-vnet-ondemand.31a8e776-91cd-482c-a26a-6f05d478d273.sql.azuresynapse.net\"],\"isCompliant\":false}}]}", - "responseHeaders": { - "content-length": "1708", - "content-type": "application/json; charset=utf-8", - "date": "Tue, 07 Sep 2021 19:30:46 GMT", - "server": "Microsoft-HTTPAPI/2.0", - "strict-transport-security": "max-age=31536000; includeSubDomains", - "x-ms-request-id": "eb4d3d64-d9cc-4888-baa5-52ad0e39b50e" - } - } - ], - "uniqueTestInfo": { - "uniqueName": {}, - "newDate": {} - }, - "hash": "0126c817a63f3e2820509373698ac737" -} \ No newline at end of file + "Entries": [ + { + "RequestUri": "https://testaccount.dev.azuresynapse.net/managedVirtualNetworks/default/managedPrivateEndpoints?api-version=2020-12-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/109.0.5412.0 Safari/537.36", + "x-ms-client-request-id": "19ef46b0-6d89-4cf7-b827-3a4ca3ed0e78", + "x-ms-useragent": "azsdk-js-synapse-managed-private-endpoints/1.0.0-beta.6 core-rest-pipeline/1.10.2 OS/Win32" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "2465", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 13 Jan 2023 17:41:55 GMT", + "Server": "Microsoft-HTTPAPI/2.0", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "6a1c8a51-b7f2-47e1-9aca-1c24ffc3b7d9" + }, + "ResponseBody": { + "value": [ + { + "name": "synapse-ws-sql--minhanhphan", + "id": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sql--minhanhphan", + "type": "Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints", + "properties": { + "privateLinkResourceId": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan", + "groupId": "sql", + "provisioningState": "Succeeded", + "connectionState": { + "status": "Approved", + "description": "Approved by Microsoft.Synapse Resource Provider", + "actionsRequired": "" + }, + "isReserved": true, + "fqdns": [ + "minhanhphan.8f6087d5-a969-4908-977e-817573a6b15b.sql.azuresynapse.net" + ], + "isCompliant": false + } + }, + { + "name": "synapse-ws-custstgacct--minhanhphan-minhanhphan", + "id": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-custstgacct--minhanhphan-minhanhphan", + "type": "Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints", + "properties": { + "privateLinkResourceId": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Storage/storageAccounts/minhanhphan", + "groupId": "dfs", + "provisioningState": "Succeeded", + "connectionState": { + "status": "Approved", + "description": "Auto-Approved", + "actionsRequired": "None" + }, + "isReserved": false, + "fqdns": [ + "minhanhphan.dfs.core.windows.net" + ], + "isCompliant": false + } + }, + { + "name": "synapse-ws-sqlOnDemand--minhanhphan", + "id": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sqlOnDemand--minhanhphan", + "type": "Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints", + "properties": { + "privateLinkResourceId": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan", + "groupId": "sqlOnDemand", + "provisioningState": "Succeeded", + "connectionState": { + "status": "Approved", + "description": "Approved by Microsoft.Synapse Resource Provider", + "actionsRequired": "" + }, + "isReserved": true, + "fqdns": [ + "minhanhphan-ondemand.8f6087d5-a969-4908-977e-817573a6b15b.sql.azuresynapse.net" + ], + "isCompliant": false + } + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/synapse/synapse-managed-private-endpoints/recordings/node/synapse_managed_private_endpoints/recording_should_list_endpoints.js b/sdk/synapse/synapse-managed-private-endpoints/recordings/node/synapse_managed_private_endpoints/recording_should_list_endpoints.js deleted file mode 100644 index 08bbe5325e67..000000000000 --- a/sdk/synapse/synapse-managed-private-endpoints/recordings/node/synapse_managed_private_endpoints/recording_should_list_endpoints.js +++ /dev/null @@ -1,129 +0,0 @@ -let nock = require('nock'); - -module.exports.hash = "0010dc7db46eede5dad80db7c5799fdc"; - -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/88888888-8888-8888-8888-888888888888/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', - '42845562-fcc7-4559-8f74-51f73de92501', - 'x-ms-ests-server', - '2.1.12011.8 - NCUS ProdSlices', - 'Set-Cookie', - 'fpc=AvhAR0541wxLhc89DT853p8; expires=Thu, 07-Oct-2021 19:30:37 GMT; path=/; secure; HttpOnly; SameSite=None', - 'Set-Cookie', - 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrHoNEznYN7Z2A0qkLrgZ1viF7gZPxJDwfSc9c4_UlBQxmIkaIep1YXYTbGzcHsS_ExP7fI8bnCFj2sd9GXIPrUj26ZGlWJgfhwZRU0l4Q0FcxcKEpnPCzREEmdBj-wUHqh6ylFzcuRg-8qHscT9uSiV5F-9olAU1t_iCRfIR-MNggAA; 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', - 'Tue, 07 Sep 2021 19:30:37 GMT', - 'Content-Length', - '980' -]); - -nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) - .get('/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration') - .reply(200, {"token_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt","client_secret_basic"],"jwks_uri":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/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/88888888-8888-8888-8888-888888888888/v2.0","request_uri_parameter_supported":false,"userinfo_endpoint":"https://graph.microsoft.com/oidc/userinfo","authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/authorize","device_authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/devicecode","http_logout_supported":true,"frontchannel_logout_supported":true,"end_session_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/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/88888888-8888-8888-8888-888888888888/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', - 'f0b92ad8-7fe6-41e1-a862-e59bf12ff100', - 'x-ms-ests-server', - '2.1.12025.12 - SCUS ProdSlices', - 'Set-Cookie', - 'fpc=AkBz_HWShUhAoKrRKcVNtjk; expires=Thu, 07-Oct-2021 19:30:38 GMT; path=/; secure; HttpOnly; SameSite=None', - 'Set-Cookie', - 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7Wevrbv-fZXqaHBSHnpjeCQabzVpnVVD69b3CVdpKqkLH3KNk8kZBWHBgBxWq8I8YuWjB2ovKlj37Dg4UO-GpDBZ-2JEhYq1fjkGE-zuFmeWros99_8hUqDSynymFUymjNwTt0LBqSXEwNS26F-JzCddViGQb_vmOPMa61MVFbINAML4gAA; 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', - 'Tue, 07 Sep 2021 19:30:37 GMT', - 'Content-Length', - '1753' -]); - -nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) - .post('/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token', "client_id=azure_client_id&scope=https%3A%2F%2Fsanitized%2F&grant_type=client_credentials&x-client-SKU=msal.js.node&x-client-VER=1.3.0&x-client-OS=linux&x-client-CPU=x64&x-ms-lib-capability=retry-after, h429&x-client-current-telemetry=5|771,2,,,|,&x-client-last-telemetry=5|0|||0,0&client-request-id=e68dbd7e-7924-4110-ae45-d55cf12bd10e&client_secret=azure_client_secret&claims=%7B%22access_token%22%3A%7B%22xms_cc%22%3A%7B%22values%22%3A%5B%22CP1%22%5D%7D%7D%7D") - .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', - '71c9ac57-2e09-46cf-9f5e-cf1cfa06f100', - 'x-ms-ests-server', - '2.1.12025.12 - EUS ProdSlices', - 'x-ms-clitelem', - '1,0,0,,', - 'Set-Cookie', - 'fpc=AjjHYisth5hCrmP7I9o8GonKOuyWAQAAAN60ydgOAAAA; expires=Thu, 07-Oct-2021 19:30:38 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', - 'Tue, 07 Sep 2021 19:30:38 GMT', - 'Content-Length', - '1322' -]); - -nock('https://testaccount.dev.azuresynapse.net', {"encodedQueryParams":true}) - .get('/managedVirtualNetworks/default/managedPrivateEndpoints') - .query(true) - .reply(200, {"value":[{"name":"synapse-ws-sql--synapse-test-vnet","id":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/xiangyan/providers/Microsoft.Synapse/workspaces/synapse-test-vnet/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sql--synapse-test-vnet","type":"Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints","properties":{"privateLinkResourceId":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/xiangyan/providers/Microsoft.Synapse/workspaces/synapse-test-vnet","groupId":"sql","provisioningState":"Succeeded","connectionState":{"status":"Approved","description":"Approved by Microsoft.Synapse Resource Provider","actionsRequired":""},"isReserved":true,"fqdns":["synapse-test-vnet.31a8e776-91cd-482c-a26a-6f05d478d273.sql.azuresynapse.net"],"isCompliant":false}},{"name":"synapse-ws-sqlOnDemand--synapse-test-vnet","id":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/xiangyan/providers/Microsoft.Synapse/workspaces/synapse-test-vnet/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sqlOnDemand--synapse-test-vnet","type":"Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints","properties":{"privateLinkResourceId":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/xiangyan/providers/Microsoft.Synapse/workspaces/synapse-test-vnet","groupId":"sqlOnDemand","provisioningState":"Succeeded","connectionState":{"status":"Approved","description":"Approved by Microsoft.Synapse Resource Provider","actionsRequired":""},"isReserved":true,"fqdns":["synapse-test-vnet-ondemand.31a8e776-91cd-482c-a26a-6f05d478d273.sql.azuresynapse.net"],"isCompliant":false}}]}, [ - 'Content-Length', - '1708', - 'Content-Type', - 'application/json; charset=utf-8', - 'Server', - 'Microsoft-HTTPAPI/2.0', - 'Strict-Transport-Security', - 'max-age=31536000; includeSubDomains', - 'x-ms-request-id', - 'c5fca139-1f8b-4646-b05b-05150cb46f4e', - 'Date', - 'Tue, 07 Sep 2021 19:30:38 GMT' -]); diff --git a/sdk/synapse/synapse-managed-private-endpoints/recordings/node/synapse_managed_private_endpoints/recording_should_list_endpoints.json b/sdk/synapse/synapse-managed-private-endpoints/recordings/node/synapse_managed_private_endpoints/recording_should_list_endpoints.json new file mode 100644 index 000000000000..0c501945b92c --- /dev/null +++ b/sdk/synapse/synapse-managed-private-endpoints/recordings/node/synapse_managed_private_endpoints/recording_should_list_endpoints.json @@ -0,0 +1,91 @@ +{ + "Entries": [ + { + "RequestUri": "https://testaccount.dev.azuresynapse.net/managedVirtualNetworks/default/managedPrivateEndpoints?api-version=2020-12-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip,deflate", + "Authorization": "Sanitized", + "Connection": "keep-alive", + "User-Agent": "azsdk-js-synapse-managed-private-endpoints/1.0.0-beta.6 core-rest-pipeline/1.10.2 Node/v16.17.0 OS/(x64-Windows_NT-10.0.22621)", + "x-ms-client-request-id": "70f3991d-6df2-4c57-8bc4-155047600319" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "2465", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 13 Jan 2023 17:38:30 GMT", + "Server": "Microsoft-HTTPAPI/2.0", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-ms-request-id": "905a0fe8-4b25-4629-9e86-0bea49dda488" + }, + "ResponseBody": { + "value": [ + { + "name": "synapse-ws-sql--minhanhphan", + "id": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sql--minhanhphan", + "type": "Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints", + "properties": { + "privateLinkResourceId": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan", + "groupId": "sql", + "provisioningState": "Succeeded", + "connectionState": { + "status": "Approved", + "description": "Approved by Microsoft.Synapse Resource Provider", + "actionsRequired": "" + }, + "isReserved": true, + "fqdns": [ + "minhanhphan.8f6087d5-a969-4908-977e-817573a6b15b.sql.azuresynapse.net" + ], + "isCompliant": false + } + }, + { + "name": "synapse-ws-custstgacct--minhanhphan-minhanhphan", + "id": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-custstgacct--minhanhphan-minhanhphan", + "type": "Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints", + "properties": { + "privateLinkResourceId": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Storage/storageAccounts/minhanhphan", + "groupId": "dfs", + "provisioningState": "Succeeded", + "connectionState": { + "status": "Approved", + "description": "Auto-Approved", + "actionsRequired": "None" + }, + "isReserved": false, + "fqdns": [ + "minhanhphan.dfs.core.windows.net" + ], + "isCompliant": false + } + }, + { + "name": "synapse-ws-sqlOnDemand--minhanhphan", + "id": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sqlOnDemand--minhanhphan", + "type": "Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints", + "properties": { + "privateLinkResourceId": "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/minhanhphan-rg/providers/Microsoft.Synapse/workspaces/minhanhphan", + "groupId": "sqlOnDemand", + "provisioningState": "Succeeded", + "connectionState": { + "status": "Approved", + "description": "Approved by Microsoft.Synapse Resource Provider", + "actionsRequired": "" + }, + "isReserved": true, + "fqdns": [ + "minhanhphan-ondemand.8f6087d5-a969-4908-977e-817573a6b15b.sql.azuresynapse.net" + ], + "isCompliant": false + } + } + ] + } + } + ], + "Variables": {} +} diff --git a/sdk/synapse/synapse-managed-private-endpoints/test/public/test.spec.ts b/sdk/synapse/synapse-managed-private-endpoints/test/public/test.spec.ts index abcc2062b871..bf79d586752f 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/test/public/test.spec.ts +++ b/sdk/synapse/synapse-managed-private-endpoints/test/public/test.spec.ts @@ -7,9 +7,9 @@ describe("Synapse Managed Private Endpoints", () => { let recorder: Recorder; let client: ManagedPrivateEndpointsClient; - beforeEach(function() { - recorder = createRecorder(this); - client = createClient(); + beforeEach(async function() { + recorder = await createRecorder(this); + client = createClient(recorder.configureClientOptions({})); }); afterEach(async () => { diff --git a/sdk/synapse/synapse-managed-private-endpoints/test/public/utils/recordedClient.ts b/sdk/synapse/synapse-managed-private-endpoints/test/public/utils/recordedClient.ts index 6e0218937292..4c4afd8c8a10 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/test/public/utils/recordedClient.ts +++ b/sdk/synapse/synapse-managed-private-endpoints/test/public/utils/recordedClient.ts @@ -3,63 +3,24 @@ import "./env"; -import { ClientSecretCredential, TokenCredential } from "@azure/identity"; import { ManagedPrivateEndpointsClient, ManagedPrivateEndpointsClientOptionalParams, } from "../../../src"; import { Recorder, - RecorderEnvironmentSetup, - env, - isLiveMode, - record, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import { createXhrHttpClient, isNode } from "@azure/test-utils"; +import { createTestCredential } from "@azure-tools/test-credential"; import { Context } from "mocha"; -const replaceableVariables: { [k: string]: string } = { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - ENDPOINT: "https://testaccount.dev.azuresynapse.net", -}; - -export const environmentSetup: RecorderEnvironmentSetup = { - replaceableVariables, - customizationsOnRecordings: [ - (recording: string): string => - recording.replace(/"access_token"\s?:\s?"[^"]*"/g, `"access_token":"access_token"`), - // If we put ENDPOINT in replaceableVariables above, it will not capture - // the endpoint string used with nock, which will be expanded to - // https://:443/ and therefore will not match, so we have to do - // this instead. - (recording: string): string => { - const replaced = recording.replace( - "testaccount.dev.azuresynapse.net:443", - "testaccount.dev.azuresynapse.net" - ); - return replaced; - }, - ], - queryParametersToSkip: [], -}; - export function createClient( options?: ManagedPrivateEndpointsClientOptionalParams ): ManagedPrivateEndpointsClient { - let credential: TokenCredential; - const httpClient = isNode || isLiveMode() ? undefined : createXhrHttpClient(); - - credential = new ClientSecretCredential( - env.AZURE_TENANT_ID, - env.AZURE_CLIENT_ID, - env.AZURE_CLIENT_SECRET, - { httpClient } - ); - - return new ManagedPrivateEndpointsClient(credential, env.ENDPOINT, { ...options, httpClient }); + let credential = createTestCredential(); + return new ManagedPrivateEndpointsClient(credential, env.ENDPOINT as string, { ...options }); } /** @@ -67,6 +28,16 @@ export function createClient( * Should be called first in the test suite to make sure environment variables are * read before they are being used. */ -export function createRecorder(context: Context): Recorder { - return record(context, environmentSetup); +export async function createRecorder(context: Context): Promise { + const recorderStartOptions: RecorderStartOptions = { + envSetupForPlayback: { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + ENDPOINT: "https://testaccount.dev.azuresynapse.net" + }, + }; + const recorder = new Recorder(context.currentTest); + await recorder.start(recorderStartOptions); + return recorder; }