From 18b3f306026d1b42b7745fd76d6f5c8feb94814d Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Mon, 22 Mar 2021 20:51:54 -0400 Subject: [PATCH] Use @this to satisfy ESLint's no-invalid-this (#14406) # Problem `no-invalid-this` makes sure uses of `this` are valid (see [docs](https://eslint.org/docs/rules/no-invalid-this) and [implementation](https://github.com/eslint/eslint/blob/8984c91372e64d1e8dd2ce21b87b80977d57bff9/lib/rules/utils/ast-utils.js#L900)). However, uses of `this` are rampant in our test suites because this is how mocha unit tests are structured, the Mocha context can be accessed only through `this`. # Fix So instead of disabling `no-invalid-this` in our test suites, this PR tags functions that reference `this` with `@this` and that satisfies the rule requirements (see [docs](https://eslint.org/docs/rules/no-invalid-this)). # Discussion It could be argued that this work just replaces one comment annotation with another so we did not really solve the underlying problem. However, the inherent problem lies in how mocha itself works and there is nothing we can do other than probably migrating to another framework that is more sane/type-safe. One minor improvement we get is we now have slightly less syntactic overhead because we need to tag just the function instead of individual lines in its body that violate the rule. # Trade-offs Pros: - function tags are less than line tags Cons: - whitelisting one more tag with the tsdoc linter that our devs need to learn about - still having rampant tags everywhere Fixes https://github.com/Azure/azure-sdk-for-js/issues/11404 --- .../test/anomalydetector.spec.ts | 9 +- .../test/public/attestationTests.spec.ts | 3 +- .../test/public/policyGetSetTests.spec.ts | 3 +- .../policyManagementGetSetTests.spec.ts | 3 +- .../test/public/tokenCertTests.spec.ts | 3 +- .../public/containerRegistryClient.spec.ts | 53 +++++---- .../container-registry/tsdoc.json | 4 + .../core-http/test/defaultHttpClientTests.ts | 3 +- sdk/core/core-lro/test/utils/testOperation.ts | 4 +- sdk/core/logger/src/debug.ts | 4 +- sdk/cosmosdb/cosmos/test/.eslintrc.json | 1 - .../cosmos/test/internal/session.spec.ts | 4 +- .../cosmos/test/internal/unit/auth.spec.ts | 2 +- .../public/functional/authorization.spec.ts | 2 +- .../test/public/functional/client.spec.ts | 2 +- .../test/public/functional/conflict.spec.ts | 2 +- .../test/public/functional/container.spec.ts | 2 +- .../test/public/functional/database.spec.ts | 2 +- .../public/functional/databaseaccount.spec.ts | 10 +- .../test/public/functional/item.spec.ts | 2 +- .../test/public/functional/offer.spec.ts | 12 +- .../test/public/functional/permission.spec.ts | 2 +- .../test/public/functional/query.spec.ts | 6 +- .../test/public/functional/spatial.spec.ts | 2 +- .../test/public/functional/sproc.spec.ts | 18 +-- .../test/public/functional/trigger.spec.ts | 2 +- .../cosmos/test/public/functional/ttl.spec.ts | 2 +- .../cosmos/test/public/functional/udf.spec.ts | 2 +- .../test/public/functional/user.spec.ts | 2 +- .../public/integration/aggregateQuery.spec.ts | 2 +- .../public/integration/authorization.spec.ts | 2 +- .../public/integration/changeFeed.spec.ts | 2 +- .../public/integration/crossPartition.spec.ts | 2 +- .../test/public/integration/encoding.spec.ts | 2 +- .../public/integration/multiregion.spec.ts | 2 +- .../test/public/integration/proxy.spec.ts | 2 +- .../test/public/integration/query.spec.ts | 6 +- sdk/cosmosdb/cosmos/test/tsdoc.json | 4 + .../eventgrid/test/eventGridClient.spec.ts | 111 ++++++++++-------- .../browser/formrecognizerclient.spec.ts | 9 +- .../test/public/formtrainingclient.spec.ts | 10 +- .../public/node/formrecognizerclient.spec.ts | 11 +- .../test/internal/identityClient.spec.ts | 3 +- sdk/keyvault/keyvault-admin/.eslintrc.json | 1 - .../keyvault-certificates/.eslintrc.json | 1 - ...challengeBasedAuthenticationPolicy.spec.ts | 20 ++-- .../test/internal/userAgent.spec.ts | 2 +- .../test/public/CRUD.spec.ts | 66 ++++++----- .../test/public/list.spec.ts | 30 ++--- .../test/public/lro.create.spec.ts | 20 ++-- .../test/public/lro.delete.spec.ts | 20 ++-- .../test/public/lro.operation.spec.ts | 20 ++-- .../test/public/lro.recover.spec.ts | 22 ++-- .../test/public/mergeAndImport.spec.ts | 30 +++-- .../test/public/recoverBackupRestore.spec.ts | 24 ++-- .../test/utils/lro/restore/operation.ts | 2 + sdk/keyvault/keyvault-keys/.eslintrc.json | 1 - .../test/internal/aesCryptography.spec.ts | 66 ++++++----- ...challengeBasedAuthenticationPolicy.spec.ts | 20 ++-- .../test/internal/crypto.spec.ts | 12 +- .../test/internal/userAgent.spec.ts | 2 +- .../test/public/CRUD.hsm.spec.ts | 30 ++--- .../keyvault-keys/test/public/CRUD.spec.ts | 66 ++++++----- .../test/public/crypto.hsm.spec.ts | 34 +++--- .../keyvault-keys/test/public/crypto.spec.ts | 64 +++++----- .../keyvault-keys/test/public/import.spec.ts | 18 +-- .../keyvault-keys/test/public/list.spec.ts | 34 +++--- .../test/public/localCryptography.spec.ts | 104 ++++++++-------- .../test/public/lro.delete.spec.ts | 20 ++-- .../test/public/lro.recoverDelete.spec.ts | 22 ++-- .../test/public/recoverBackupRestore.spec.ts | 28 +++-- .../test/utils/lro/restore/operation.ts | 2 + sdk/keyvault/keyvault-secrets/.eslintrc.json | 1 - ...challengeBasedAuthenticationPolicy.spec.ts | 20 ++-- .../test/internal/userAgent.spec.ts | 2 +- .../keyvault-secrets/test/public/CRUD.spec.ts | 52 ++++---- .../keyvault-secrets/test/public/list.spec.ts | 36 +++--- .../test/public/lro.delete.spec.ts | 22 ++-- .../test/public/lro.recover.spec.ts | 22 ++-- .../test/public/recoverBackupRestore.spec.ts | 30 ++--- .../test/utils/lro/restore/operation.ts | 2 + .../test/public/adminclient.spec.ts | 18 ++- .../test/public/advisorclient.spec.ts | 9 +- .../test/public/hookTests.spec.ts | 19 +-- .../test/mixedRealityStsClient.spec.ts | 11 +- .../test/schemaRegistry.spec.ts | 9 +- sdk/schemaregistry/schema-registry/tsdoc.json | 4 + .../test/public/node/searchClient.spec.ts | 26 ++-- .../public/node/searchIndexClient.spec.ts | 25 ++-- .../public/node/searchIndexerClient.spec.ts | 29 ++--- .../test/integration/batch.spec.ts | 25 ++-- .../test/integration/tableclient.spec.ts | 40 ++++--- .../integration/tableserviceclient.spec.ts | 55 +++++---- .../test/unit/sharedKeyCredential.spec.ts | 3 +- .../data-tables/test/unit/utils.spec.ts | 13 +- .../test/public/configurationClient.spec.ts | 59 +++++----- sdk/template/template/tsdoc.json | 4 + .../multi-version/test/multiVersion.spec.ts | 8 +- .../test/public/apiKey.spec.ts | 32 ++--- .../test/public/textAnalyticsClient.spec.ts | 42 +++---- tsdoc.json | 4 + 101 files changed, 935 insertions(+), 802 deletions(-) create mode 100644 sdk/containerregistry/container-registry/tsdoc.json create mode 100644 sdk/cosmosdb/cosmos/test/tsdoc.json create mode 100644 sdk/schemaregistry/schema-registry/tsdoc.json create mode 100644 sdk/template/template/tsdoc.json diff --git a/sdk/anomalydetector/ai-anomaly-detector/test/anomalydetector.spec.ts b/sdk/anomalydetector/ai-anomaly-detector/test/anomalydetector.spec.ts index 0205a936d87c..cb120e1c215e 100644 --- a/sdk/anomalydetector/ai-anomaly-detector/test/anomalydetector.spec.ts +++ b/sdk/anomalydetector/ai-anomaly-detector/test/anomalydetector.spec.ts @@ -19,10 +19,11 @@ describe("AnomalyDetectorClient", () => { let recorder: Recorder; const apiKey = new AzureKeyCredential(testEnv.ANOMALY_DETECTOR_API_KEY); - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - ({ recorder, client } = createRecordedAnomalyDetectorClient(this, apiKey)); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ recorder, client } = createRecordedAnomalyDetectorClient(this, apiKey)); + } + ); afterEach(async function() { if (recorder) { diff --git a/sdk/attestation/attestation/test/public/attestationTests.spec.ts b/sdk/attestation/attestation/test/public/attestationTests.spec.ts index a98319589dd2..d93d76ed91ed 100644 --- a/sdk/attestation/attestation/test/public/attestationTests.spec.ts +++ b/sdk/attestation/attestation/test/public/attestationTests.spec.ts @@ -14,8 +14,7 @@ import { verifyAttestationToken } from "../utils/helpers"; describe("[AAD] Attestation Client", function() { let recorder: Recorder; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this + beforeEach(/** @this Mocha.Context */ function() { recorder = createRecorder(this); }); diff --git a/sdk/attestation/attestation/test/public/policyGetSetTests.spec.ts b/sdk/attestation/attestation/test/public/policyGetSetTests.spec.ts index cb26556db09a..c6aae43ce107 100644 --- a/sdk/attestation/attestation/test/public/policyGetSetTests.spec.ts +++ b/sdk/attestation/attestation/test/public/policyGetSetTests.spec.ts @@ -14,8 +14,7 @@ import { verifyAttestationToken } from "../utils/helpers"; describe("PolicyGetSetTests ", function() { let recorder: Recorder; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this + beforeEach(/** @this Mocha.Context */ function() { recorder = createRecorder(this); }); diff --git a/sdk/attestation/attestation/test/public/policyManagementGetSetTests.spec.ts b/sdk/attestation/attestation/test/public/policyManagementGetSetTests.spec.ts index fa9e9081aac7..9f83fafe11b2 100644 --- a/sdk/attestation/attestation/test/public/policyManagementGetSetTests.spec.ts +++ b/sdk/attestation/attestation/test/public/policyManagementGetSetTests.spec.ts @@ -13,8 +13,7 @@ import { verifyAttestationToken } from "../utils/helpers"; describe("PolicyManagementTests ", function() { let recorder: Recorder; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this + beforeEach(/** @this Mocha.Context */ function() { recorder = createRecorder(this); }); diff --git a/sdk/attestation/attestation/test/public/tokenCertTests.spec.ts b/sdk/attestation/attestation/test/public/tokenCertTests.spec.ts index c2b0ad00e2d6..da8030379308 100644 --- a/sdk/attestation/attestation/test/public/tokenCertTests.spec.ts +++ b/sdk/attestation/attestation/test/public/tokenCertTests.spec.ts @@ -13,8 +13,7 @@ import { Buffer } from "../utils/Buffer"; describe("TokenCertTests", function() { let recorder: Recorder; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this + beforeEach(/** @this Mocha.Context */ function() { recorder = createRecorder(this); }); diff --git a/sdk/containerregistry/container-registry/test/public/containerRegistryClient.spec.ts b/sdk/containerregistry/container-registry/test/public/containerRegistryClient.spec.ts index fc57fdcd622c..d09350de7c50 100644 --- a/sdk/containerregistry/container-registry/test/public/containerRegistryClient.spec.ts +++ b/sdk/containerregistry/container-registry/test/public/containerRegistryClient.spec.ts @@ -50,35 +50,36 @@ describe.skip("ContainerRegistryClient 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(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. - // eslint-disable-next-line no-invalid-this - recorder = record(this, { - // == Recorder Environment Setup == Add the replaceable variables from - // above - replaceableVariables, + beforeEach( + /** @this Mocha.Context */ 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: [], + // 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"`) - ] - }); + // 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 = createTestClient(); - }); + // We'll be able to refer to the instantiated `client` in tests, since we + // initialize it before each test + client = createTestClient(); + } + ); // After each test, we need to stop the recording. afterEach(async function() { diff --git a/sdk/containerregistry/container-registry/tsdoc.json b/sdk/containerregistry/container-registry/tsdoc.json new file mode 100644 index 000000000000..81c5a8a2aa2f --- /dev/null +++ b/sdk/containerregistry/container-registry/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": ["../../../tsdoc.json"] +} diff --git a/sdk/core/core-http/test/defaultHttpClientTests.ts b/sdk/core/core-http/test/defaultHttpClientTests.ts index 1bd1a76c1a97..e548d2e26ff6 100644 --- a/sdk/core/core-http/test/defaultHttpClientTests.ts +++ b/sdk/core/core-http/test/defaultHttpClientTests.ts @@ -236,9 +236,8 @@ describe("defaultHttpClient", function() { } }); - it("should give a graceful error for nonexistent hosts", async function() { + it("should give a graceful error for nonexistent hosts", /** @this Mocha.Context */ async function() { // Increase timeout to give the request time to fail - // eslint-disable-next-line no-invalid-this this.timeout(10000); const requestUrl = "http://fake.domain"; const request = new WebResource(requestUrl, "GET"); diff --git a/sdk/core/core-lro/test/utils/testOperation.ts b/sdk/core/core-lro/test/utils/testOperation.ts index 00cc3ffa617d..8741abce9efb 100644 --- a/sdk/core/core-lro/test/utils/testOperation.ts +++ b/sdk/core/core-lro/test/utils/testOperation.ts @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/* eslint-disable no-invalid-this */ import { HttpOperationResponse, RequestOptionsBase } from "@azure/core-http"; import { AbortSignalLike } from "@azure/abort-controller"; @@ -22,6 +21,7 @@ export interface TestOperationState extends PollOperationState { export interface TestOperation extends PollOperation {} +/** @this TestOperation */ async function update( this: TestOperation, options: { @@ -70,6 +70,7 @@ async function update( return makeOperation(newState); } +/** @this TestOperation */ async function cancel( this: TestOperation, options: { abortSignal?: AbortSignal } = {} @@ -100,6 +101,7 @@ async function cancel( }); } +/** @this TestOperation */ function toString(this: TestOperation): string { return JSON.stringify({ state: this.state diff --git a/sdk/core/logger/src/debug.ts b/sdk/core/logger/src/debug.ts index 07165617e242..1c29423fe62a 100644 --- a/sdk/core/logger/src/debug.ts +++ b/sdk/core/logger/src/debug.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/* eslint-disable no-invalid-this */ - import { log } from "./log"; /** @@ -157,6 +155,7 @@ function createDebugger(namespace: string): Debugger { return newDebugger; } +/** @this Debugger */ function destroy(this: Debugger): boolean { const index = debuggers.indexOf(this); if (index >= 0) { @@ -166,6 +165,7 @@ function destroy(this: Debugger): boolean { return false; } +/** @this Debugger */ function extend(this: Debugger, namespace: string): Debugger { const newDebugger = createDebugger(`${this.namespace}:${namespace}`); newDebugger.log = this.log; diff --git a/sdk/cosmosdb/cosmos/test/.eslintrc.json b/sdk/cosmosdb/cosmos/test/.eslintrc.json index 150383183916..485795008a39 100644 --- a/sdk/cosmosdb/cosmos/test/.eslintrc.json +++ b/sdk/cosmosdb/cosmos/test/.eslintrc.json @@ -2,7 +2,6 @@ "extends": ["../.eslintrc.json"], "rules": { "no-console": "off", - "no-invalid-this": "off", "space-before-function-paren": "off" } } diff --git a/sdk/cosmosdb/cosmos/test/internal/session.spec.ts b/sdk/cosmosdb/cosmos/test/internal/session.spec.ts index a6e93d6978b6..769a78855d72 100644 --- a/sdk/cosmosdb/cosmos/test/internal/session.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/session.spec.ts @@ -28,7 +28,7 @@ function getCollection2TokenMap( return (sessionContainer as any).collectionResourceIdToSessionTokens; } -describe("Session Token", function() { +describe("Session Token", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 20000); const containerId = "sessionTestColl"; @@ -304,7 +304,7 @@ describe("Session Token", function() { spy.restore(); }); - it("validate 'lsn not caught up' error for higher lsn and clearing session token", async function() { + it("validate 'lsn not caught up' error for higher lsn and clearing session token", /** @this Mocha.Context */ async function() { this.retries(2); const database = await getTestDatabase("session test", client); diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts index 8625c5fe6b53..cac18417be47 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts @@ -4,7 +4,7 @@ import { getAuthorizationTokenUsingResourceTokens } from "../../../src/auth"; import assert from "assert"; -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); it("should find exact match", async function() { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts index 1de9580ce23e..3b6d75fa567f 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts @@ -11,7 +11,7 @@ import { removeAllDatabases } from "../common/TestHelpers"; -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { await removeAllDatabases(); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts index 70f223dff25d..8e18e80646b6 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts @@ -13,7 +13,7 @@ import { import AbortController from "node-abort-controller"; import { UsernamePasswordCredential } from "@azure/identity"; -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 20000); describe("Validate client request timeout", function() { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts index 3df4ff8cb451..1f8aab90af1c 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts @@ -3,7 +3,7 @@ import assert from "assert"; import { removeAllDatabases, getTestContainer } from "../common/TestHelpers"; -describe("Conflicts", function() { +describe("Conflicts", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { await removeAllDatabases(); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts index 3a959edc72db..81c4d262fa1f 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts @@ -14,7 +14,7 @@ import { import { SpatialType } from "../../../src"; import { GeospatialType } from "../../../src"; -describe("Containers", function() { +describe("Containers", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { await removeAllDatabases(); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts index 4c74176cc248..123c5fdec13f 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts @@ -13,7 +13,7 @@ import { DatabaseRequest } from "../../../src"; const client = new CosmosClient({ endpoint, key: masterKey }); -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { await removeAllDatabases(); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts index 8797d8f28f19..1aa438386527 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts @@ -6,11 +6,13 @@ import { endpoint, masterKey } from "../common/_testConfig"; const client = new CosmosClient({ endpoint, key: masterKey }); -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function() { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - }); + beforeEach( + /** @this Mocha.Context */ async function() { + this.timeout(process.env.MOCHA_TIMEOUT || 10000); + } + ); describe("validate database account functionality", function() { it("nativeApi Should get database account successfully name based", async function() { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item.spec.ts index 0d383bd8100b..c231f99d5ac2 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item.spec.ts @@ -26,7 +26,7 @@ interface TestItem { replace?: string; } -describe("Item CRUD", function() { +describe("Item CRUD", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { await removeAllDatabases(); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts index 0357bbe1a01d..e148d49c35db 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts @@ -15,13 +15,15 @@ const validateOfferResponseBody = function(offer: any): void { assert(offer._self.indexOf(offer.id) !== -1, "Offer id not contained in offer self link."); }; -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function() { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - await removeAllDatabases(); - }); + beforeEach( + /** @this Mocha.Context */ async function() { + this.timeout(process.env.MOCHA_TIMEOUT || 10000); + await removeAllDatabases(); + } + ); describe("Validate Offer CRUD", function() { it("nativeApi Should do offer read and query operations successfully name based single partition collection", async function() { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts index 91b4c2e7b67e..c947e0a83114 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts @@ -10,7 +10,7 @@ import { replaceOrUpsertPermission } from "../common/TestHelpers"; -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { await removeAllDatabases(); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts index d5b46e1053ae..2de5e66f30bc 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts @@ -14,7 +14,7 @@ if (!Symbol || !Symbol.asyncIterator) { (Symbol as any).asyncIterator = Symbol.for("Symbol.asyncIterator"); } -describe("Queries", function() { +describe("Queries", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); before(async function() { await removeAllDatabases(); @@ -47,7 +47,7 @@ describe("Queries", function() { }); }); - describe("QueryIterator", function() { + describe("QueryIterator", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 30000); let resources: { container: Container; doc1: any; doc2: any; doc3: any }; @@ -143,7 +143,7 @@ describe("Queries", function() { } }); - describe("SUM query iterator", function() { + describe("SUM query iterator", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 30000); it("returns undefined sum with null value in aggregator", async function() { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts index 4b27ca78113f..857b6ab3b301 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts @@ -4,7 +4,7 @@ import assert from "assert"; import { Database, DataType, IndexKind } from "../../../src"; import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers"; -describe("Spatial Indexes", function() { +describe("Spatial Indexes", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { await removeAllDatabases(); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts index 69f4c9c0f8a6..27baaf0b5532 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts @@ -13,16 +13,18 @@ import { // Used for sproc declare let getContext: any; -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { await removeAllDatabases(); }); describe("Validate sproc CRUD", function() { let container: Container; - beforeEach(async function() { - container = await getTestContainer(this.test.fullTitle()); - }); + beforeEach( + /** @this Mocha.Context */ async function() { + container = await getTestContainer(this.test.fullTitle()); + } + ); it("nativeApi Should do sproc CRUD operations successfully with create/replace", async function() { // read sprocs @@ -92,9 +94,11 @@ describe("NodeJS CRUD Tests", function() { describe("Validate stored procedure functionality", function() { let container: Container; - beforeEach(async function() { - container = await getTestContainer(this.test.fullTitle()); - }); + beforeEach( + /** @this Mocha.Context */ async function() { + container = await getTestContainer(this.test.fullTitle()); + } + ); it("nativeApi should do stored procedure operations successfully with create/replace", async function() { const sproc1: StoredProcedureDefinition = { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts index 4a1f4ad875e5..cdcc6d5b90e9 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts @@ -10,7 +10,7 @@ const notFoundErrorCode = 404; // Mock for trigger function bodies declare let getContext: any; -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); let container: Container; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts index 9da4ffe80eb7..0682de279eae 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts @@ -11,7 +11,7 @@ async function sleep(time: number): Promise { }); } -describe("Container TTL", function() { +describe("Container TTL", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 600000); beforeEach(async function() { await removeAllDatabases(); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts index 59cccd991a3e..cbfd1dfc5468 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts @@ -4,7 +4,7 @@ import assert from "assert"; import { UserDefinedFunctionDefinition, Container } from "../../../src"; import { removeAllDatabases, getTestContainer } from "../common/TestHelpers"; -describe("User Defined Function", function() { +describe("User Defined Function", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); let container: Container; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts index df242aa00330..c06ec026c6a9 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts @@ -4,7 +4,7 @@ import assert from "assert"; import { UserDefinition } from "../../../src"; import { createOrUpsertUser, getTestDatabase, removeAllDatabases } from "../common/TestHelpers"; -describe("NodeJS CRUD Tests", function() { +describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { await removeAllDatabases(); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts index 6074fe39b8f1..51dac69cf1fd 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts @@ -9,7 +9,7 @@ import { FeedOptions } from "../../../src"; import { TestData } from "../common/TestData"; import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers"; -describe("Aggregate Query", function() { +describe("Aggregate Query", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 20000); const partitionKey = "key"; const uniquePartitionKey = "uniquePartitionKey"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts index 5da7a287fe0a..a7d22d30bd6a 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts @@ -6,7 +6,7 @@ import { Database } from "../../../src"; import { endpoint } from "../common/_testConfig"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers"; -describe("Authorization", function() { +describe("Authorization", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); // TODO: should have types for all these things diff --git a/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts index ba91ff3bdb86..97625a17e2e4 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts @@ -5,7 +5,7 @@ import { RequestOptions } from "../../../src"; import { Container, ContainerDefinition } from "../../../src"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers"; -describe("Change Feed Iterator", function() { +describe("Change Feed Iterator", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 20000); // delete all databases and create sample database diff --git a/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts index 171b6333e4fa..1bf0a5db5161 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts @@ -26,7 +26,7 @@ function compare(key: string) { }; } -describe("Cross Partition", function() { +describe("Cross Partition", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || "30000"); describe("Validate Query", function() { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts index 10642368a6a3..33dc9521adfb 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts @@ -10,7 +10,7 @@ const testDoc = { "€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€" }; -describe("Create And Read Validation", function() { +describe("Create And Read Validation", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); const dateTime = new Date(); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts index baf89f5c9853..81570d28516f 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts @@ -107,7 +107,7 @@ const collectionResponse = { code: 200 }; -describe("Multi-region tests", function() { +describe("Multi-region tests", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || "30000"); it("Preferred locations should be honored for readEndpoint", async function() { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts index 236accade1e5..7409c7bacc7f 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts @@ -52,7 +52,7 @@ if (!isBrowser()) { }); }); - it("nativeApi Client Should execute request in error while the proxy setting is not correct", async function() { + it("nativeApi Client Should execute request in error while the proxy setting is not correct", /** @this Mocha.Context */ async function() { this.timeout(process.env.MOCHA_TIMEOUT || 30000); return new Promise((resolve, reject) => { proxy.listen(proxyPort + 1, "127.0.0.1", async () => { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts index 11f9f1821b2d..f33bb4753ff3 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts @@ -6,7 +6,7 @@ import { getTestContainer, getTestDatabase, removeAllDatabases } from "../common const doc = { id: "myId", pk: "pk" }; -describe("ResourceLink Trimming of leading and trailing slashes", function() { +describe("ResourceLink Trimming of leading and trailing slashes", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); const containerId = "testcontainer"; @@ -39,7 +39,7 @@ describe("ResourceLink Trimming of leading and trailing slashes", function() { }); }); -describe("Test Query Metrics", function() { +describe("Test Query Metrics", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 20000); const collectionId = "testCollection2"; @@ -84,7 +84,7 @@ describe("Test Query Metrics", function() { }); }); -describe("Partition key in FeedOptions", function() { +describe("Partition key in FeedOptions", /** @this Mocha.Context */ function() { this.timeout(process.env.MOCHA_TIMEOUT || 10000); beforeEach(async function() { diff --git a/sdk/cosmosdb/cosmos/test/tsdoc.json b/sdk/cosmosdb/cosmos/test/tsdoc.json new file mode 100644 index 000000000000..76f784c0fb5c --- /dev/null +++ b/sdk/cosmosdb/cosmos/test/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": ["../../../../tsdoc.json"] +} diff --git a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts index 57bdc840281a..7b9c98393f4b 100644 --- a/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts +++ b/sdk/eventgrid/eventgrid/test/eventGridClient.spec.ts @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/* eslint-disable no-invalid-this */ import { assert } from "chai"; @@ -19,7 +18,7 @@ import { import { FullOperationResponse } from "@azure/core-client"; import { RestError } from "@azure/core-rest-pipeline"; -describe("EventGridPublisherClient", function() { +describe("EventGridPublisherClient", /** @this Mocha.Context */ function() { let recorder: Recorder; let res: FullOperationResponse | undefined; @@ -32,14 +31,16 @@ describe("EventGridPublisherClient", function() { describe("#send (EventGrid schema)", function() { let client: EventGridPublisherClient<"EventGrid">; - beforeEach(function() { - ({ client, recorder } = createRecordedClient( - this, - testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT, - "EventGrid", - new AzureKeyCredential(testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_API_KEY) - )); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ client, recorder } = createRecordedClient( + this, + testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT, + "EventGrid", + new AzureKeyCredential(testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_API_KEY) + )); + } + ); afterEach(async function() { await recorder.stop(); @@ -99,14 +100,16 @@ describe("EventGridPublisherClient", function() { describe("#send error cases (EventGrid schema)", function() { let client: EventGridPublisherClient<"EventGrid">; - beforeEach(function() { - ({ client, recorder } = createRecordedClient( - this, - removeApiEventsSuffix(testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT), - "EventGrid", - new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY) - )); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ client, recorder } = createRecordedClient( + this, + removeApiEventsSuffix(testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT), + "EventGrid", + new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY) + )); + } + ); afterEach(async function() { await recorder.stop(); @@ -142,14 +145,16 @@ describe("EventGridPublisherClient", function() { describe("#send (CloudEvent schema)", function() { let client: EventGridPublisherClient<"CloudEvent">; - beforeEach(function() { - ({ client, recorder } = createRecordedClient( - this, - testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT, - "CloudEvent", - new AzureKeyCredential(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY) - )); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ client, recorder } = createRecordedClient( + this, + testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT, + "CloudEvent", + new AzureKeyCredential(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY) + )); + } + ); afterEach(async function() { await recorder.stop(); @@ -251,14 +256,16 @@ describe("EventGridPublisherClient", function() { describe("#send error cases (CloudEvent schema)", function() { let client: EventGridPublisherClient<"CloudEvent">; - beforeEach(function() { - ({ client, recorder } = createRecordedClient( - this, - removeApiEventsSuffix(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT), - "CloudEvent", - new AzureKeyCredential(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY) - )); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ client, recorder } = createRecordedClient( + this, + removeApiEventsSuffix(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT), + "CloudEvent", + new AzureKeyCredential(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY) + )); + } + ); afterEach(async function() { await recorder.stop(); @@ -292,14 +299,16 @@ describe("EventGridPublisherClient", function() { describe("#send (Custom Event Schema)", function() { let client: EventGridPublisherClient<"Custom">; - beforeEach(function() { - ({ client, recorder } = createRecordedClient( - this, - testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT, - "Custom", - new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY) - )); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ client, recorder } = createRecordedClient( + this, + testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT, + "Custom", + new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY) + )); + } + ); afterEach(async function() { await recorder.stop(); @@ -353,14 +362,16 @@ describe("EventGridPublisherClient", function() { describe("#send error cases (Custom Event Schema)", function() { let client: EventGridPublisherClient<"Custom">; - beforeEach(function() { - ({ client, recorder } = createRecordedClient( - this, - removeApiEventsSuffix(testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT), - "Custom", - new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY) - )); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ client, recorder } = createRecordedClient( + this, + removeApiEventsSuffix(testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT), + "Custom", + new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY) + )); + } + ); afterEach(async function() { await recorder.stop(); diff --git a/sdk/formrecognizer/ai-form-recognizer/test/public/browser/formrecognizerclient.spec.ts b/sdk/formrecognizer/ai-form-recognizer/test/public/browser/formrecognizerclient.spec.ts index 34ff37fbd453..03515611079a 100644 --- a/sdk/formrecognizer/ai-form-recognizer/test/public/browser/formrecognizerclient.spec.ts +++ b/sdk/formrecognizer/ai-form-recognizer/test/public/browser/formrecognizerclient.spec.ts @@ -16,10 +16,11 @@ describe("FormRecognizerClient browser only", () => { let recorder: Recorder; const apiKey = new AzureKeyCredential(testEnv.FORM_RECOGNIZER_API_KEY); - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - ({ recorder, client } = createRecordedRecognizerClient(this, apiKey)); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ recorder, client } = createRecordedRecognizerClient(this, apiKey)); + } + ); afterEach(async function() { if (recorder) { diff --git a/sdk/formrecognizer/ai-form-recognizer/test/public/formtrainingclient.spec.ts b/sdk/formrecognizer/ai-form-recognizer/test/public/formtrainingclient.spec.ts index e270e294cb15..582c49f61c1f 100644 --- a/sdk/formrecognizer/ai-form-recognizer/test/public/formtrainingclient.spec.ts +++ b/sdk/formrecognizer/ai-form-recognizer/test/public/formtrainingclient.spec.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/* eslint-disable no-invalid-this */ - import { assert } from "chai"; import { Context } from "mocha"; @@ -29,9 +27,11 @@ matrix([[true, false]] as const, async (useAad) => { describe(`[${useAad ? "AAD" : "API Key"}] FormTrainingClient`, () => { let recorder: Recorder; - beforeEach(function(this: Context) { - recorder = createRecorder(this); - }); + beforeEach( + /** @this Mocha.Context */ function(this: Context) { + recorder = createRecorder(this); + } + ); afterEach(async function() { await recorder.stop(); diff --git a/sdk/formrecognizer/ai-form-recognizer/test/public/node/formrecognizerclient.spec.ts b/sdk/formrecognizer/ai-form-recognizer/test/public/node/formrecognizerclient.spec.ts index 33cf1eeb2ee8..09094bd24aa4 100644 --- a/sdk/formrecognizer/ai-form-recognizer/test/public/node/formrecognizerclient.spec.ts +++ b/sdk/formrecognizer/ai-form-recognizer/test/public/node/formrecognizerclient.spec.ts @@ -28,11 +28,12 @@ matrix([[true, false]] as const, async (useAad) => { let client: FormRecognizerClient; let recorder: Recorder; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - recorder = createRecorder(this); - client = new FormRecognizerClient(endpoint(), makeCredential(useAad)); - }); + beforeEach( + /** @this Mocha.Context */ function() { + recorder = createRecorder(this); + client = new FormRecognizerClient(endpoint(), makeCredential(useAad)); + } + ); afterEach(async function() { if (recorder) { diff --git a/sdk/identity/identity/test/internal/identityClient.spec.ts b/sdk/identity/identity/test/internal/identityClient.spec.ts index be51be197996..41a6471af3c1 100644 --- a/sdk/identity/identity/test/internal/identityClient.spec.ts +++ b/sdk/identity/identity/test/internal/identityClient.spec.ts @@ -77,9 +77,8 @@ describe("IdentityClient", function() { ); }); - it("throws an exception when an Env AZURE_AUTHORITY_HOST using 'http' is provided", async function() { + it("throws an exception when an Env AZURE_AUTHORITY_HOST using 'http' is provided", /** @this Mocha.Context */ async function() { if (!isNode) { - // eslint-disable-next-line no-invalid-this return this.skip(); } process.env.AZURE_AUTHORITY_HOST = "http://totallyinsecure.lol"; diff --git a/sdk/keyvault/keyvault-admin/.eslintrc.json b/sdk/keyvault/keyvault-admin/.eslintrc.json index aa4842f828a5..03b4c28d1be5 100644 --- a/sdk/keyvault/keyvault-admin/.eslintrc.json +++ b/sdk/keyvault/keyvault-admin/.eslintrc.json @@ -4,7 +4,6 @@ "ignorePatterns": ["src/generated"], "rules": { "@typescript-eslint/no-this-alias": "off", - "no-invalid-this": "off", "@azure/azure-sdk/ts-package-json-module": "warn", "no-use-before-define": "warn" } diff --git a/sdk/keyvault/keyvault-certificates/.eslintrc.json b/sdk/keyvault/keyvault-certificates/.eslintrc.json index 903cedb0fb82..dda4b269063f 100644 --- a/sdk/keyvault/keyvault-certificates/.eslintrc.json +++ b/sdk/keyvault/keyvault-certificates/.eslintrc.json @@ -4,7 +4,6 @@ "ignorePatterns": ["src/core"], "rules": { "@typescript-eslint/no-this-alias": "off", - "no-invalid-this": "off", "@azure/azure-sdk/ts-package-json-module": "warn", "no-use-before-define": "warn" } diff --git a/sdk/keyvault/keyvault-certificates/test/internal/challengeBasedAuthenticationPolicy.spec.ts b/sdk/keyvault/keyvault-certificates/test/internal/challengeBasedAuthenticationPolicy.spec.ts index 5922a3d59a53..97c489b37405 100644 --- a/sdk/keyvault/keyvault-certificates/test/internal/challengeBasedAuthenticationPolicy.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/internal/challengeBasedAuthenticationPolicy.spec.ts @@ -32,13 +32,15 @@ describe("Challenge based authentication tests", () => { subject: "cn=MyCert" }; - beforeEach(async function() { - const authentication = await authenticate(this); - certificateSuffix = authentication.suffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + certificateSuffix = authentication.suffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -46,7 +48,7 @@ describe("Challenge based authentication tests", () => { // The tests follow - it("Authentication should work for parallel requests", async function() { + it("Authentication should work for parallel requests", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` ); @@ -84,7 +86,7 @@ describe("Challenge based authentication tests", () => { sandbox.restore(); }); - it("Once authenticated, new requests should not authenticate again", async function() { + it("Once authenticated, new requests should not authenticate again", /** @this Mocha.Context */ async function() { // Our goal is to intercept how our pipelines are storing the challenge. // The first network call should indeed set the challenge in memory. // Subsequent network calls should not set new challenges. diff --git a/sdk/keyvault/keyvault-certificates/test/internal/userAgent.spec.ts b/sdk/keyvault/keyvault-certificates/test/internal/userAgent.spec.ts index 993c96794dcc..2949f7e2475b 100644 --- a/sdk/keyvault/keyvault-certificates/test/internal/userAgent.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/internal/userAgent.spec.ts @@ -13,7 +13,7 @@ describe("Certificates client's user agent (only in Node, because of fs)", () => assert.equal(SDK_VERSION, packageVersion); }); - it("the version should also match with the one available in the package.json (only in Node, because of fs)", async function() { + it("the version should also match with the one available in the package.json (only in Node, because of fs)", /** @this Mocha.Context */ async function() { if (!isNode) { this.skip(); return; diff --git a/sdk/keyvault/keyvault-certificates/test/public/CRUD.spec.ts b/sdk/keyvault/keyvault-certificates/test/public/CRUD.spec.ts index 8a104af66f33..d0431553ed36 100644 --- a/sdk/keyvault/keyvault-certificates/test/public/CRUD.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/public/CRUD.spec.ts @@ -32,16 +32,18 @@ describe("Certificates client - create, read, update and delete", () => { subject: "cn=MyCert" }; - beforeEach(async function() { - const authentication = await authenticate(this); - suffix = authentication.suffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - keyVaultUrl = authentication.keyVaultUrl; - credential = authentication.credential; - secretClient = new SecretClient(keyVaultUrl, credential); - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + suffix = authentication.suffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + keyVaultUrl = authentication.keyVaultUrl; + credential = authentication.credential; + secretClient = new SecretClient(keyVaultUrl, credential); + } + ); afterEach(async function() { await recorder.stop(); @@ -49,7 +51,7 @@ describe("Certificates client - create, read, update and delete", () => { // The tests follow - it("can create a certificate", async function() { + it("can create a certificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const poller = await client.beginCreateCertificate( certificateName, @@ -65,7 +67,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.flushCertificate(certificateName); }); - it("can abort creating a certificate", async function() { + it("can abort creating a certificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const controller = new AbortController(); @@ -80,7 +82,7 @@ describe("Certificates client - create, read, update and delete", () => { }); // On playback mode, the tests happen too fast for the timeout to work - in browsers - it("can create a certificate with requestOptions timeout", async function() { + it("can create a certificate with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip("browser", "Timeout tests don't work on playback mode."); const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); @@ -114,7 +116,7 @@ describe("Certificates client - create, read, update and delete", () => { ); }); - it("can update the tags of a certificate", async function() { + it("can update the tags of a certificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( @@ -137,7 +139,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.flushCertificate(certificateName); }); - it("can disable a certificate", async function() { + it("can disable a certificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const poller = await client.beginCreateCertificate( @@ -160,7 +162,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.flushCertificate(certificateName); }); - it("can disable a certificate version", async function() { + it("can disable a certificate version", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const poller = await client.beginCreateCertificate( @@ -186,7 +188,7 @@ describe("Certificates client - create, read, update and delete", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can update certificate with requestOptions timeout", async function() { + it("can update certificate with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); @@ -207,7 +209,7 @@ describe("Certificates client - create, read, update and delete", () => { }); }); - it("can get a certificate", async function() { + it("can get a certificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( certificateName, @@ -223,7 +225,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.flushCertificate(certificateName); }); - it("can get a certificate's secret in PKCS 12 format", async function() { + it("can get a certificate's secret in PKCS 12 format", /** @this Mocha.Context */ async function() { recorder.skip("browser", "This test uses the file system."); // Skipping this test from the live browser test runs, because we use the file system. if (!isNode) { @@ -272,7 +274,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.flushCertificate(certificateName); }); - it("can get a certificate's secret in PEM format", async function() { + it("can get a certificate's secret in PEM format", /** @this Mocha.Context */ async function() { recorder.skip("browser", "This test uses the file system."); // Skipping this test from the live browser test runs, because we use the file system. if (!isNode) { @@ -308,7 +310,7 @@ describe("Certificates client - create, read, update and delete", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can get a certificate with requestOptions timeout", async function() { + it("can get a certificate with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( @@ -321,7 +323,7 @@ describe("Certificates client - create, read, update and delete", () => { }); }); - it("can retrieve the latest version of a certificate value", async function() { + it("can retrieve the latest version of a certificate value", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( certificateName, @@ -339,7 +341,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.flushCertificate(certificateName); }); - it("can get a certificate (Non Existing)", async function() { + it("can get a certificate (Non Existing)", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); let error; try { @@ -352,7 +354,7 @@ describe("Certificates client - create, read, update and delete", () => { assert.equal(error.statusCode, 404); }); - it("can delete a certificate", async function() { + it("can delete a certificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( certificateName, @@ -382,7 +384,7 @@ describe("Certificates client - create, read, update and delete", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can delete a certificate with requestOptions timeout", async function() { + it("can delete a certificate with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( @@ -400,7 +402,7 @@ describe("Certificates client - create, read, update and delete", () => { }); }); - it("can delete a certificate (Non Existing)", async function() { + it("can delete a certificate (Non Existing)", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); let error; try { @@ -414,7 +416,7 @@ describe("Certificates client - create, read, update and delete", () => { }); describe("can get a deleted certificate", () => { - it("using beginDeleteCertificate's poller", async function() { + it("using beginDeleteCertificate's poller", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( certificateName, @@ -436,7 +438,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.purgeCertificate(certificateName); }); - it("using getDeletedCertificate", async function() { + it("using getDeletedCertificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( certificateName, @@ -460,7 +462,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.purgeCertificate(certificateName); }); - it("can not get a certificate that never existed", async function() { + it("can not get a certificate that never existed", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); let error; try { @@ -474,7 +476,7 @@ describe("Certificates client - create, read, update and delete", () => { }); }); - it("can create, read, and delete a certificate issuer", async function() { + it("can create, read, and delete a certificate issuer", /** @this Mocha.Context */ async function() { const issuerName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); @@ -540,7 +542,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.flushCertificate(certificateName); }); - it("can update a certificate's policy", async function() { + it("can update a certificate's policy", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( @@ -562,7 +564,7 @@ describe("Certificates client - create, read, update and delete", () => { await testClient.flushCertificate(certificateName); }); - it("can read, cancel and delete a certificate's operation", async function() { + it("can read, cancel and delete a certificate's operation", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); await client.beginCreateCertificate( certificateName, diff --git a/sdk/keyvault/keyvault-certificates/test/public/list.spec.ts b/sdk/keyvault/keyvault-certificates/test/public/list.spec.ts index b0cc4699b45e..0509116495b5 100644 --- a/sdk/keyvault/keyvault-certificates/test/public/list.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/public/list.spec.ts @@ -26,13 +26,15 @@ describe("Certificates client - list certificates in various ways", () => { subject: "cn=MyCert" }; - beforeEach(async function() { - const authentication = await authenticate(this); - suffix = authentication.suffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + suffix = authentication.suffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -43,7 +45,7 @@ describe("Certificates client - list certificates in various ways", () => { // Use this while recording to make sure the target keyvault is clean. // The next tests will produce a more consistent output. // This test is only useful while developing locally. - it("can purge all certificates", async function(): Promise { + it("can purge all certificates", /** @this Mocha.Context */ async function(): Promise { // WARNING: When TEST_MODE equals "record", all of the certificates in the indicated KEYVAULT_NAME will be deleted as part of this test. if (!isRecordMode()) { return this.skip(); @@ -66,7 +68,7 @@ describe("Certificates client - list certificates in various ways", () => { } }); - it("can list certificates", async function() { + it("can list certificates", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const certificateNames = [`${certificateName}0`, `${certificateName}1`]; for (const name of certificateNames) { @@ -92,7 +94,7 @@ describe("Certificates client - list certificates in various ways", () => { } }); - it("can list deleted certificates", async function() { + it("can list deleted certificates", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const certificateNames = [`${certificateName}0`, `${certificateName}1`]; for (const name of certificateNames) { @@ -122,7 +124,7 @@ describe("Certificates client - list certificates in various ways", () => { } }); - it("can list certificates by page", async function() { + it("can list certificates by page", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const certificateNames = [`${certificateName}0`, `${certificateName}1`]; for (const name of certificateNames) { @@ -159,7 +161,7 @@ describe("Certificates client - list certificates in various ways", () => { }); } - it("can list deleted certificates by page", async function() { + it("can list deleted certificates by page", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const certificateNames = [`${certificateName}0`, `${certificateName}1`]; for (const name of certificateNames) { @@ -198,7 +200,7 @@ describe("Certificates client - list certificates in various ways", () => { }); }); - it("can retrieve all versions of a certificate", async function() { + it("can retrieve all versions of a certificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const certificateTags = ["tag01", "tag02", "tag03"]; @@ -255,7 +257,7 @@ describe("Certificates client - list certificates in various ways", () => { }); }); - it("can list certificate versions (non existing)", async function() { + it("can list certificate versions (non existing)", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); let totalVersions = 0; for await (const page of client.listPropertiesOfCertificateVersions(certificateName).byPage()) { diff --git a/sdk/keyvault/keyvault-certificates/test/public/lro.create.spec.ts b/sdk/keyvault/keyvault-certificates/test/public/lro.create.spec.ts index 0319285aff35..e03d00b8a8e1 100644 --- a/sdk/keyvault/keyvault-certificates/test/public/lro.create.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/public/lro.create.spec.ts @@ -17,13 +17,15 @@ describe("Certificates client - LRO - create", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - certificateSuffix = authentication.suffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + certificateSuffix = authentication.suffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -31,7 +33,7 @@ describe("Certificates client - LRO - create", () => { // The tests follow - it("can wait until a certificate is created", async function() { + it("can wait until a certificate is created", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` ); @@ -55,7 +57,7 @@ describe("Certificates client - LRO - create", () => { await testClient.flushCertificate(certificateName); }); - it("can resume from a stopped poller", async function() { + it("can resume from a stopped poller", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` ); diff --git a/sdk/keyvault/keyvault-certificates/test/public/lro.delete.spec.ts b/sdk/keyvault/keyvault-certificates/test/public/lro.delete.spec.ts index fdc67af0149b..028bb40d82d5 100644 --- a/sdk/keyvault/keyvault-certificates/test/public/lro.delete.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/public/lro.delete.spec.ts @@ -17,13 +17,15 @@ describe("Certificates client - lro - delete", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - certificateSuffix = authentication.suffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + certificateSuffix = authentication.suffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -31,7 +33,7 @@ describe("Certificates client - lro - delete", () => { // The tests follow - it("can wait until a certificate is deleted", async function() { + it("can wait until a certificate is deleted", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` ); @@ -61,7 +63,7 @@ describe("Certificates client - lro - delete", () => { await testClient.purgeCertificate(certificateName); }); - it("can resume from a stopped poller", async function() { + it("can resume from a stopped poller", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` ); diff --git a/sdk/keyvault/keyvault-certificates/test/public/lro.operation.spec.ts b/sdk/keyvault/keyvault-certificates/test/public/lro.operation.spec.ts index 3f617de0025b..afbdfd974767 100644 --- a/sdk/keyvault/keyvault-certificates/test/public/lro.operation.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/public/lro.operation.spec.ts @@ -21,13 +21,15 @@ describe("Certificates client - LRO - certificate operation", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - certificateSuffix = authentication.suffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + certificateSuffix = authentication.suffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -35,7 +37,7 @@ describe("Certificates client - LRO - certificate operation", () => { // The tests follow - it("can wait until a certificate is created by getting the poller from getCertificateOperation", async function() { + it("can wait until a certificate is created by getting the poller from getCertificateOperation", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` ); @@ -64,7 +66,7 @@ describe("Certificates client - LRO - certificate operation", () => { await testClient.flushCertificate(certificateName); }); - it("can resume from a stopped poller", async function() { + it("can resume from a stopped poller", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` ); diff --git a/sdk/keyvault/keyvault-certificates/test/public/lro.recover.spec.ts b/sdk/keyvault/keyvault-certificates/test/public/lro.recover.spec.ts index 4f615e7d8024..1dbf31eb4cd3 100644 --- a/sdk/keyvault/keyvault-certificates/test/public/lro.recover.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/public/lro.recover.spec.ts @@ -18,13 +18,15 @@ describe("Certificates client - LRO - recoverDelete", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - certificateSuffix = authentication.suffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + certificateSuffix = authentication.suffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -32,7 +34,7 @@ describe("Certificates client - LRO - recoverDelete", () => { // The tests follow - it("can wait until a certificate is recovered", async function() { + it("can wait until a certificate is recovered", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` ); @@ -65,7 +67,7 @@ describe("Certificates client - LRO - recoverDelete", () => { await testClient.flushCertificate(certificateName); }); - it("can resume from a stopped poller", async function() { + it("can resume from a stopped poller", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` ); @@ -112,7 +114,7 @@ describe("Certificates client - LRO - recoverDelete", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can recover a deleted certificate with requestOptions timeout", async function() { + it("can recover a deleted certificate with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const certificateName = testClient.formatName( `${certificatePrefix}-${this!.test!.title}-${certificateSuffix}` diff --git a/sdk/keyvault/keyvault-certificates/test/public/mergeAndImport.spec.ts b/sdk/keyvault/keyvault-certificates/test/public/mergeAndImport.spec.ts index 2c28b8328f82..9a01a66cb025 100644 --- a/sdk/keyvault/keyvault-certificates/test/public/mergeAndImport.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/public/mergeAndImport.spec.ts @@ -24,16 +24,18 @@ describe("Certificates client - merge and import certificates", () => { let credential: ClientSecretCredential; let secretClient: SecretClient; - beforeEach(async function() { - const authentication = await authenticate(this); - suffix = authentication.suffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - keyVaultUrl = authentication.keyVaultUrl; - credential = authentication.credential; - secretClient = new SecretClient(keyVaultUrl, credential); - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + suffix = authentication.suffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + keyVaultUrl = authentication.keyVaultUrl; + credential = authentication.credential; + secretClient = new SecretClient(keyVaultUrl, credential); + } + ); afterEach(async function() { await recorder.stop(); @@ -41,7 +43,7 @@ describe("Certificates client - merge and import certificates", () => { // The tests follow - it("can import a certificate from a certificate's non base64 secret value", async function() { + it("can import a certificate from a certificate's non base64 secret value", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const certificateNames = [`${certificateName}0`, `${certificateName}1`]; const createPoller = await client.beginCreateCertificate( @@ -65,7 +67,7 @@ describe("Certificates client - merge and import certificates", () => { } }); - it("can import a certificate from a certificate's base64 secret value", async function() { + it("can import a certificate from a certificate's base64 secret value", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const certificateNames = [`${certificateName}0`, `${certificateName}1`]; const createPoller = await client.beginCreateCertificate( @@ -95,7 +97,9 @@ describe("Certificates client - merge and import certificates", () => { // The signed certificate will never be the same, so we can't play it back. // This test is only designed to work on NodeJS, since we use child_process to interact with openssl. - it("can merge a self signed certificate", async function(): Promise { + it("can merge a self signed certificate", /** @this Mocha.Context */ async function(): Promise< + void + > { recorder.skip( undefined, "The signed certificate will never be the same, so we can't play it back." diff --git a/sdk/keyvault/keyvault-certificates/test/public/recoverBackupRestore.spec.ts b/sdk/keyvault/keyvault-certificates/test/public/recoverBackupRestore.spec.ts index 4fb5d7f28462..097780726e50 100644 --- a/sdk/keyvault/keyvault-certificates/test/public/recoverBackupRestore.spec.ts +++ b/sdk/keyvault/keyvault-certificates/test/public/recoverBackupRestore.spec.ts @@ -23,13 +23,15 @@ describe("Certificates client - restore certificates and recover backups", () => subject: "cn=MyCert" }; - beforeEach(async function() { - const authentication = await authenticate(this); - suffix = authentication.suffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + suffix = authentication.suffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -37,7 +39,7 @@ describe("Certificates client - restore certificates and recover backups", () => // The tests follow - it("can recover a deleted certificate", async function() { + it("can recover a deleted certificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const createPoller = await client.beginCreateCertificate( certificateName, @@ -65,7 +67,7 @@ describe("Certificates client - restore certificates and recover backups", () => await testClient.flushCertificate(certificateName); }); - it("can recover a deleted certificate (non existing)", async function() { + it("can recover a deleted certificate (non existing)", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); let error; try { @@ -81,7 +83,7 @@ describe("Certificates client - restore certificates and recover backups", () => if (isRecordMode() || isPlaybackMode()) { // This test can't run live, // since the purge operation currently can't be expected to finish anytime soon. - it("can restore a certificate", async function() { + it("can restore a certificate", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const createPoller = await client.beginCreateCertificate( certificateName, @@ -141,7 +143,7 @@ describe("Certificates client - restore certificates and recover backups", () => if (isNode && !isPlaybackMode()) { // On playback mode, the tests happen too fast for the timeout to work - it("can restore a key with requestOptions timeout", async function() { + it("can restore a key with requestOptions timeout", /** @this Mocha.Context */ async function() { const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); const createPoller = await client.beginCreateCertificate( certificateName, diff --git a/sdk/keyvault/keyvault-certificates/test/utils/lro/restore/operation.ts b/sdk/keyvault/keyvault-certificates/test/utils/lro/restore/operation.ts index fc950e86d3b8..e9eabd39902f 100644 --- a/sdk/keyvault/keyvault-certificates/test/utils/lro/restore/operation.ts +++ b/sdk/keyvault/keyvault-certificates/test/utils/lro/restore/operation.ts @@ -54,6 +54,7 @@ export interface RestoreCertificateBackupPollOperation /** * Reaches to the service and updates the restore certificate's poll operation. * @param options - The optional parameters, which are an abortSignal from \@azure/abort-controller and a function that triggers the poller's onProgress function. + * @this RestoreCertificateBackupPollOperation */ async function update( this: RestoreCertificateBackupPollOperation, @@ -92,6 +93,7 @@ async function cancel(this: RestoreCertificateBackupPollOperation): Promise> 3), // Generate a symmetric key for testing - kty: "oct" - }; + jwk = { + keyOps: ["encrypt", "decrypt", "wrapKey", "unwrapKey"], + k: getKey(keySize >> 3), // Generate a symmetric key for testing + kty: "oct" + }; - cryptoClient = new CryptographyClient(jwk); - }); + cryptoClient = new CryptographyClient(jwk); + } + ); describe(`AES-CBC with PKCS padding (${keySize})`, () => { describe("local-only tests", async function() { - it("encrypts and decrypts locally", async function() { + it("encrypts and decrypts locally", /** @this Mocha.Context */ async function() { const text = this.test!.title; const encryptResult = await cryptoClient.encrypt({ algorithm: encryptionAlgorithm, @@ -75,7 +77,7 @@ describe("AesCryptographyProvider internal tests", function() { assert.equal(uint8ArrayToString(decryptResult.result), text); }); - it("validates the key type", async function() { + it("validates the key type", /** @this Mocha.Context */ async function() { const text = this.test!.title; jwk.kty = "RSA"; @@ -98,7 +100,7 @@ describe("AesCryptographyProvider internal tests", function() { ); }); - it("validates the key length", async function() { + it("validates the key length", /** @this Mocha.Context */ async function() { const text = this.test!.title; jwk.k = getKey((keySize >> 3) - 1); @@ -132,27 +134,29 @@ describe("AesCryptographyProvider internal tests", function() { let keyVaultKey: KeyVaultKey; let remoteProvider: RemoteCryptographyProvider; - beforeEach(async function() { - const authentication = await authenticate(this); - recorder = authentication.recorder; - - if (!authentication.hsmClient) { - // Managed HSM is not deployed for this run due to service resource restrictions so we skip these tests. - // This is only necessary while Managed HSM is in preview. - this.skip(); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + recorder = authentication.recorder; + + if (!authentication.hsmClient) { + // Managed HSM is not deployed for this run due to service resource restrictions so we skip these tests. + // This is only necessary while Managed HSM is in preview. + this.skip(); + } + + client = authentication.hsmClient; + credential = authentication.credential; + testClient = new TestClient(authentication.hsmClient); + keySuffix = authentication.keySuffix; } - - client = authentication.hsmClient; - credential = authentication.credential; - testClient = new TestClient(authentication.hsmClient); - keySuffix = authentication.keySuffix; - }); + ); afterEach(async function() { await recorder.stop(); }); - it("encrypts locally and decrypts remotely", async function() { + it("encrypts locally and decrypts remotely", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this.test!.title}-${keySuffix}`); keyVaultKey = await client.importKey(keyName, jwk, {}); remoteProvider = new RemoteCryptographyProvider(keyVaultKey, credential); @@ -174,7 +178,7 @@ describe("AesCryptographyProvider internal tests", function() { await testClient.flushKey(keyName); }); - it("encrypts remotely and decrypts locally", async function() { + it("encrypts remotely and decrypts locally", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this.test!.title}-${keySuffix}`); keyVaultKey = await client.importKey(keyName, jwk, {}); remoteProvider = new RemoteCryptographyProvider(keyVaultKey, credential); diff --git a/sdk/keyvault/keyvault-keys/test/internal/challengeBasedAuthenticationPolicy.spec.ts b/sdk/keyvault/keyvault-keys/test/internal/challengeBasedAuthenticationPolicy.spec.ts index a9be2e0db0ce..6adc6eef74b8 100644 --- a/sdk/keyvault/keyvault-keys/test/internal/challengeBasedAuthenticationPolicy.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/internal/challengeBasedAuthenticationPolicy.spec.ts @@ -26,13 +26,15 @@ describe("Challenge based authentication tests", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - keySuffix = authentication.keySuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + keySuffix = authentication.keySuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -40,7 +42,7 @@ describe("Challenge based authentication tests", () => { // The tests follow - it("Authentication should work for parallel requests", async function() { + it("Authentication should work for parallel requests", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const keyNames = [`${keyName}-0`, `${keyName}-1`]; @@ -71,7 +73,7 @@ describe("Challenge based authentication tests", () => { sandbox.restore(); }); - it("Once authenticated, new requests should not authenticate again", async function() { + it("Once authenticated, new requests should not authenticate again", /** @this Mocha.Context */ async function() { // Our goal is to intercept how our pipelines are storing the challenge. // The first network call should indeed set the challenge in memory. // Subsequent network calls should not set new challenges. diff --git a/sdk/keyvault/keyvault-keys/test/internal/crypto.spec.ts b/sdk/keyvault/keyvault-keys/test/internal/crypto.spec.ts index 0a2da2002ab6..ed0e5f4dbfbf 100644 --- a/sdk/keyvault/keyvault-keys/test/internal/crypto.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/internal/crypto.spec.ts @@ -135,7 +135,7 @@ describe("internal crypto tests", () => { }); describe("Encrypt parameter mapping", async function() { - it("maps parameters correctly when using the previous API", async function() { + it("maps parameters correctly when using the previous API", /** @this Mocha.Context */ async function() { const text = stringToUint8Array(this.test!.title!); await client.encrypt("RSA1_5", text, { requestOptions: { timeout: 5 } }); @@ -146,7 +146,7 @@ describe("internal crypto tests", () => { ); }); - it("maps parameters correctly when using the current API", async function() { + it("maps parameters correctly when using the current API", /** @this Mocha.Context */ async function() { const text = stringToUint8Array(this.test!.title!); await client.encrypt( @@ -163,7 +163,7 @@ describe("internal crypto tests", () => { }); describe("Decrypt parameter mapping", async function() { - it("maps parameters correctly when using the previous API", async function() { + it("maps parameters correctly when using the previous API", /** @this Mocha.Context */ async function() { const text = stringToUint8Array(this.test!.title!); await client.decrypt("RSA1_5", text, { requestOptions: { timeout: 5 } }); @@ -174,7 +174,7 @@ describe("internal crypto tests", () => { ); }); - it("maps parameters correctly when using the current API", async function() { + it("maps parameters correctly when using the current API", /** @this Mocha.Context */ async function() { const text = stringToUint8Array(this.test!.title!); await client.decrypt( @@ -192,7 +192,7 @@ describe("internal crypto tests", () => { }); describe("RSA local cryptography tests", function() { - it("throws a validation error when the key is invalid", function() { + it("throws a validation error when the key is invalid", /** @this Mocha.Context */ function() { if (!isNode) { // Local cryptography is not supported in the browser this.skip(); @@ -204,7 +204,7 @@ describe("internal crypto tests", () => { ); }); - it("uses the browser replacement when running in the browser", function() { + it("uses the browser replacement when running in the browser", /** @this Mocha.Context */ function() { if (isNode) { this.skip(); } diff --git a/sdk/keyvault/keyvault-keys/test/internal/userAgent.spec.ts b/sdk/keyvault/keyvault-keys/test/internal/userAgent.spec.ts index 6571b5891ffe..13ea672ba6fe 100644 --- a/sdk/keyvault/keyvault-keys/test/internal/userAgent.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/internal/userAgent.spec.ts @@ -13,7 +13,7 @@ describe("Keys client's user agent (only in Node, because of fs)", () => { assert.equal(SDK_VERSION, packageVersion); }); - it("the version should also match with the one available in the package.json (only in Node, because of fs)", async function() { + it("the version should also match with the one available in the package.json (only in Node, because of fs)", /** @this Mocha.Context */ async function() { if (!isNode) { this.skip(); return; diff --git a/sdk/keyvault/keyvault-keys/test/public/CRUD.hsm.spec.ts b/sdk/keyvault/keyvault-keys/test/public/CRUD.hsm.spec.ts index 89d926d862c2..5f09ae91ab6f 100644 --- a/sdk/keyvault/keyvault-keys/test/public/CRUD.hsm.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/CRUD.hsm.spec.ts @@ -16,26 +16,28 @@ describe("Keys client - create, read, update and delete operations for managed H let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - recorder = authentication.recorder; - - if (!authentication.hsmClient) { - // Managed HSM is not deployed for this run due to service resource restrictions so we skip these tests. - // This is only necessary while Managed HSM is in preview. - this.skip(); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + recorder = authentication.recorder; + + if (!authentication.hsmClient) { + // Managed HSM is not deployed for this run due to service resource restrictions so we skip these tests. + // This is only necessary while Managed HSM is in preview. + this.skip(); + } + + hsmClient = authentication.hsmClient; + keySuffix = authentication.keySuffix; + testClient = new TestClient(authentication.hsmClient); } - - hsmClient = authentication.hsmClient; - keySuffix = authentication.keySuffix; - testClient = new TestClient(authentication.hsmClient); - }); + ); afterEach(async function() { await recorder.stop(); }); - it("can create an OCT key with options", async function() { + it("can create an OCT key with options", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const options: CreateOctKeyOptions = { hsm: true diff --git a/sdk/keyvault/keyvault-keys/test/public/CRUD.spec.ts b/sdk/keyvault/keyvault-keys/test/public/CRUD.spec.ts index c1515e588bff..6afa8e5bd20e 100644 --- a/sdk/keyvault/keyvault-keys/test/public/CRUD.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/CRUD.spec.ts @@ -24,13 +24,15 @@ describe("Keys client - create, read, update and delete operations", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - keySuffix = authentication.keySuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + keySuffix = authentication.keySuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -38,7 +40,7 @@ describe("Keys client - create, read, update and delete operations", () => { // The tests follow - it("can create a key while giving a manual type", async function() { + it("can create a key while giving a manual type", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const result = await client.createKey(keyName, "RSA"); assert.equal(result.name, keyName, "Unexpected key name in result from createKey()."); @@ -46,7 +48,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can abort creating a key", async function() { + it("can abort creating a key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const controller = new AbortController(); @@ -60,7 +62,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can create a key with requestOptions timeout", async function() { + it("can create a key with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await assertThrowsAbortError(async () => { @@ -88,14 +90,14 @@ describe("Keys client - create, read, update and delete operations", () => { ); }); - it("can create a RSA key", async function() { + it("can create a RSA key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const result = await client.createRsaKey(keyName); assert.equal(result.name, keyName, "Unexpected key name in result from createKey()."); await testClient.flushKey(keyName); }); - it("can create a RSA key with size", async function() { + it("can create a RSA key with size", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const options = { keySize: 2048 @@ -105,7 +107,7 @@ describe("Keys client - create, read, update and delete operations", () => { await testClient.flushKey(keyName); }); - it("can create a RSA key with public exponent", async function() { + it("can create a RSA key with public exponent", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const options = { publicExponent: 3 @@ -116,7 +118,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can create a RSA key with requestOptions timeout", async function() { + it("can create a RSA key with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); @@ -129,14 +131,14 @@ describe("Keys client - create, read, update and delete operations", () => { }); }); - it("can create an EC key", async function() { + it("can create an EC key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const result = await client.createEcKey(keyName); assert.equal(result.name, keyName, "Unexpected key name in result from createKey()."); await testClient.flushKey(keyName); }); - it("can create an EC key with curve", async function() { + it("can create an EC key with curve", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const options: CreateEcKeyOptions = { curve: "P-256" @@ -147,7 +149,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can create an EC key with requestOptions timeout", async function() { + it("can create an EC key with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await assertThrowsAbortError(async () => { @@ -159,7 +161,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); }); - it("can create a disabled key", async function() { + it("can create a disabled key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const options = { enabled: false @@ -169,7 +171,7 @@ describe("Keys client - create, read, update and delete operations", () => { await testClient.flushKey(keyName); }); - it("can create a key with notBefore", async function() { + it("can create a key with notBefore", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const date = new Date("2019-01-01"); const notBefore = new Date(date.getTime() + 5000); // 5 seconds later @@ -187,7 +189,7 @@ describe("Keys client - create, read, update and delete operations", () => { await testClient.flushKey(keyName); }); - it("can create a key with expires", async function() { + it("can create a key with expires", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const date = new Date("2019-01-01"); const expiresOn = new Date(date.getTime() + 5000); // 5 seconds later @@ -205,7 +207,7 @@ describe("Keys client - create, read, update and delete operations", () => { await testClient.flushKey(keyName); }); - it("can update key", async function() { + it("can update key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const { version } = (await client.createRsaKey(keyName)).properties; const options: UpdateKeyPropertiesOptions = { enabled: false }; @@ -214,7 +216,7 @@ describe("Keys client - create, read, update and delete operations", () => { await testClient.flushKey(keyName); }); - it("can update a disabled key", async function() { + it("can update a disabled key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const createOptions = { enabled: false @@ -233,7 +235,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can update key with requestOptions timeout", async function() { + it("can update key with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const { version } = (await client.createRsaKey(keyName)).properties; @@ -246,7 +248,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); }); - it("can delete a key", async function() { + it("can delete a key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const poller = await client.beginDeleteKey(keyName, testPollerProperties); @@ -267,7 +269,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can delete a key with requestOptions timeout", async function() { + it("can delete a key with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); @@ -281,7 +283,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); }); - it("delete nonexisting key", async function() { + it("delete nonexisting key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); try { await client.getKey(keyName); @@ -296,7 +298,7 @@ describe("Keys client - create, read, update and delete operations", () => { } }); - it("can get a key", async function() { + it("can get a key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const getResult = await client.getKey(keyName); @@ -305,7 +307,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can get a key with requestOptions timeout", async function() { + it("can get a key with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); @@ -314,7 +316,7 @@ describe("Keys client - create, read, update and delete operations", () => { }); }); - it("can get a specific version of a key", async function() { + it("can get a specific version of a key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const { version } = (await client.createKey(keyName, "RSA")).properties; const options: GetKeyOptions = { version }; @@ -327,7 +329,7 @@ describe("Keys client - create, read, update and delete operations", () => { await testClient.flushKey(keyName); }); - it("can get a deleted key", async function() { + it("can get a deleted key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const poller = await client.beginDeleteKey(keyName, testPollerProperties); @@ -348,7 +350,7 @@ describe("Keys client - create, read, update and delete operations", () => { await testClient.purgeKey(keyName); }); - it("can't get a deleted key that doesn't exist", async function() { + it("can't get a deleted key that doesn't exist", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); let error; try { @@ -362,7 +364,7 @@ describe("Keys client - create, read, update and delete operations", () => { assert.equal(error.statusCode, 404); }); - it("can purge a deleted key", async function() { + it("can purge a deleted key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const poller = await client.beginDeleteKey(keyName, testPollerProperties); diff --git a/sdk/keyvault/keyvault-keys/test/public/crypto.hsm.spec.ts b/sdk/keyvault/keyvault-keys/test/public/crypto.hsm.spec.ts index 824fd839a5b0..7dc9798bae9a 100644 --- a/sdk/keyvault/keyvault-keys/test/public/crypto.hsm.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/crypto.hsm.spec.ts @@ -20,22 +20,24 @@ describe("CryptographyClient for managed HSM (skipped if MHSM is not deployed)", let keyVaultKey: KeyVaultKey; let keySuffix: string; - beforeEach(async function() { - const authentication = await authenticate(this); - recorder = authentication.recorder; + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + recorder = authentication.recorder; - if (!authentication.hsmClient) { - // Managed HSM is not deployed for this run due to service resource restrictions so we skip these tests. - // This is only necessary while Managed HSM is in preview. - this.skip(); - } + if (!authentication.hsmClient) { + // Managed HSM is not deployed for this run due to service resource restrictions so we skip these tests. + // This is only necessary while Managed HSM is in preview. + this.skip(); + } - hsmClient = authentication.hsmClient; - testClient = new TestClient(authentication.hsmClient); - credential = authentication.credential; - keySuffix = authentication.keySuffix; - keyName = testClient.formatName("cryptography-client-test" + keySuffix); - }); + hsmClient = authentication.hsmClient; + testClient = new TestClient(authentication.hsmClient); + credential = authentication.credential; + keySuffix = authentication.keySuffix; + keyName = testClient.formatName("cryptography-client-test" + keySuffix); + } + ); afterEach(async function() { await testClient?.flushKey(keyName); @@ -43,7 +45,7 @@ describe("CryptographyClient for managed HSM (skipped if MHSM is not deployed)", }); describe("with AES crypto algorithms", async function() { - it("encrypts and decrypts using AES-GCM", async function() { + it("encrypts and decrypts using AES-GCM", /** @this Mocha.Context */ async function() { keyVaultKey = await hsmClient.createKey(keyName, "AES", { keySize: 256 }); cryptoClient = new CryptographyClient(keyVaultKey.id!, credential); const text = this.test!.title; @@ -63,7 +65,7 @@ describe("CryptographyClient for managed HSM (skipped if MHSM is not deployed)", assert.equal(text, uint8ArrayToString(decryptResult.result)); }); - it("encrypts and decrypts using AES-CBC", async function() { + it("encrypts and decrypts using AES-CBC", /** @this Mocha.Context */ async function() { keyVaultKey = await hsmClient.createKey(keyName, "AES", { keySize: 256 }); cryptoClient = new CryptographyClient(keyVaultKey.id!, credential); const text = this.test!.title; diff --git a/sdk/keyvault/keyvault-keys/test/public/crypto.spec.ts b/sdk/keyvault/keyvault-keys/test/public/crypto.spec.ts index db100bfe9e97..d7938fa66152 100644 --- a/sdk/keyvault/keyvault-keys/test/public/crypto.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/crypto.spec.ts @@ -29,29 +29,33 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { return; } - beforeEach(async function() { - const authentication = await authenticate(this); - client = authentication.client; - recorder = authentication.recorder; - testClient = authentication.testClient; - credential = authentication.credential; - keySuffix = authentication.keySuffix; - keyName = testClient.formatName("cryptography-client-test" + keySuffix); - keyVaultKey = await client.createKey(keyName, "RSA"); - cryptoClient = new CryptographyClient(keyVaultKey.id!, credential); - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + client = authentication.client; + recorder = authentication.recorder; + testClient = authentication.testClient; + credential = authentication.credential; + keySuffix = authentication.keySuffix; + keyName = testClient.formatName("cryptography-client-test" + keySuffix); + keyVaultKey = await client.createKey(keyName, "RSA"); + cryptoClient = new CryptographyClient(keyVaultKey.id!, credential); + } + ); - afterEach(async function() { - if (!this.currentTest?.isPending()) { - await testClient.flushKey(keyName); + afterEach( + /** @this Mocha.Context */ async function() { + if (!this.currentTest?.isPending()) { + await testClient.flushKey(keyName); + } + await recorder.stop(); } - await recorder.stop(); - }); + ); // The tests follow if (!isPlaybackMode()) { - it("encrypt & decrypt with RSA1_5", async function() { + it("encrypt & decrypt with RSA1_5", /** @this Mocha.Context */ async function() { const text = this.test!.title; const encryptResult = await cryptoClient.encrypt({ algorithm: "RSA1_5", @@ -65,7 +69,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { assert.equal(text, decryptedText); }); - it("manually encrypt locally and decrypt remotely, both with RSA1_5", async function() { + it("manually encrypt locally and decrypt remotely, both with RSA1_5", /** @this Mocha.Context */ async function() { const text = this.test!.title; const localProvider = new RsaCryptographyProvider(keyVaultKey.key!); const encryptResult = await localProvider.encrypt({ @@ -80,7 +84,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { assert.equal(text, decryptedText); }); - it("encrypt & decrypt with RSA-OAEP", async function() { + it("encrypt & decrypt with RSA-OAEP", /** @this Mocha.Context */ async function() { const text = this.test!.title; const encryptResult = await cryptoClient.encrypt( { @@ -97,7 +101,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { assert.equal(text, decryptedText); }); - it("manually encrypt locally and decrypt remotely, both with RSA-OAEP", async function() { + it("manually encrypt locally and decrypt remotely, both with RSA-OAEP", /** @this Mocha.Context */ async function() { const text = this.test!.title; const localProvider = new RsaCryptographyProvider(keyVaultKey.key!); const encryptResult = await localProvider.encrypt({ @@ -112,7 +116,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { assert.equal(text, decryptedText); }); - it("the CryptographyClient can be created from a full KeyVaultKey object", async function() { + it("the CryptographyClient can be created from a full KeyVaultKey object", /** @this Mocha.Context */ async function() { const customKeyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const customKeyVaultKey = await client.createKey(customKeyName, "RSA"); const cryptoClientFromKey = new CryptographyClient(customKeyVaultKey, credential); @@ -162,7 +166,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { assert.equal("RSA1_5", unwrappedResult.algorithm); }); - it("wrap and unwrap with RSA-OAEP", async function() { + it("wrap and unwrap with RSA-OAEP", /** @this Mocha.Context */ async function() { recorder.skip( undefined, "Wrapping and unwrapping don't cause a repeatable pattern, so these tests can only run in playback mode" @@ -176,7 +180,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { }); if (!isPlaybackMode()) { - it("encrypt & decrypt with an RSA-HSM key and the RSA-OAEP algorithm", async function() { + it("encrypt & decrypt with an RSA-HSM key and the RSA-OAEP algorithm", /** @this Mocha.Context */ async function() { const hsmKeyName = keyName + "2"; const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM"); const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential); @@ -188,7 +192,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { await testClient.flushKey(hsmKeyName); }); - it("encrypt & decrypt with an RSA-HSM key and the RSA1_5 algorithm", async function() { + it("encrypt & decrypt with an RSA-HSM key and the RSA1_5 algorithm", /** @this Mocha.Context */ async function() { const hsmKeyName = keyName + "2"; const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM"); const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential); @@ -201,7 +205,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { }); } - it("wrap and unwrap with RSA-OAEP on a RSA-HSM key", async function() { + it("wrap and unwrap with RSA-OAEP on a RSA-HSM key", /** @this Mocha.Context */ async function() { recorder.skip( undefined, "Wrapping and unwrapping don't cause a repeatable pattern, so this test can only run live" @@ -217,7 +221,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { await testClient.flushKey(hsmKeyName); }); - it("wrap and unwrap with RSA1_5 on a RSA-HSM key", async function() { + it("wrap and unwrap with RSA1_5 on a RSA-HSM key", /** @this Mocha.Context */ async function() { recorder.skip( undefined, "Wrapping and unwrapping don't cause a repeatable pattern, so this test can only run live" @@ -233,7 +237,9 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { await testClient.flushKey(hsmKeyName); }); - it("sign and verify with RS256 through an RSA-HSM key", async function(): Promise { + it("sign and verify with RS256 through an RSA-HSM key", /** @this Mocha.Context */ async function(): Promise< + void + > { const hsmKeyName = keyName + "2"; const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM"); const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential); @@ -264,7 +270,9 @@ describe("CryptographyClient (all decrypts happen remotely)", () => { await testClient.flushKey(hsmKeyName); }); - it("sign and verify with RS384 through an RSA-HSM key", async function(): Promise { + it("sign and verify with RS384 through an RSA-HSM key", /** @this Mocha.Context */ async function(): Promise< + void + > { const hsmKeyName = keyName + "2"; const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM"); const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential); diff --git a/sdk/keyvault/keyvault-keys/test/public/import.spec.ts b/sdk/keyvault/keyvault-keys/test/public/import.spec.ts index 2788491f14f5..73dc9c9aef3e 100644 --- a/sdk/keyvault/keyvault-keys/test/public/import.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/import.spec.ts @@ -16,13 +16,15 @@ describe("Keys client - import keys", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - suffix = authentication.keySuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + suffix = authentication.keySuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -30,7 +32,7 @@ describe("Keys client - import keys", () => { // The tests follow - it("can import a key", async function() { + it("can import a key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`); function toBytes(hex: string): Uint8Array { if (hex.length % 2) { diff --git a/sdk/keyvault/keyvault-keys/test/public/list.spec.ts b/sdk/keyvault/keyvault-keys/test/public/list.spec.ts index c077dcfa82e4..b69f177d6253 100644 --- a/sdk/keyvault/keyvault-keys/test/public/list.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/list.spec.ts @@ -20,13 +20,15 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this, serviceVersion); - keySuffix = authentication.keySuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this, serviceVersion); + keySuffix = authentication.keySuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -37,7 +39,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { // Use this while recording to make sure the target keyvault is clean. // The next tests will produce a more consistent output. // This test is only useful while developing locally. - it("can purge all keys", async function(): Promise { + it("can purge all keys", /** @this Mocha.Context */ async function(): Promise { // WARNING: When TEST_MODE equals "record", all of the keys in the indicated KEYVAULT_URI will be deleted as part of this test. if (!isRecordMode()) { return this.skip(); @@ -58,7 +60,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { } }); - it("can get the versions of a key", async function() { + it("can get the versions of a key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); let totalVersions = 0; @@ -85,7 +87,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { }); }); - it("can get the versions of a key (paged)", async function() { + it("can get the versions of a key (paged)", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); let totalVersions = 0; @@ -103,7 +105,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { await testClient.flushKey(keyName); }); - it("list 0 versions of a non-existing key", async function() { + it("list 0 versions of a non-existing key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); let totalVersions = 0; for await (const version of client.listPropertiesOfKeyVersions(keyName)) { @@ -117,7 +119,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { assert.equal(totalVersions, 0, `Unexpected total versions for key ${keyName}`); }); - it("list 0 versions of a non-existing key (paged)", async function() { + it("list 0 versions of a non-existing key (paged)", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); let totalVersions = 0; for await (const page of client.listPropertiesOfKeyVersions(keyName).byPage()) { @@ -133,7 +135,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { assert.equal(totalVersions, 0, `Unexpected total versions for key ${keyName}`); }); - it("can get several inserted keys", async function() { + it("can get several inserted keys", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const keyNames = [`${keyName}-0`, `${keyName}-1`]; for (const name of keyNames) { @@ -164,7 +166,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { }); }); - it("can get several inserted keys (paged)", async function() { + it("can get several inserted keys (paged)", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const keyNames = [`${keyName}-0`, `${keyName}-1`]; for (const name of keyNames) { @@ -187,7 +189,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { } }); - it("list deleted keys", async function() { + it("list deleted keys", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const keyNames = [`${keyName}-0`, `${keyName}-1`]; for (const name of keyNames) { @@ -221,7 +223,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => { }); }); - it("list deleted keys (paged)", async function() { + it("list deleted keys (paged)", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const keyNames = [`${keyName}-0`, `${keyName}-1`]; for (const name of keyNames) { diff --git a/sdk/keyvault/keyvault-keys/test/public/localCryptography.spec.ts b/sdk/keyvault/keyvault-keys/test/public/localCryptography.spec.ts index 8444cb2e4863..6b877d10cfaa 100644 --- a/sdk/keyvault/keyvault-keys/test/public/localCryptography.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/localCryptography.spec.ts @@ -33,14 +33,16 @@ describe("Local cryptography public tests", () => { return; } - beforeEach(async function() { - const authentication = await authenticate(this); - client = authentication.client; - recorder = authentication.recorder; - testClient = authentication.testClient; - credential = authentication.credential; - keySuffix = authentication.keySuffix; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + client = authentication.client; + recorder = authentication.recorder; + testClient = authentication.testClient; + credential = authentication.credential; + keySuffix = authentication.keySuffix; + } + ); afterEach(async function() { await recorder.stop(); @@ -51,11 +53,13 @@ describe("Local cryptography public tests", () => { let customKeyVaultKey: KeyVaultKey; let cryptoClientFromKey: CryptographyClient; - beforeEach(async function() { - customKeyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); - customKeyVaultKey = await client.createKey(customKeyName, "RSA"); - cryptoClientFromKey = new CryptographyClient(customKeyVaultKey.key!); - }); + beforeEach( + /** @this Mocha.Context */ async function() { + customKeyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); + customKeyVaultKey = await client.createKey(customKeyName, "RSA"); + cryptoClientFromKey = new CryptographyClient(customKeyVaultKey.key!); + } + ); it("the CryptographyClient can be created from a local JsonWebKey object", async function() { assert.isEmpty(cryptoClientFromKey.vaultUrl); @@ -123,7 +127,7 @@ describe("Local cryptography public tests", () => { }); }); - it("encrypt & decrypt RSA1_5", async function() { + it("encrypt & decrypt RSA1_5", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Local encryption can't be tested on playback"); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const keyVaultKey = await client.createKey(keyName, "RSA"); @@ -137,7 +141,7 @@ describe("Local cryptography public tests", () => { await testClient.flushKey(keyName); }); - it("encrypt & decrypt RSA-OAEP", async function() { + it("encrypt & decrypt RSA-OAEP", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Local encryption can't be tested on playback"); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const keyVaultKey = await client.createKey(keyName, "RSA"); @@ -151,7 +155,7 @@ describe("Local cryptography public tests", () => { await testClient.flushKey(keyName); }); - it("wrapKey & unwrapKey RSA1_5", async function() { + it("wrapKey & unwrapKey RSA1_5", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Local encryption can't be tested on playback"); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const keyVaultKey = await client.createKey(keyName, "RSA"); @@ -168,7 +172,7 @@ describe("Local cryptography public tests", () => { await testClient.flushKey(keyName); }); - it("wrapKey & unwrapKey RSA-OAEP", async function() { + it("wrapKey & unwrapKey RSA-OAEP", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Local encryption can't be tested on playback"); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); const keyVaultKey = await client.createKey(keyName, "RSA"); @@ -190,35 +194,43 @@ describe("Local cryptography public tests", () => { const localSupportedAlgorithmNames = Object.keys(rsaProvider.signatureAlgorithmToHashAlgorithm); for (const localAlgorithmName of localSupportedAlgorithmNames) { - it(localAlgorithmName, async function(): Promise { - recorder.skip( - "browser", - `Local sign of algorithm ${localAlgorithmName} is only supported in NodeJS` - ); - - const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); - const keyVaultKey = await client.createKey(keyName, "RSA"); - const cryptoClient = new CryptographyClient(keyVaultKey.id!, credential); - - // Sign is not implemented yet. - // This boils down to the JWK to PEM conversion, which doesn't support private keys at the moment. - const signatureValue = this.test!.title; - const hash = createHash(rsaProvider.signatureAlgorithmToHashAlgorithm[localAlgorithmName]); - hash.update(signatureValue); - const digest = hash.digest(); - const signature = await cryptoClient.sign(localAlgorithmName as SignatureAlgorithm, digest); - - // Local Cryptography Client part - const localCryptoClient = new CryptographyClient(keyVaultKey.key!); - const verifyResult = await localCryptoClient.verifyData( - localAlgorithmName as LocalSupportedAlgorithmName, - digest, - signature.result - ); - assert.ok(verifyResult); - - await testClient.flushKey(keyName); - }); + it( + localAlgorithmName, + /** @this Mocha.Context */ async function(): Promise { + recorder.skip( + "browser", + `Local sign of algorithm ${localAlgorithmName} is only supported in NodeJS` + ); + + const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); + const keyVaultKey = await client.createKey(keyName, "RSA"); + const cryptoClient = new CryptographyClient(keyVaultKey.id!, credential); + + // Sign is not implemented yet. + // This boils down to the JWK to PEM conversion, which doesn't support private keys at the moment. + const signatureValue = this.test!.title; + const hash = createHash( + rsaProvider.signatureAlgorithmToHashAlgorithm[localAlgorithmName] + ); + hash.update(signatureValue); + const digest = hash.digest(); + const signature = await cryptoClient.sign( + localAlgorithmName as SignatureAlgorithm, + digest + ); + + // Local Cryptography Client part + const localCryptoClient = new CryptographyClient(keyVaultKey.key!); + const verifyResult = await localCryptoClient.verifyData( + localAlgorithmName as LocalSupportedAlgorithmName, + digest, + signature.result + ); + assert.ok(verifyResult); + + await testClient.flushKey(keyName); + } + ); } }); }); diff --git a/sdk/keyvault/keyvault-keys/test/public/lro.delete.spec.ts b/sdk/keyvault/keyvault-keys/test/public/lro.delete.spec.ts index 0ed4ab39d9a0..7184d8dbaa2f 100644 --- a/sdk/keyvault/keyvault-keys/test/public/lro.delete.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/lro.delete.spec.ts @@ -17,13 +17,15 @@ describe("Keys client - Long Running Operations - delete", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - keySuffix = authentication.keySuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + keySuffix = authentication.keySuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -31,7 +33,7 @@ describe("Keys client - Long Running Operations - delete", () => { // The tests follow - it("can wait until a key is deleted", async function() { + it("can wait until a key is deleted", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const poller = await client.beginDeleteKey(keyName, testPollerProperties); @@ -50,7 +52,7 @@ describe("Keys client - Long Running Operations - delete", () => { await testClient.purgeKey(keyName); }); - it("can resume from a stopped poller", async function() { + it("can resume from a stopped poller", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const poller = await client.beginDeleteKey(keyName, testPollerProperties); diff --git a/sdk/keyvault/keyvault-keys/test/public/lro.recoverDelete.spec.ts b/sdk/keyvault/keyvault-keys/test/public/lro.recoverDelete.spec.ts index 315d3d0fa0fe..ac8769138cfd 100644 --- a/sdk/keyvault/keyvault-keys/test/public/lro.recoverDelete.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/lro.recoverDelete.spec.ts @@ -18,13 +18,15 @@ describe("Keys client - Long Running Operations - recoverDelete", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - keySuffix = authentication.keySuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + keySuffix = authentication.keySuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -32,7 +34,7 @@ describe("Keys client - Long Running Operations - recoverDelete", () => { // The tests follow - it("can wait until a key is recovered", async function() { + it("can wait until a key is recovered", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); @@ -55,7 +57,7 @@ describe("Keys client - Long Running Operations - recoverDelete", () => { await testClient.flushKey(keyName); }); - it("can resume from a stopped poller", async function() { + it("can resume from a stopped poller", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const deletePoller = await client.beginDeleteKey(keyName, testPollerProperties); @@ -92,7 +94,7 @@ describe("Keys client - Long Running Operations - recoverDelete", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can recover a deleted key with requestOptions timeout", async function() { + it("can recover a deleted key with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); diff --git a/sdk/keyvault/keyvault-keys/test/public/recoverBackupRestore.spec.ts b/sdk/keyvault/keyvault-keys/test/public/recoverBackupRestore.spec.ts index 9ad2b2582cff..14cfaba62c4f 100644 --- a/sdk/keyvault/keyvault-keys/test/public/recoverBackupRestore.spec.ts +++ b/sdk/keyvault/keyvault-keys/test/public/recoverBackupRestore.spec.ts @@ -17,13 +17,15 @@ describe("Keys client - restore keys and recover backups", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - keySuffix = authentication.keySuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + keySuffix = authentication.keySuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -31,7 +33,7 @@ describe("Keys client - restore keys and recover backups", () => { // The tests follow - it("can recover a deleted key", async function() { + it("can recover a deleted key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const deletePoller = await client.beginDeleteKey(keyName, testPollerProperties); @@ -52,7 +54,7 @@ describe("Keys client - restore keys and recover backups", () => { await testClient.flushKey(keyName); }); - it("fails if one tries to recover a non-existing deleted key", async function() { + it("fails if one tries to recover a non-existing deleted key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); let error; try { @@ -66,7 +68,7 @@ describe("Keys client - restore keys and recover backups", () => { assert.equal(error.statusCode, 404); }); - it("can generate a backup of a key", async function() { + it("can generate a backup of a key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const result = await client.backupKey(keyName); @@ -87,7 +89,7 @@ describe("Keys client - restore keys and recover backups", () => { }); }); - it("fails to generate a backup of a non-existing key", async function() { + it("fails to generate a backup of a non-existing key", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); let error; try { @@ -103,7 +105,7 @@ describe("Keys client - restore keys and recover backups", () => { if (isRecordMode() || isPlaybackMode()) { // This test can't run live, // since the purge operation currently can't be expected to finish anytime soon. - it("can restore a key with a given backup", async function() { + it("can restore a key with a given backup", /** @this Mocha.Context */ async function() { const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); const backup = await client.backupKey(keyName); @@ -126,7 +128,7 @@ describe("Keys client - restore keys and recover backups", () => { } // On playback mode, the tests happen too fast for the timeout to work - it("can restore a key with requestOptions timeout", async function() { + it("can restore a key with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`); await client.createKey(keyName, "RSA"); diff --git a/sdk/keyvault/keyvault-keys/test/utils/lro/restore/operation.ts b/sdk/keyvault/keyvault-keys/test/utils/lro/restore/operation.ts index 1e91f24e96c5..84c4cf59cb2b 100644 --- a/sdk/keyvault/keyvault-keys/test/utils/lro/restore/operation.ts +++ b/sdk/keyvault/keyvault-keys/test/utils/lro/restore/operation.ts @@ -53,6 +53,7 @@ export interface RestoreKeyBackupPollOperation /** * Reaches to the service and updates the restore key's poll operation. * @param options - The optional parameters, which are an abortSignal from \@azure/abort-controller and a function that triggers the poller's onProgress function. + * @this RestoreKeyBackupPollOperation */ async function update( this: RestoreKeyBackupPollOperation, @@ -91,6 +92,7 @@ async function cancel(this: RestoreKeyBackupPollOperation): Promise { /** * Serializes the create key's poll operation + * @this RestoreKeyBackupPollOperation */ function toString(this: RestoreKeyBackupPollOperation): string { return JSON.stringify({ diff --git a/sdk/keyvault/keyvault-secrets/.eslintrc.json b/sdk/keyvault/keyvault-secrets/.eslintrc.json index 903cedb0fb82..dda4b269063f 100644 --- a/sdk/keyvault/keyvault-secrets/.eslintrc.json +++ b/sdk/keyvault/keyvault-secrets/.eslintrc.json @@ -4,7 +4,6 @@ "ignorePatterns": ["src/core"], "rules": { "@typescript-eslint/no-this-alias": "off", - "no-invalid-this": "off", "@azure/azure-sdk/ts-package-json-module": "warn", "no-use-before-define": "warn" } diff --git a/sdk/keyvault/keyvault-secrets/test/internal/challengeBasedAuthenticationPolicy.spec.ts b/sdk/keyvault/keyvault-secrets/test/internal/challengeBasedAuthenticationPolicy.spec.ts index 62410d2a7d36..5c3c9adddbb2 100644 --- a/sdk/keyvault/keyvault-secrets/test/internal/challengeBasedAuthenticationPolicy.spec.ts +++ b/sdk/keyvault/keyvault-secrets/test/internal/challengeBasedAuthenticationPolicy.spec.ts @@ -26,13 +26,15 @@ describe("Challenge based authentication tests", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - secretSuffix = authentication.secretSuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + secretSuffix = authentication.secretSuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -40,7 +42,7 @@ describe("Challenge based authentication tests", () => { // The tests follow - it("Authentication should work for parallel requests", async function() { + it("Authentication should work for parallel requests", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -73,7 +75,7 @@ describe("Challenge based authentication tests", () => { sandbox.restore(); }); - it("Once authenticated, new requests should not authenticate again", async function() { + it("Once authenticated, new requests should not authenticate again", /** @this Mocha.Context */ async function() { // Our goal is to intercept how our pipelines are storing the challenge. // The first network call should indeed set the challenge in memory. // Subsequent network calls should not set new challenges. diff --git a/sdk/keyvault/keyvault-secrets/test/internal/userAgent.spec.ts b/sdk/keyvault/keyvault-secrets/test/internal/userAgent.spec.ts index a599906cc5c2..a2f06913dcc9 100644 --- a/sdk/keyvault/keyvault-secrets/test/internal/userAgent.spec.ts +++ b/sdk/keyvault/keyvault-secrets/test/internal/userAgent.spec.ts @@ -13,7 +13,7 @@ describe("Secrets client's user agent (only in Node, because of fs)", () => { assert.equal(SDK_VERSION, packageVersion); }); - it("the version should also match with the one available in the package.json (only in Node, because of fs)", async function() { + it("the version should also match with the one available in the package.json (only in Node, because of fs)", /** @this Mocha.Context */ async function() { if (!isNode) { this.skip(); return; diff --git a/sdk/keyvault/keyvault-secrets/test/public/CRUD.spec.ts b/sdk/keyvault/keyvault-secrets/test/public/CRUD.spec.ts index ddd9c6ab29eb..d941ee8c085e 100644 --- a/sdk/keyvault/keyvault-secrets/test/public/CRUD.spec.ts +++ b/sdk/keyvault/keyvault-secrets/test/public/CRUD.spec.ts @@ -19,13 +19,15 @@ describe("Secret client - create, read, update and delete operations", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - secretSuffix = authentication.secretSuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + secretSuffix = authentication.secretSuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -33,7 +35,7 @@ describe("Secret client - create, read, update and delete operations", () => { // The tests follow - it("can add a secret", async function() { + it("can add a secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -45,7 +47,7 @@ describe("Secret client - create, read, update and delete operations", () => { // If this test is not skipped in the browser's playback, no other test will be played back. // This is a bug related to the browser features of the recorder. - it("can abort adding a secret", async function() { + it("can abort adding a secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -59,7 +61,7 @@ describe("Secret client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can timeout adding a secret", async function() { + it("can timeout adding a secret", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` @@ -89,7 +91,7 @@ describe("Secret client - create, read, update and delete operations", () => { ); }); - it("can set a secret with Empty Value", async function() { + it("can set a secret with Empty Value", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -104,7 +106,7 @@ describe("Secret client - create, read, update and delete operations", () => { await testClient.flushSecret(secretName); }); - it("can set a secret with attributes", async function() { + it("can set a secret with attributes", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -120,7 +122,7 @@ describe("Secret client - create, read, update and delete operations", () => { await testClient.flushSecret(secretName); }); - it("can update a secret", async function() { + it("can update a secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -142,7 +144,7 @@ describe("Secret client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can timeout updating a secret", async function() { + it("can timeout updating a secret", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` @@ -161,7 +163,7 @@ describe("Secret client - create, read, update and delete operations", () => { }); }); - it("can update a disabled secret", async function() { + it("can update a disabled secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -182,7 +184,7 @@ describe("Secret client - create, read, update and delete operations", () => { await testClient.flushSecret(secretName); }); - it("can get a secret", async function() { + it("can get a secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -194,7 +196,7 @@ describe("Secret client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can timeout getting a secret", async function() { + it("can timeout getting a secret", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` @@ -209,7 +211,7 @@ describe("Secret client - create, read, update and delete operations", () => { }); }); - it("can't get a disabled secret", async function() { + it("can't get a disabled secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -234,7 +236,7 @@ describe("Secret client - create, read, update and delete operations", () => { await testClient.flushSecret(secretName); }); - it("can retrieve the latest version of a secret value", async function() { + it("can retrieve the latest version of a secret value", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -247,7 +249,7 @@ describe("Secret client - create, read, update and delete operations", () => { await testClient.flushSecret(secretName); }); - it("can get a secret (Non Existing)", async function() { + it("can get a secret (Non Existing)", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -262,7 +264,7 @@ describe("Secret client - create, read, update and delete operations", () => { assert.equal(error.statusCode, 404); }); - it("can delete a secret", async function() { + it("can delete a secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -293,7 +295,7 @@ describe("Secret client - create, read, update and delete operations", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can timeout deleting a secret", async function() { + it("can timeout deleting a secret", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` @@ -309,7 +311,7 @@ describe("Secret client - create, read, update and delete operations", () => { }); }); - it("can delete a secret (Non Existing)", async function() { + it("can delete a secret (Non Existing)", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -324,7 +326,7 @@ describe("Secret client - create, read, update and delete operations", () => { assert.equal(error.statusCode, 404); }); - it("can get a deleted secret", async function() { + it("can get a deleted secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -351,7 +353,7 @@ describe("Secret client - create, read, update and delete operations", () => { await testClient.purgeSecret(secretName); }); - it("can get a deleted secret (Non Existing)", async function() { + it("can get a deleted secret (Non Existing)", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); diff --git a/sdk/keyvault/keyvault-secrets/test/public/list.spec.ts b/sdk/keyvault/keyvault-secrets/test/public/list.spec.ts index 20a6ccb4ed8e..a32c8c0bf77c 100644 --- a/sdk/keyvault/keyvault-secrets/test/public/list.spec.ts +++ b/sdk/keyvault/keyvault-secrets/test/public/list.spec.ts @@ -21,13 +21,15 @@ describe("Secret client - list secrets in various ways", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - secretSuffix = authentication.secretSuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + secretSuffix = authentication.secretSuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -38,7 +40,7 @@ describe("Secret client - list secrets in various ways", () => { // Use this while recording to make sure the target keyvault is clean. // The next tests will produce a more consistent output. // This test is only useful while developing locally. - it("can purge all secrets", async function(): Promise { + it("can purge all secrets", /** @this Mocha.Context */ async function(): Promise { // WARNING: When TEST_MODE equals "record", all of the secrets in the indicated KEYVAULT_URI will be deleted as part of this test. if (!isRecordMode()) { return this.skip(); @@ -59,7 +61,7 @@ describe("Secret client - list secrets in various ways", () => { } }); - it("can list secret properties", async function() { + it("can list secret properties", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -83,7 +85,7 @@ describe("Secret client - list secrets in various ways", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can get secret properties with requestOptions timeout", async function() { + it("can get secret properties with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const iter = client.listPropertiesOfSecrets({ requestOptions: { timeout: 1 } @@ -93,7 +95,7 @@ describe("Secret client - list secrets in various ways", () => { }); }); - it("can list deleted secrets", async function() { + it("can list deleted secrets", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -132,7 +134,7 @@ describe("Secret client - list secrets in various ways", () => { }); }); - it("can retrieve all versions of a secret", async function() { + it("can retrieve all versions of a secret", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` @@ -175,7 +177,7 @@ describe("Secret client - list secrets in various ways", () => { }); }); - it("can list secret versions (non existing)", async function() { + it("can list secret versions (non existing)", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -191,7 +193,7 @@ describe("Secret client - list secrets in various ways", () => { assert.equal(totalVersions, 0, `Unexpected total versions for secret ${secretName}`); }); - it("can list secrets by page", async function() { + it("can list secrets by page", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -213,7 +215,7 @@ describe("Secret client - list secrets in various ways", () => { } }); - it("can list deleted secrets by page", async function() { + it("can list deleted secrets by page", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -240,7 +242,7 @@ describe("Secret client - list secrets in various ways", () => { } }); - it("can retrieve all versions of a secret by page", async function() { + it("can retrieve all versions of a secret by page", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -273,7 +275,7 @@ describe("Secret client - list secrets in various ways", () => { await testClient.flushSecret(secretName); }); - it("can list secret versions by page (non existing)", async function() { + it("can list secret versions by page (non existing)", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); diff --git a/sdk/keyvault/keyvault-secrets/test/public/lro.delete.spec.ts b/sdk/keyvault/keyvault-secrets/test/public/lro.delete.spec.ts index dd1aa09114e0..60e83731f084 100644 --- a/sdk/keyvault/keyvault-secrets/test/public/lro.delete.spec.ts +++ b/sdk/keyvault/keyvault-secrets/test/public/lro.delete.spec.ts @@ -18,13 +18,15 @@ describe("Secrets client - Long Running Operations - delete", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - secretSuffix = authentication.secretSuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + secretSuffix = authentication.secretSuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -32,7 +34,7 @@ describe("Secrets client - Long Running Operations - delete", () => { // The tests follow - it("can wait until a secret is deleted", async function() { + it("can wait until a secret is deleted", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -53,7 +55,7 @@ describe("Secrets client - Long Running Operations - delete", () => { await testClient.purgeSecret(secretName); }); - it("can resume from a stopped poller", async function() { + it("can resume from a stopped poller", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -87,7 +89,7 @@ describe("Secrets client - Long Running Operations - delete", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can attempt to delete a secret with requestOptions timeout", async function() { + it("can attempt to delete a secret with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` diff --git a/sdk/keyvault/keyvault-secrets/test/public/lro.recover.spec.ts b/sdk/keyvault/keyvault-secrets/test/public/lro.recover.spec.ts index 87d222faa074..f26b4bb5b09f 100644 --- a/sdk/keyvault/keyvault-secrets/test/public/lro.recover.spec.ts +++ b/sdk/keyvault/keyvault-secrets/test/public/lro.recover.spec.ts @@ -18,13 +18,15 @@ describe("Secrets client - Long Running Operations - recoverDelete", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - secretSuffix = authentication.secretSuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + secretSuffix = authentication.secretSuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -32,7 +34,7 @@ describe("Secrets client - Long Running Operations - recoverDelete", () => { // The tests follow - it("can wait until a secret is recovered", async function() { + it("can wait until a secret is recovered", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -57,7 +59,7 @@ describe("Secrets client - Long Running Operations - recoverDelete", () => { await testClient.flushSecret(secretName); }); - it("can resume from a stopped poller", async function() { + it("can resume from a stopped poller", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -96,7 +98,7 @@ describe("Secrets client - Long Running Operations - recoverDelete", () => { }); // On playback mode, the tests happen too fast for the timeout to work - it("can attempt to recover a deleted secret with requestOptions timeout", async function() { + it("can attempt to recover a deleted secret with requestOptions timeout", /** @this Mocha.Context */ async function() { recorder.skip(undefined, "Timeout tests don't work on playback mode."); const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` diff --git a/sdk/keyvault/keyvault-secrets/test/public/recoverBackupRestore.spec.ts b/sdk/keyvault/keyvault-secrets/test/public/recoverBackupRestore.spec.ts index 9287c6766db7..84dc3f97a77d 100644 --- a/sdk/keyvault/keyvault-secrets/test/public/recoverBackupRestore.spec.ts +++ b/sdk/keyvault/keyvault-secrets/test/public/recoverBackupRestore.spec.ts @@ -18,13 +18,15 @@ describe("Secret client - restore secrets and recover backups", () => { let testClient: TestClient; let recorder: Recorder; - beforeEach(async function() { - const authentication = await authenticate(this); - secretSuffix = authentication.secretSuffix; - client = authentication.client; - testClient = authentication.testClient; - recorder = authentication.recorder; - }); + beforeEach( + /** @this Mocha.Context */ async function() { + const authentication = await authenticate(this); + secretSuffix = authentication.secretSuffix; + client = authentication.client; + testClient = authentication.testClient; + recorder = authentication.recorder; + } + ); afterEach(async function() { await recorder.stop(); @@ -32,7 +34,7 @@ describe("Secret client - restore secrets and recover backups", () => { // The tests follow - it("can recover a deleted secret", async function() { + it("can recover a deleted secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -62,7 +64,7 @@ describe("Secret client - restore secrets and recover backups", () => { await testClient.flushSecret(secretName); }); - it("can recover a deleted secret (non existing)", async function() { + it("can recover a deleted secret (non existing)", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -83,7 +85,7 @@ describe("Secret client - restore secrets and recover backups", () => { if (isNode && !isPlaybackMode()) { // On playback mode, the tests happen too fast for the timeout to work - it("can recover a deleted a secret with requestOptions timeout", async function() { + it("can recover a deleted a secret with requestOptions timeout", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -101,7 +103,7 @@ describe("Secret client - restore secrets and recover backups", () => { }); } - it("can backup a secret", async function() { + it("can backup a secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -119,7 +121,7 @@ describe("Secret client - restore secrets and recover backups", () => { await testClient.flushSecret(secretName); }); - it("can backup a secret (non existing)", async function() { + it("can backup a secret (non existing)", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -137,7 +139,7 @@ describe("Secret client - restore secrets and recover backups", () => { if (isRecordMode() || isPlaybackMode()) { // This test can't run live, // since the purge operation currently can't be expected to finish anytime soon. - it("can restore a secret", async function() { + it("can restore a secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); @@ -182,7 +184,7 @@ describe("Secret client - restore secrets and recover backups", () => { if (isNode && !isPlaybackMode()) { // On playback mode, the tests happen too fast for the timeout to work - it("can timeout deleting a secret", async function() { + it("can timeout deleting a secret", /** @this Mocha.Context */ async function() { const secretName = testClient.formatName( `${secretPrefix}-${this!.test!.title}-${secretSuffix}` ); diff --git a/sdk/keyvault/keyvault-secrets/test/utils/lro/restore/operation.ts b/sdk/keyvault/keyvault-secrets/test/utils/lro/restore/operation.ts index 4d141cbdf33b..be58e9a61eee 100644 --- a/sdk/keyvault/keyvault-secrets/test/utils/lro/restore/operation.ts +++ b/sdk/keyvault/keyvault-secrets/test/utils/lro/restore/operation.ts @@ -54,6 +54,7 @@ export interface RestoreSecretBackupPollOperation /** * Reaches to the service and updates the restore secret's poll operation. * @param options - The optional parameters, which are an abortSignal from \@azure/abort-controller and a function that triggers the poller's onProgress function. + * @this RestoreSecretBackupPollOperation */ async function update( this: RestoreSecretBackupPollOperation, @@ -92,6 +93,7 @@ async function cancel(this: RestoreSecretBackupPollOperation): Promise { /** * Serializes the create secret's poll operation + * @this RestoreSecretBackupPollOperation */ function toString(this: RestoreSecretBackupPollOperation): string { return JSON.stringify({ diff --git a/sdk/metricsadvisor/ai-metrics-advisor/test/public/adminclient.spec.ts b/sdk/metricsadvisor/ai-metrics-advisor/test/public/adminclient.spec.ts index e74e9c1a994d..ba12db6b72d3 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/test/public/adminclient.spec.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/test/public/adminclient.spec.ts @@ -19,10 +19,11 @@ matrix([[true, false]] as const, async (useAad) => { let client: MetricsAdvisorAdministrationClient; let recorder: Recorder; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - ({ recorder, client } = createRecordedAdminClient(this, makeCredential(useAad))); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ recorder, client } = createRecordedAdminClient(this, makeCredential(useAad))); + } + ); afterEach(async function() { if (recorder) { @@ -78,7 +79,7 @@ matrix([[true, false]] as const, async (useAad) => { assert.ok(result.latestActiveTimestamp, "Expecting valid latest active timestamp"); }); - it("refreshes ingesetion status", async function() { + it("refreshes ingesetion status", /** @this Mocha.Context */ async function() { const iterator = client.listDataFeedIngestionStatus( testEnv.METRICS_ADVISOR_AZURE_SQLSERVER_DATAFEED_ID, new Date(Date.UTC(2020, 7, 22)), @@ -101,7 +102,6 @@ matrix([[true, false]] as const, async (useAad) => { const result2 = await iterator2.next(); assert.notEqual(result2.value.status, "Succeeded"); } else { - // eslint-disable-next-line no-invalid-this this.skip(); } }); @@ -368,9 +368,8 @@ matrix([[true, false]] as const, async (useAad) => { } }); - it("deletes an alert configuration", async function() { + it("deletes an alert configuration", /** @this Mocha.Context */ async function() { if (!createdAlertConfigId) { - // eslint-disable-next-line no-invalid-this this.skip(); } @@ -383,9 +382,8 @@ matrix([[true, false]] as const, async (useAad) => { } }); - it("deletes a detection configuration", async function() { + it("deletes a detection configuration", /** @this Mocha.Context */ async function() { if (!createdDetectionConfigId) { - // eslint-disable-next-line no-invalid-this this.skip(); } diff --git a/sdk/metricsadvisor/ai-metrics-advisor/test/public/advisorclient.spec.ts b/sdk/metricsadvisor/ai-metrics-advisor/test/public/advisorclient.spec.ts index 46c7a41c49f8..b434c2325203 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/test/public/advisorclient.spec.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/test/public/advisorclient.spec.ts @@ -20,10 +20,11 @@ matrix([[true, false]] as const, async (useAad) => { let client: MetricsAdvisorClient; let recorder: Recorder; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - ({ recorder, client } = createRecordedAdvisorClient(this, makeCredential(useAad))); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ recorder, client } = createRecordedAdvisorClient(this, makeCredential(useAad))); + } + ); afterEach(async function() { if (recorder) { diff --git a/sdk/metricsadvisor/ai-metrics-advisor/test/public/hookTests.spec.ts b/sdk/metricsadvisor/ai-metrics-advisor/test/public/hookTests.spec.ts index 4510ea7c79db..4c4bb60d3ea2 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/test/public/hookTests.spec.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/test/public/hookTests.spec.ts @@ -24,16 +24,17 @@ matrix([[true, false]] as const, async (useAad) => { let emailHookName: string; let webHookName: string; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - ({ recorder, client } = createRecordedAdminClient(this, makeCredential(useAad))); - if (recorder && !emailHookName) { - emailHookName = recorder.getUniqueName("js-test-emailHook-"); - } - if (recorder && !webHookName) { - webHookName = recorder.getUniqueName("js-test-webHook-"); + beforeEach( + /** @this Mocha.Context */ function() { + ({ recorder, client } = createRecordedAdminClient(this, makeCredential(useAad))); + if (recorder && !emailHookName) { + emailHookName = recorder.getUniqueName("js-test-emailHook-"); + } + if (recorder && !webHookName) { + webHookName = recorder.getUniqueName("js-test-webHook-"); + } } - }); + ); afterEach(async function() { if (recorder) { diff --git a/sdk/mixedreality/mixedreality-authentication/test/mixedRealityStsClient.spec.ts b/sdk/mixedreality/mixedreality-authentication/test/mixedRealityStsClient.spec.ts index 95109bd50f24..9652fb026c82 100644 --- a/sdk/mixedreality/mixedreality-authentication/test/mixedRealityStsClient.spec.ts +++ b/sdk/mixedreality/mixedreality-authentication/test/mixedRealityStsClient.spec.ts @@ -77,11 +77,12 @@ describe("[AccountKey] MixedRealityStsClient functional tests", function() { let client: MixedRealityStsClient; let recorder: Recorder; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - recorder = createRecorder(this); - client = createClient(); - }); + beforeEach( + /** @this Mocha.Context */ function() { + recorder = createRecorder(this); + client = createClient(); + } + ); afterEach(async function() { // Stop the recording. diff --git a/sdk/schemaregistry/schema-registry/test/schemaRegistry.spec.ts b/sdk/schemaregistry/schema-registry/test/schemaRegistry.spec.ts index 84e5659e4124..77718fccaefb 100644 --- a/sdk/schemaregistry/schema-registry/test/schemaRegistry.spec.ts +++ b/sdk/schemaregistry/schema-registry/test/schemaRegistry.spec.ts @@ -62,10 +62,11 @@ describe("SchemaRegistryClient", function() { let recorder: Recorder; let client: SchemaRegistryClient; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - ({ client, recorder } = createRecordedClient(this)); - }); + beforeEach( + /** @this Mocha.Context */ function() { + ({ client, recorder } = createRecordedClient(this)); + } + ); afterEach(async function() { await recorder.stop(); diff --git a/sdk/schemaregistry/schema-registry/tsdoc.json b/sdk/schemaregistry/schema-registry/tsdoc.json new file mode 100644 index 000000000000..81c5a8a2aa2f --- /dev/null +++ b/sdk/schemaregistry/schema-registry/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": ["../../../tsdoc.json"] +} diff --git a/sdk/search/search-documents/test/public/node/searchClient.spec.ts b/sdk/search/search-documents/test/public/node/searchClient.spec.ts index 118a6abd2feb..ba1d47853bb4 100644 --- a/sdk/search/search-documents/test/public/node/searchClient.spec.ts +++ b/sdk/search/search-documents/test/public/node/searchClient.spec.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/* eslint-disable no-invalid-this */ - import { assert } from "chai"; import { Recorder, record, isPlaybackMode, isLiveMode } from "@azure/test-utils-recorder"; @@ -20,24 +18,26 @@ import { delay } from "@azure/core-http"; const TEST_INDEX_NAME = isLiveMode() ? createRandomIndexName() : "hotel-live-test1"; -describe("SearchClient", function() { +describe("SearchClient", /** @this Mocha.Context */ function() { let recorder: Recorder; let searchClient: SearchClient; let indexClient: SearchIndexClient; this.timeout(99999); - beforeEach(async function() { - ({ searchClient, indexClient } = createClients(TEST_INDEX_NAME)); - if (!isPlaybackMode()) { - await createIndex(indexClient, TEST_INDEX_NAME); - await delay(WAIT_TIME); - await populateIndex(searchClient); + beforeEach( + /** @this Mocha.Context */ async function() { + ({ searchClient, indexClient } = createClients(TEST_INDEX_NAME)); + if (!isPlaybackMode()) { + await createIndex(indexClient, TEST_INDEX_NAME); + await delay(WAIT_TIME); + await populateIndex(searchClient); + } + recorder = record(this, environmentSetup); + // create the clients again, but hooked up to the recorder + ({ searchClient, indexClient } = createClients(TEST_INDEX_NAME)); } - recorder = record(this, environmentSetup); - // create the clients again, but hooked up to the recorder - ({ searchClient, indexClient } = createClients(TEST_INDEX_NAME)); - }); + ); afterEach(async function() { if (recorder) { diff --git a/sdk/search/search-documents/test/public/node/searchIndexClient.spec.ts b/sdk/search/search-documents/test/public/node/searchIndexClient.spec.ts index 9ce9b62bc7a2..6884e9d1fa0d 100644 --- a/sdk/search/search-documents/test/public/node/searchIndexClient.spec.ts +++ b/sdk/search/search-documents/test/public/node/searchIndexClient.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/* eslint-disable no-invalid-this */ import { isPlaybackMode, record, Recorder, isLiveMode } from "@azure/test-utils-recorder"; import { assert } from "chai"; import { SearchIndexClient, SynonymMap, SearchIndex } from "../../../src"; @@ -18,23 +17,25 @@ import { delay } from "@azure/core-http"; const TEST_INDEX_NAME = isLiveMode() ? createRandomIndexName() : "hotel-live-test3"; -describe("SearchIndexClient", function() { +describe("SearchIndexClient", /** @this Mocha.Context */ function() { let recorder: Recorder; let indexClient: SearchIndexClient; this.timeout(99999); - beforeEach(async function() { - ({ indexClient } = createClients(TEST_INDEX_NAME)); - if (!isPlaybackMode()) { - await createSynonymMaps(indexClient); - await createSimpleIndex(indexClient, TEST_INDEX_NAME); - await delay(WAIT_TIME); + beforeEach( + /** @this Mocha.Context */ async function() { + ({ indexClient } = createClients(TEST_INDEX_NAME)); + if (!isPlaybackMode()) { + await createSynonymMaps(indexClient); + await createSimpleIndex(indexClient, TEST_INDEX_NAME); + await delay(WAIT_TIME); + } + recorder = record(this, environmentSetup); + // create the clients again, but hooked up to the recorder + ({ indexClient } = createClients(TEST_INDEX_NAME)); } - recorder = record(this, environmentSetup); - // create the clients again, but hooked up to the recorder - ({ indexClient } = createClients(TEST_INDEX_NAME)); - }); + ); afterEach(async function() { if (recorder) { diff --git a/sdk/search/search-documents/test/public/node/searchIndexerClient.spec.ts b/sdk/search/search-documents/test/public/node/searchIndexerClient.spec.ts index 5f1bdd35c631..733aa1ddd73b 100644 --- a/sdk/search/search-documents/test/public/node/searchIndexerClient.spec.ts +++ b/sdk/search/search-documents/test/public/node/searchIndexerClient.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/* eslint-disable no-invalid-this */ import { isPlaybackMode, record, Recorder, isLiveMode } from "@azure/test-utils-recorder"; import { assert } from "chai"; import { @@ -28,26 +27,28 @@ import { delay } from "@azure/core-http"; const TEST_INDEX_NAME = isLiveMode() ? createRandomIndexName() : "hotel-live-test2"; -describe("SearchIndexerClient", function() { +describe("SearchIndexerClient", /** @this Mocha.Context */ function() { let recorder: Recorder; let indexerClient: SearchIndexerClient; let indexClient: SearchIndexClient; this.timeout(99999); - beforeEach(async function() { - ({ indexClient, indexerClient } = createClients(TEST_INDEX_NAME)); - if (!isPlaybackMode()) { - await createDataSourceConnections(indexerClient); - await createSkillsets(indexerClient); - await createIndex(indexClient, TEST_INDEX_NAME); - await delay(5000); - await createIndexers(indexerClient, TEST_INDEX_NAME); + beforeEach( + /** @this Mocha.Context */ async function() { + ({ indexClient, indexerClient } = createClients(TEST_INDEX_NAME)); + if (!isPlaybackMode()) { + await createDataSourceConnections(indexerClient); + await createSkillsets(indexerClient); + await createIndex(indexClient, TEST_INDEX_NAME); + await delay(5000); + await createIndexers(indexerClient, TEST_INDEX_NAME); + } + recorder = record(this, environmentSetup); + // create the clients again, but hooked up to the recorder + ({ indexClient, indexerClient } = createClients(TEST_INDEX_NAME)); } - recorder = record(this, environmentSetup); - // create the clients again, but hooked up to the recorder - ({ indexClient, indexerClient } = createClients(TEST_INDEX_NAME)); - }); + ); afterEach(async function() { if (recorder) { diff --git a/sdk/tables/data-tables/test/integration/batch.spec.ts b/sdk/tables/data-tables/test/integration/batch.spec.ts index ffc9f094455e..0d6375845baf 100644 --- a/sdk/tables/data-tables/test/integration/batch.spec.ts +++ b/sdk/tables/data-tables/test/integration/batch.spec.ts @@ -26,20 +26,21 @@ describe("batch operations", () => { // which wouldn't match the recorded one. Fallingback to SAS for recorded tests. const authMode = !isNode || !isLiveMode() ? "SASConnectionString" : "AccountConnectionString"; - beforeEach(async function() { - sinon.stub(Uuid, "generateUuid").returns("fakeId"); - // eslint-disable-next-line no-invalid-this - recorder = record(this, recordedEnvironmentSetup); - client = createTableClient(tableName, authMode); - - try { - if (!isPlaybackMode()) { - await client.create(); + beforeEach( + /** @this Mocha.Context */ async function() { + sinon.stub(Uuid, "generateUuid").returns("fakeId"); + recorder = record(this, recordedEnvironmentSetup); + client = createTableClient(tableName, authMode); + + try { + if (!isPlaybackMode()) { + await client.create(); + } + } catch { + console.warn("Table already exists"); } - } catch { - console.warn("Table already exists"); } - }); + ); afterEach(async function() { sinon.restore(); diff --git a/sdk/tables/data-tables/test/integration/tableclient.spec.ts b/sdk/tables/data-tables/test/integration/tableclient.spec.ts index e7ecb80f7647..2505d6f5645e 100644 --- a/sdk/tables/data-tables/test/integration/tableclient.spec.ts +++ b/sdk/tables/data-tables/test/integration/tableclient.spec.ts @@ -18,12 +18,13 @@ describe("TableClient", () => { // which wouldn't match the recorded one. Fallingback to SAS for recorded tests. const authMode = !isNode || !isLiveMode() ? "SASConnectionString" : "AccountConnectionString"; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - recorder = record(this, recordedEnvironmentSetup); + beforeEach( + /** @this Mocha.Context */ function() { + recorder = record(this, recordedEnvironmentSetup); - client = createTableClient(tableName, authMode); - }); + client = createTableClient(tableName, authMode); + } + ); before(async () => { if (!isPlaybackMode()) { @@ -44,25 +45,26 @@ describe("TableClient", () => { describe("listEntities", () => { // Create required entities for testing list operations - before(async function() { - if (!isPlaybackMode()) { - // eslint-disable-next-line no-invalid-this - this.timeout(10000); - await client.createEntity({ - partitionKey: listPartitionKey, - rowKey: "binary1", - foo: new Uint8Array([66, 97, 114]) - }); - - for (let i = 0; i < 20; i++) { + before( + /** @this Mocha.Context */ async function() { + if (!isPlaybackMode()) { + this.timeout(10000); await client.createEntity({ partitionKey: listPartitionKey, - rowKey: `${i}`, - foo: "testEntity" + rowKey: "binary1", + foo: new Uint8Array([66, 97, 114]) }); + + for (let i = 0; i < 20; i++) { + await client.createEntity({ + partitionKey: listPartitionKey, + rowKey: `${i}`, + foo: "testEntity" + }); + } } } - }); + ); type StringEntity = { foo: string }; type NumberEntity = { foo: number }; type DateEntity = { foo: Date }; diff --git a/sdk/tables/data-tables/test/integration/tableserviceclient.spec.ts b/sdk/tables/data-tables/test/integration/tableserviceclient.spec.ts index cad2288b90a7..ba3c836446b0 100644 --- a/sdk/tables/data-tables/test/integration/tableserviceclient.spec.ts +++ b/sdk/tables/data-tables/test/integration/tableserviceclient.spec.ts @@ -14,11 +14,12 @@ describe("TableServiceClient", () => { const suffix = isNode ? "node" : "browser"; const authMode = !isNode || !isLiveMode() ? "SASConnectionString" : "AccountConnectionString"; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - recorder = record(this, recordedEnvironmentSetup); - client = createTableServiceClient(authMode); - }); + beforeEach( + /** @this Mocha.Context */ function() { + recorder = record(this, recordedEnvironmentSetup); + client = createTableServiceClient(authMode); + } + ); afterEach(async function() { await recorder.stop(); @@ -50,33 +51,35 @@ describe("TableServiceClient", () => { describe("listTables", () => { const tableNames: string[] = []; const expectedTotalItems = 20; - before(async function() { - // Create tables to be listed - if (!isPlaybackMode()) { - // eslint-disable-next-line no-invalid-this - this.timeout(10000); - for (let i = 0; i < 20; i++) { - const tableName = `ListTableTest${suffix}${i}`; - await client.createTable(tableName); - tableNames.push(tableName); + before( + /** @this Mocha.Context */ async function() { + // Create tables to be listed + if (!isPlaybackMode()) { + this.timeout(10000); + for (let i = 0; i < 20; i++) { + const tableName = `ListTableTest${suffix}${i}`; + await client.createTable(tableName); + tableNames.push(tableName); + } } } - }); + ); - after(async function() { - // Cleanup tables - if (!isPlaybackMode()) { - // eslint-disable-next-line no-invalid-this - this.timeout(10000); - try { - for (const table of tableNames) { - await client.deleteTable(table); + after( + /** @this Mocha.Context */ async function() { + // Cleanup tables + if (!isPlaybackMode()) { + this.timeout(10000); + try { + for (const table of tableNames) { + await client.deleteTable(table); + } + } catch (error) { + console.warn(`Failed to delete a table during cleanup`); } - } catch (error) { - console.warn(`Failed to delete a table during cleanup`); } } - }); + ); it("should list all", async () => { const tables = client.listTables(); diff --git a/sdk/tables/data-tables/test/unit/sharedKeyCredential.spec.ts b/sdk/tables/data-tables/test/unit/sharedKeyCredential.spec.ts index 7b5a13fc5764..b71521260069 100644 --- a/sdk/tables/data-tables/test/unit/sharedKeyCredential.spec.ts +++ b/sdk/tables/data-tables/test/unit/sharedKeyCredential.spec.ts @@ -25,10 +25,9 @@ describe("TablesSharedKeyCredential", () => { Date.prototype.toUTCString = originalToUTCString; }); - it("It should sign", async function() { + it("It should sign", /** @this Mocha.Context */ async function() { if (!isNode) { // TablesSharedKeyCredential auth is not supported in Browser - // eslint-disable-next-line no-invalid-this this.skip(); } const url = diff --git a/sdk/tables/data-tables/test/unit/utils.spec.ts b/sdk/tables/data-tables/test/unit/utils.spec.ts index d5c6815a6c98..3559606b22a0 100644 --- a/sdk/tables/data-tables/test/unit/utils.spec.ts +++ b/sdk/tables/data-tables/test/unit/utils.spec.ts @@ -10,13 +10,14 @@ import { ConnectionString } from "../../src/utils/internalModels"; describe("Utility Helpers", () => { describe("extractConnectionStringParts", () => { describe("Account Connection String", () => { - beforeEach(function() { - if (!isNode) { - // Account connection string is not supported for Browsers - // eslint-disable-next-line no-invalid-this - this.skip(); + beforeEach( + /** @this Mocha.Context */ function() { + if (!isNode) { + // Account connection string is not supported for Browsers + this.skip(); + } } - }); + ); it("should handle connection string without TableEndpoint", () => { const validConnectionString = "DefaultEndpointsProtocol=https;AccountName=testaccount;AccountKey=REDACTED;EndpointSuffix=core.windows.net"; diff --git a/sdk/template/template/test/public/configurationClient.spec.ts b/sdk/template/template/test/public/configurationClient.spec.ts index e56752424e2a..36706d5e28f2 100644 --- a/sdk/template/template/test/public/configurationClient.spec.ts +++ b/sdk/template/template/test/public/configurationClient.spec.ts @@ -52,35 +52,36 @@ 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(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. - // eslint-disable-next-line no-invalid-this - 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(); - }); + beforeEach( + /** @this Mocha.Context */ 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() { diff --git a/sdk/template/template/tsdoc.json b/sdk/template/template/tsdoc.json new file mode 100644 index 000000000000..81c5a8a2aa2f --- /dev/null +++ b/sdk/template/template/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": ["../../../tsdoc.json"] +} diff --git a/sdk/test-utils/multi-version/test/multiVersion.spec.ts b/sdk/test-utils/multi-version/test/multiVersion.spec.ts index d171af10d85b..6d0584cd5f7c 100644 --- a/sdk/test-utils/multi-version/test/multiVersion.spec.ts +++ b/sdk/test-utils/multi-version/test/multiVersion.spec.ts @@ -41,7 +41,9 @@ versionsToTest(serviceVersions, {}, (serviceVersion, onVersions) => { console.log(`creating test client for service version ${serviceVersion}`); }); - afterEach(async function() { /** empty */}); + afterEach(async function() { + /** empty */ + }); it("test case 2", function() { if (serviceVersion === "7.0") { @@ -50,7 +52,9 @@ versionsToTest(serviceVersions, {}, (serviceVersion, onVersions) => { }); describe("nested test suite 3a", function() { - it("nested test 4a", function() { /** empty */}); + it("nested test 4a", function() { + /** empty */ + }); }); onVersions(["7.0"]).describe("nested test suite 3b", function() { diff --git a/sdk/textanalytics/ai-text-analytics/test/public/apiKey.spec.ts b/sdk/textanalytics/ai-text-analytics/test/public/apiKey.spec.ts index ab81543e8405..08d82c723afe 100644 --- a/sdk/textanalytics/ai-text-analytics/test/public/apiKey.spec.ts +++ b/sdk/textanalytics/ai-text-analytics/test/public/apiKey.spec.ts @@ -19,28 +19,29 @@ const testDataEn = [ "I didn't like the last book I read at all." ]; -describe("[API Key] TextAnalyticsClient", function() { +describe("[API Key] TextAnalyticsClient", /** @this Mocha.Context */ function() { let recorder: Recorder; let client: TextAnalyticsClient; - // eslint-disable-next-line no-invalid-this const CLITimeout = this.timeout(); const fastTimeout = 10000; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - recorder = createRecorder(this); - client = createClient("APIKey"); - }); + beforeEach( + /** @this Mocha.Context */ function() { + recorder = createRecorder(this); + client = createClient("APIKey"); + } + ); afterEach(async function() { await recorder.stop(); }); describe("fast tests", function() { - before(function() { - // eslint-disable-next-line no-invalid-this - this.timeout(fastTimeout); - }); + before( + /** @this Mocha.Context */ function() { + this.timeout(fastTimeout); + } + ); it("#analyzeSentiment", async function() { const results = await client.analyzeSentiment(testDataEn); @@ -88,10 +89,11 @@ describe("[API Key] TextAnalyticsClient", function() { describe("LROs", function() { const pollingInterval = isPlaybackMode() ? 0 : 2000; - before(function() { - // eslint-disable-next-line no-invalid-this - this.timeout(isPlaybackMode() ? fastTimeout : CLITimeout); - }); + before( + /** @this Mocha.Context */ function() { + this.timeout(isPlaybackMode() ? fastTimeout : CLITimeout); + } + ); describe("#health", function() { it("input strings", async function() { diff --git a/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts b/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts index 4835f67238a8..042db8123bc1 100644 --- a/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts +++ b/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts @@ -35,35 +35,36 @@ const testDataEs = [ "Los caminos que llevan hasta Monte Rainier son espectaculares y hermosos.", "La carretera estaba atascada. Había mucho tráfico el día de ayer." ]; -describe("[AAD] TextAnalyticsClient", function() { +describe("[AAD] TextAnalyticsClient", /** @this Mocha.Context */ function() { let recorder: Recorder; let client: TextAnalyticsClient; - // eslint-disable-next-line no-invalid-this const CLITimeout = this.timeout(); const fastTimeout = 10000; let getId: () => string; - beforeEach(function() { - // eslint-disable-next-line no-invalid-this - recorder = createRecorder(this); - client = createClient("AAD"); - let nextId = 0; - getId = function() { - nextId += 1; - return nextId.toString(); - }; - }); + beforeEach( + /** @this Mocha.Context */ function() { + recorder = createRecorder(this); + client = createClient("AAD"); + let nextId = 0; + getId = function() { + nextId += 1; + return nextId.toString(); + }; + } + ); afterEach(async function() { await recorder.stop(); }); describe("fast tests", function() { - before(function() { - // eslint-disable-next-line no-invalid-this - this.timeout(fastTimeout); - }); + before( + /** @this Mocha.Context */ function() { + this.timeout(fastTimeout); + } + ); describe("#analyzeSentiment", function() { it("client throws on empty list", async function() { @@ -929,10 +930,11 @@ describe("[AAD] TextAnalyticsClient", function() { describe("LROs", function() { const pollingInterval = isPlaybackMode() ? 0 : 2000; - before(function() { - // eslint-disable-next-line no-invalid-this - this.timeout(isPlaybackMode() ? fastTimeout : CLITimeout); - }); + before( + /** @this Mocha.Context */ function() { + this.timeout(isPlaybackMode() ? fastTimeout : CLITimeout); + } + ); describe("#analyze", function() { it("single entity recognition action", async function() { diff --git a/tsdoc.json b/tsdoc.json index 6e1223d4e138..9c1bbccb2518 100644 --- a/tsdoc.json +++ b/tsdoc.json @@ -4,6 +4,10 @@ { "tagName": "@hidden", "syntaxKind": "modifier" + }, + { + "tagName": "@this", + "syntaxKind": "modifier" } ] }