From ac983a2f6e541785180e6244ba776f5b41913c44 Mon Sep 17 00:00:00 2001 From: darlin Date: Thu, 10 Sep 2020 22:05:06 +0800 Subject: [PATCH] SMB multichannel test only --- sdk/storage/storage-file-share/karma.conf.js | 2 + .../recording_smb_multichannel.json | 48 +++++++++++++++++++ .../recording_smb_multichannel.js | 43 +++++++++++++++++ sdk/storage/storage-file-share/sample.env | 10 +++- .../test/fileserviceclient.spec.ts | 44 +++++++++++++---- .../test/utils/testutils.common.ts | 7 ++- 6 files changed, 142 insertions(+), 12 deletions(-) create mode 100644 sdk/storage/storage-file-share/recordings/browsers/fileserviceclient_premium/recording_smb_multichannel.json create mode 100644 sdk/storage/storage-file-share/recordings/node/fileserviceclient_premium/recording_smb_multichannel.js diff --git a/sdk/storage/storage-file-share/karma.conf.js b/sdk/storage/storage-file-share/karma.conf.js index 59b4dbd6b38a..c3b516d8bb0b 100644 --- a/sdk/storage/storage-file-share/karma.conf.js +++ b/sdk/storage/storage-file-share/karma.conf.js @@ -62,6 +62,8 @@ module.exports = function(config) { "ACCOUNT_SAS", "SOFT_DELETE_ACCOUNT_NAME", "SOFT_DELETE_ACCOUNT_SAS", + "PREMIUM_FILE_ACCOUNT_NAME", + "PREMIUM_FILE_ACCOUNT_SAS", "TEST_MODE" ], diff --git a/sdk/storage/storage-file-share/recordings/browsers/fileserviceclient_premium/recording_smb_multichannel.json b/sdk/storage/storage-file-share/recordings/browsers/fileserviceclient_premium/recording_smb_multichannel.json new file mode 100644 index 000000000000..bbe95845bb91 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/browsers/fileserviceclient_premium/recording_smb_multichannel.json @@ -0,0 +1,48 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://pf-fakestorageaccount.file.core.windows.net/", + "query": { + "restype": "service", + "comp": "properties" + }, + "requestBody": "true", + "status": 202, + "response": "", + "responseHeaders": { + "date": "Thu, 10 Sep 2020 14:03:06 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding": "chunked", + "x-ms-client-request-id": "934f892e-3e9b-44c9-8407-a50a3c40a43d", + "x-ms-request-id": "8db70106-201a-0042-1b7b-878fcc000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "GET", + "url": "https://pf-fakestorageaccount.file.core.windows.net/", + "query": { + "restype": "service", + "comp": "properties" + }, + "requestBody": null, + "status": 200, + "response": "1.0truefalsetrue31.0truefalsetrue3DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT,PATCH***86400DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT,PATCH***86400true", + "responseHeaders": { + "content-type": "application/xml", + "date": "Thu, 10 Sep 2020 14:03:07 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding": "chunked", + "x-ms-client-request-id": "d7ce9946-4739-4100-a4f5-8f31e13ebdc9", + "x-ms-request-id": "8db70110-201a-0042-1f7b-878fcc000000", + "x-ms-version": "2020-02-10" + } + } + ], + "uniqueTestInfo": { + "uniqueName": {}, + "newDate": {} + }, + "hash": "0239648c88b551390876f693c87cb2ae" +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/recordings/node/fileserviceclient_premium/recording_smb_multichannel.js b/sdk/storage/storage-file-share/recordings/node/fileserviceclient_premium/recording_smb_multichannel.js new file mode 100644 index 000000000000..e3d782352036 --- /dev/null +++ b/sdk/storage/storage-file-share/recordings/node/fileserviceclient_premium/recording_smb_multichannel.js @@ -0,0 +1,43 @@ +let nock = require('nock'); + +module.exports.hash = "78826de9762af24647034ce150be365a"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://pf-fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .put('/', "true") + .query(true) + .reply(202, "", [ + 'Transfer-Encoding', + 'chunked', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2dc4a1f7-801a-0016-7f78-87c09b000000', + 'x-ms-client-request-id', + '8f92140c-f966-4ad0-a2fc-3ea6b49a939a', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Thu, 10 Sep 2020 13:46:59 GMT' +]); + +nock('https://pf-fakestorageaccount.file.core.windows.net:443', {"encodedQueryParams":true}) + .get('/') + .query(true) + .reply(200, "1.0truefalsetrue31.0truefalsetrue3true", [ + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2dc4a201-801a-0016-8078-87c09b000000', + 'x-ms-client-request-id', + '75abb464-0639-484a-a861-9b9c187d6452', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Thu, 10 Sep 2020 13:46:59 GMT' +]); diff --git a/sdk/storage/storage-file-share/sample.env b/sdk/storage/storage-file-share/sample.env index 5eabd1722fed..fa2a131c708c 100644 --- a/sdk/storage/storage-file-share/sample.env +++ b/sdk/storage/storage-file-share/sample.env @@ -19,8 +19,14 @@ DIR_NAME= # change it to "record" to generate new recordings, or "live" to bypass the recorder entirely. # TEST_MODE=playback -# Used for share soft delete. +# Optional, used for share soft delete. SOFT_DELETE_ACCOUNT_NAME= SOFT_DELETE_ACCOUNT_KEY= SOFT_DELETE_STORAGE_CONNECTION_STRING= -SOFT_DELETE_ACCOUNT_SAS= \ No newline at end of file +SOFT_DELETE_ACCOUNT_SAS= + +# Optional, used for tests on premium file accounts. +PREMIUM_FILE_ACCOUNT_NAME= +PREMIUM_FILE_ACCOUNT_KEY= +PREMIUM_FILE_STORAGE_CONNECTION_STRING= +PREMIUM_FILE_ACCOUNT_SAS= diff --git a/sdk/storage/storage-file-share/test/fileserviceclient.spec.ts b/sdk/storage/storage-file-share/test/fileserviceclient.spec.ts index 28267e9e2167..edbe0eb98d8a 100644 --- a/sdk/storage/storage-file-share/test/fileserviceclient.spec.ts +++ b/sdk/storage/storage-file-share/test/fileserviceclient.spec.ts @@ -4,7 +4,8 @@ import { getBSU, getSASConnectionStringFromEnvironment, recorderEnvSetup, - getSoftDeleteBSU + getSoftDeleteBSU, + getGenericBSU } from "./utils"; import { record, delay, Recorder } from "@azure/test-utils-recorder"; import * as dotenv from "dotenv"; @@ -14,11 +15,11 @@ dotenv.config(); describe("FileServiceClient", () => { let recorder: Recorder; - beforeEach(function () { + beforeEach(function() { recorder = record(this, recorderEnvSetup); }); - afterEach(async function () { + afterEach(async function() { await recorder.stop(); }); @@ -387,12 +388,11 @@ describe("FileServiceClient", () => { }); }); - describe("FileServiceClient", () => { let recorder: Recorder; let serviceClient: ShareServiceClient; - beforeEach(function () { + beforeEach(function() { recorder = record(this, recorderEnvSetup); try { @@ -402,11 +402,11 @@ describe("FileServiceClient", () => { } }); - afterEach(async function () { + afterEach(async function() { await recorder.stop(); }); - it("ListShares with deleted share", async function () { + it("ListShares with deleted share", async function() { const shareClient = serviceClient.getShareClient(recorder.getUniqueName("share")); await shareClient.create(); await shareClient.delete(); @@ -422,7 +422,7 @@ describe("FileServiceClient", () => { assert.ok(found); }); - it("Undelete share positive", async function () { + it("Undelete share positive", async function() { const shareClient = serviceClient.getShareClient(recorder.getUniqueName("share")); await shareClient.create(); await shareClient.delete(); @@ -455,7 +455,7 @@ describe("FileServiceClient", () => { await restoredShareClient.delete(); }); - it("Undelete share negative", async function () { + it("Undelete share negative", async function() { const shareClient = serviceClient.getShareClient(recorder.getUniqueName("share")); const invalidVersion = "01D60F8BB59A4652"; @@ -467,3 +467,29 @@ describe("FileServiceClient", () => { } }); }); + +describe("FileServiceClient Premium", () => { + let recorder: Recorder; + let serviceClient: ShareServiceClient; + + beforeEach(function() { + recorder = record(this, recorderEnvSetup); + try { + serviceClient = getGenericBSU("PREMIUM_FILE_"); + } catch (error) { + this.skip(); + } + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("SMB Multichannel", async () => { + await serviceClient.setProperties({ + protocolSettings: { smbSettings: { multichannel: { enabled: true } } } + }); + const propertiesSet = await serviceClient.getProperties(); + assert.ok(propertiesSet.protocolSettings?.smbSettings?.multichannel); + }); +}); diff --git a/sdk/storage/storage-file-share/test/utils/testutils.common.ts b/sdk/storage/storage-file-share/test/utils/testutils.common.ts index 2fff35a5c671..0e35a2c92542 100644 --- a/sdk/storage/storage-file-share/test/utils/testutils.common.ts +++ b/sdk/storage/storage-file-share/test/utils/testutils.common.ts @@ -8,6 +8,7 @@ export function isBrowser(): boolean { const mockAccountName = "fakestorageaccount"; const mockAccountKey = "aaaaa"; const mockSDAccountName = "sd-fakestorageaccount"; +const mockPFAccountName = "pf-fakestorageaccount"; export const recorderEnvSetup: RecorderEnvironmentSetup = { replaceableVariables: { // Used in record and playback modes @@ -23,7 +24,11 @@ export const recorderEnvSetup: RecorderEnvironmentSetup = { SOFT_DELETE_ACCOUNT_NAME: `${mockSDAccountName}`, SOFT_DELETE_ACCOUNT_KEY: `${mockAccountKey}`, SOFT_DELETE_ACCOUNT_SAS: `${mockAccountKey}`, - SOFT_DELETE_STORAGE_CONNECTION_STRING: `DefaultEndpointsProtocol=https;AccountName=${mockSDAccountName};AccountKey=${mockAccountKey};EndpointSuffix=core.windows.net` + SOFT_DELETE_STORAGE_CONNECTION_STRING: `DefaultEndpointsProtocol=https;AccountName=${mockSDAccountName};AccountKey=${mockAccountKey};EndpointSuffix=core.windows.net`, + PREMIUM_FILE_ACCOUNT_NAME: `${mockPFAccountName}`, + PREMIUM_FILE_ACCOUNT_KEY: `${mockAccountKey}`, + PREMIUM_FILE_ACCOUNT_SAS: `${mockAccountKey}`, + PREMIUM_FILE_STORAGE_CONNECTION_STRING: `DefaultEndpointsProtocol=https;AccountName=${mockPFAccountName};AccountKey=${mockAccountKey};EndpointSuffix=core.windows.net` }, customizationsOnRecordings: [ // Used in record mode