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](8984c91372/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
This commit is contained in:
Родитель
589e8cd553
Коммит
18b3f30602
|
@ -19,10 +19,11 @@ describe("AnomalyDetectorClient", () => {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
const apiKey = new AzureKeyCredential(testEnv.ANOMALY_DETECTOR_API_KEY);
|
const apiKey = new AzureKeyCredential(testEnv.ANOMALY_DETECTOR_API_KEY);
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
({ recorder, client } = createRecordedAnomalyDetectorClient(this, apiKey));
|
({ recorder, client } = createRecordedAnomalyDetectorClient(this, apiKey));
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
|
|
|
@ -14,8 +14,7 @@ import { verifyAttestationToken } from "../utils/helpers";
|
||||||
describe("[AAD] Attestation Client", function() {
|
describe("[AAD] Attestation Client", function() {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(/** @this Mocha.Context */ function() {
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
recorder = createRecorder(this);
|
recorder = createRecorder(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ import { verifyAttestationToken } from "../utils/helpers";
|
||||||
describe("PolicyGetSetTests ", function() {
|
describe("PolicyGetSetTests ", function() {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(/** @this Mocha.Context */ function() {
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
recorder = createRecorder(this);
|
recorder = createRecorder(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ import { verifyAttestationToken } from "../utils/helpers";
|
||||||
describe("PolicyManagementTests ", function() {
|
describe("PolicyManagementTests ", function() {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(/** @this Mocha.Context */ function() {
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
recorder = createRecorder(this);
|
recorder = createRecorder(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ import { Buffer } from "../utils/Buffer";
|
||||||
describe("TokenCertTests", function() {
|
describe("TokenCertTests", function() {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(/** @this Mocha.Context */ function() {
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
recorder = createRecorder(this);
|
recorder = createRecorder(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -50,35 +50,36 @@ describe.skip("ContainerRegistryClient functional tests", function() {
|
||||||
// NOTE: use of "function" and not ES6 arrow-style functions with the
|
// 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
|
// beforeEach hook is IMPORTANT due to the use of `this` in the function
|
||||||
// body.
|
// body.
|
||||||
beforeEach(function(this: Context) {
|
beforeEach(
|
||||||
// The recorder has some convenience methods, and we need to store a
|
/** @this Mocha.Context */ function(this: Context) {
|
||||||
// reference to it so that we can `stop()` the recorder later in the
|
// The recorder has some convenience methods, and we need to store a
|
||||||
// `afterEach` hook.
|
// reference to it so that we can `stop()` the recorder later in the
|
||||||
// eslint-disable-next-line no-invalid-this
|
// `afterEach` hook.
|
||||||
recorder = record(this, {
|
recorder = record(this, {
|
||||||
// == Recorder Environment Setup == Add the replaceable variables from
|
// == Recorder Environment Setup == Add the replaceable variables from
|
||||||
// above
|
// above
|
||||||
replaceableVariables,
|
replaceableVariables,
|
||||||
|
|
||||||
// We don't use this in the template, but if we had any query parameters
|
// We don't use this in the template, but if we had any query parameters
|
||||||
// we wished to discard, we could add them here
|
// we wished to discard, we could add them here
|
||||||
queryParametersToSkip: [],
|
queryParametersToSkip: [],
|
||||||
|
|
||||||
// Finally, we need to remove the AAD `access_token` from any requests.
|
// Finally, we need to remove the AAD `access_token` from any requests.
|
||||||
// This is very important, as it cannot be removed using environment
|
// This is very important, as it cannot be removed using environment
|
||||||
// variable or query parameter replacement. The
|
// variable or query parameter replacement. The
|
||||||
// `customizationsOnRecordings` field allows us to make arbitrary
|
// `customizationsOnRecordings` field allows us to make arbitrary
|
||||||
// replacements within recordings.
|
// replacements within recordings.
|
||||||
customizationsOnRecordings: [
|
customizationsOnRecordings: [
|
||||||
(recording: any): any =>
|
(recording: any): any =>
|
||||||
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`)
|
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`)
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
// We'll be able to refer to the instantiated `client` in tests, since we
|
// We'll be able to refer to the instantiated `client` in tests, since we
|
||||||
// initialize it before each test
|
// initialize it before each test
|
||||||
client = createTestClient();
|
client = createTestClient();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// After each test, we need to stop the recording.
|
// After each test, we need to stop the recording.
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||||
|
"extends": ["../../../tsdoc.json"]
|
||||||
|
}
|
|
@ -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
|
// Increase timeout to give the request time to fail
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
const requestUrl = "http://fake.domain";
|
const requestUrl = "http://fake.domain";
|
||||||
const request = new WebResource(requestUrl, "GET");
|
const request = new WebResource(requestUrl, "GET");
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
/* eslint-disable no-invalid-this */
|
|
||||||
|
|
||||||
import { HttpOperationResponse, RequestOptionsBase } from "@azure/core-http";
|
import { HttpOperationResponse, RequestOptionsBase } from "@azure/core-http";
|
||||||
import { AbortSignalLike } from "@azure/abort-controller";
|
import { AbortSignalLike } from "@azure/abort-controller";
|
||||||
|
@ -22,6 +21,7 @@ export interface TestOperationState extends PollOperationState<string> {
|
||||||
|
|
||||||
export interface TestOperation extends PollOperation<TestOperationState, string> {}
|
export interface TestOperation extends PollOperation<TestOperationState, string> {}
|
||||||
|
|
||||||
|
/** @this TestOperation */
|
||||||
async function update(
|
async function update(
|
||||||
this: TestOperation,
|
this: TestOperation,
|
||||||
options: {
|
options: {
|
||||||
|
@ -70,6 +70,7 @@ async function update(
|
||||||
return makeOperation(newState);
|
return makeOperation(newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @this TestOperation */
|
||||||
async function cancel(
|
async function cancel(
|
||||||
this: TestOperation,
|
this: TestOperation,
|
||||||
options: { abortSignal?: AbortSignal } = {}
|
options: { abortSignal?: AbortSignal } = {}
|
||||||
|
@ -100,6 +101,7 @@ async function cancel(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @this TestOperation */
|
||||||
function toString(this: TestOperation): string {
|
function toString(this: TestOperation): string {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
state: this.state
|
state: this.state
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
/* eslint-disable no-invalid-this */
|
|
||||||
|
|
||||||
import { log } from "./log";
|
import { log } from "./log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,6 +155,7 @@ function createDebugger(namespace: string): Debugger {
|
||||||
return newDebugger;
|
return newDebugger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @this Debugger */
|
||||||
function destroy(this: Debugger): boolean {
|
function destroy(this: Debugger): boolean {
|
||||||
const index = debuggers.indexOf(this);
|
const index = debuggers.indexOf(this);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
@ -166,6 +165,7 @@ function destroy(this: Debugger): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @this Debugger */
|
||||||
function extend(this: Debugger, namespace: string): Debugger {
|
function extend(this: Debugger, namespace: string): Debugger {
|
||||||
const newDebugger = createDebugger(`${this.namespace}:${namespace}`);
|
const newDebugger = createDebugger(`${this.namespace}:${namespace}`);
|
||||||
newDebugger.log = this.log;
|
newDebugger.log = this.log;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
"extends": ["../.eslintrc.json"],
|
"extends": ["../.eslintrc.json"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-console": "off",
|
"no-console": "off",
|
||||||
"no-invalid-this": "off",
|
|
||||||
"space-before-function-paren": "off"
|
"space-before-function-paren": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ function getCollection2TokenMap(
|
||||||
return (sessionContainer as any).collectionResourceIdToSessionTokens;
|
return (sessionContainer as any).collectionResourceIdToSessionTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Session Token", function() {
|
describe("Session Token", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 20000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 20000);
|
||||||
|
|
||||||
const containerId = "sessionTestColl";
|
const containerId = "sessionTestColl";
|
||||||
|
@ -304,7 +304,7 @@ describe("Session Token", function() {
|
||||||
spy.restore();
|
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);
|
this.retries(2);
|
||||||
const database = await getTestDatabase("session test", client);
|
const database = await getTestDatabase("session test", client);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import { getAuthorizationTokenUsingResourceTokens } from "../../../src/auth";
|
import { getAuthorizationTokenUsingResourceTokens } from "../../../src/auth";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
|
|
||||||
describe("NodeJS CRUD Tests", function() {
|
describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
|
|
||||||
it("should find exact match", async function() {
|
it("should find exact match", async function() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {
|
||||||
removeAllDatabases
|
removeAllDatabases
|
||||||
} from "../common/TestHelpers";
|
} from "../common/TestHelpers";
|
||||||
|
|
||||||
describe("NodeJS CRUD Tests", function() {
|
describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
import AbortController from "node-abort-controller";
|
import AbortController from "node-abort-controller";
|
||||||
import { UsernamePasswordCredential } from "@azure/identity";
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 20000);
|
||||||
|
|
||||||
describe("Validate client request timeout", function() {
|
describe("Validate client request timeout", function() {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import { removeAllDatabases, getTestContainer } from "../common/TestHelpers";
|
import { removeAllDatabases, getTestContainer } from "../common/TestHelpers";
|
||||||
|
|
||||||
describe("Conflicts", function() {
|
describe("Conflicts", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
import { SpatialType } from "../../../src";
|
import { SpatialType } from "../../../src";
|
||||||
import { GeospatialType } from "../../../src";
|
import { GeospatialType } from "../../../src";
|
||||||
|
|
||||||
describe("Containers", function() {
|
describe("Containers", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { DatabaseRequest } from "../../../src";
|
||||||
|
|
||||||
const client = new CosmosClient({ endpoint, key: masterKey });
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
|
|
|
@ -6,11 +6,13 @@ import { endpoint, masterKey } from "../common/_testConfig";
|
||||||
|
|
||||||
const client = new CosmosClient({ endpoint, key: masterKey });
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
/** @this Mocha.Context */ async function() {
|
||||||
});
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
describe("validate database account functionality", function() {
|
describe("validate database account functionality", function() {
|
||||||
it("nativeApi Should get database account successfully name based", async function() {
|
it("nativeApi Should get database account successfully name based", async function() {
|
||||||
|
|
|
@ -26,7 +26,7 @@ interface TestItem {
|
||||||
replace?: string;
|
replace?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Item CRUD", function() {
|
describe("Item CRUD", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
|
|
|
@ -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.");
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
/** @this Mocha.Context */ async function() {
|
||||||
await removeAllDatabases();
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
});
|
await removeAllDatabases();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
describe("Validate Offer CRUD", function() {
|
describe("Validate Offer CRUD", function() {
|
||||||
it("nativeApi Should do offer read and query operations successfully name based single partition collection", async function() {
|
it("nativeApi Should do offer read and query operations successfully name based single partition collection", async function() {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
replaceOrUpsertPermission
|
replaceOrUpsertPermission
|
||||||
} from "../common/TestHelpers";
|
} from "../common/TestHelpers";
|
||||||
|
|
||||||
describe("NodeJS CRUD Tests", function() {
|
describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
|
|
|
@ -14,7 +14,7 @@ if (!Symbol || !Symbol.asyncIterator) {
|
||||||
(Symbol as any).asyncIterator = Symbol.for("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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
before(async function() {
|
before(async function() {
|
||||||
await removeAllDatabases();
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 30000);
|
||||||
let resources: { container: Container; doc1: any; doc2: any; doc3: any };
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 30000);
|
||||||
|
|
||||||
it("returns undefined sum with null value in aggregator", async function() {
|
it("returns undefined sum with null value in aggregator", async function() {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import assert from "assert";
|
||||||
import { Database, DataType, IndexKind } from "../../../src";
|
import { Database, DataType, IndexKind } from "../../../src";
|
||||||
import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
|
|
|
@ -13,16 +13,18 @@ import {
|
||||||
// Used for sproc
|
// Used for sproc
|
||||||
declare let getContext: any;
|
declare let getContext: any;
|
||||||
|
|
||||||
describe("NodeJS CRUD Tests", function() {
|
describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
});
|
});
|
||||||
describe("Validate sproc CRUD", function() {
|
describe("Validate sproc CRUD", function() {
|
||||||
let container: Container;
|
let container: Container;
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
container = await getTestContainer(this.test.fullTitle());
|
/** @this Mocha.Context */ async function() {
|
||||||
});
|
container = await getTestContainer(this.test.fullTitle());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
it("nativeApi Should do sproc CRUD operations successfully with create/replace", async function() {
|
it("nativeApi Should do sproc CRUD operations successfully with create/replace", async function() {
|
||||||
// read sprocs
|
// read sprocs
|
||||||
|
@ -92,9 +94,11 @@ describe("NodeJS CRUD Tests", function() {
|
||||||
|
|
||||||
describe("Validate stored procedure functionality", function() {
|
describe("Validate stored procedure functionality", function() {
|
||||||
let container: Container;
|
let container: Container;
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
container = await getTestContainer(this.test.fullTitle());
|
/** @this Mocha.Context */ async function() {
|
||||||
});
|
container = await getTestContainer(this.test.fullTitle());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
it("nativeApi should do stored procedure operations successfully with create/replace", async function() {
|
it("nativeApi should do stored procedure operations successfully with create/replace", async function() {
|
||||||
const sproc1: StoredProcedureDefinition = {
|
const sproc1: StoredProcedureDefinition = {
|
||||||
|
|
|
@ -10,7 +10,7 @@ const notFoundErrorCode = 404;
|
||||||
// Mock for trigger function bodies
|
// Mock for trigger function bodies
|
||||||
declare let getContext: any;
|
declare let getContext: any;
|
||||||
|
|
||||||
describe("NodeJS CRUD Tests", function() {
|
describe("NodeJS CRUD Tests", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
let container: Container;
|
let container: Container;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ async function sleep(time: number): Promise<unknown> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Container TTL", function() {
|
describe("Container TTL", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 600000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 600000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
|
|
|
@ -4,7 +4,7 @@ import assert from "assert";
|
||||||
import { UserDefinedFunctionDefinition, Container } from "../../../src";
|
import { UserDefinedFunctionDefinition, Container } from "../../../src";
|
||||||
import { removeAllDatabases, getTestContainer } from "../common/TestHelpers";
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
let container: Container;
|
let container: Container;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import assert from "assert";
|
||||||
import { UserDefinition } from "../../../src";
|
import { UserDefinition } from "../../../src";
|
||||||
import { createOrUpsertUser, getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
await removeAllDatabases();
|
await removeAllDatabases();
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { FeedOptions } from "../../../src";
|
||||||
import { TestData } from "../common/TestData";
|
import { TestData } from "../common/TestData";
|
||||||
import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers";
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 20000);
|
||||||
const partitionKey = "key";
|
const partitionKey = "key";
|
||||||
const uniquePartitionKey = "uniquePartitionKey";
|
const uniquePartitionKey = "uniquePartitionKey";
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { Database } from "../../../src";
|
||||||
import { endpoint } from "../common/_testConfig";
|
import { endpoint } from "../common/_testConfig";
|
||||||
import { getTestContainer, removeAllDatabases } from "../common/TestHelpers";
|
import { getTestContainer, removeAllDatabases } from "../common/TestHelpers";
|
||||||
|
|
||||||
describe("Authorization", function() {
|
describe("Authorization", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
|
|
||||||
// TODO: should have types for all these things
|
// TODO: should have types for all these things
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { RequestOptions } from "../../../src";
|
||||||
import { Container, ContainerDefinition } from "../../../src";
|
import { Container, ContainerDefinition } from "../../../src";
|
||||||
import { getTestContainer, removeAllDatabases } from "../common/TestHelpers";
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 20000);
|
||||||
|
|
||||||
// delete all databases and create sample database
|
// delete all databases and create sample database
|
||||||
|
|
|
@ -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");
|
this.timeout(process.env.MOCHA_TIMEOUT || "30000");
|
||||||
|
|
||||||
describe("Validate Query", function() {
|
describe("Validate Query", function() {
|
||||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -107,7 +107,7 @@ const collectionResponse = {
|
||||||
code: 200
|
code: 200
|
||||||
};
|
};
|
||||||
|
|
||||||
describe("Multi-region tests", function() {
|
describe("Multi-region tests", /** @this Mocha.Context */ function() {
|
||||||
this.timeout(process.env.MOCHA_TIMEOUT || "30000");
|
this.timeout(process.env.MOCHA_TIMEOUT || "30000");
|
||||||
|
|
||||||
it("Preferred locations should be honored for readEndpoint", async function() {
|
it("Preferred locations should be honored for readEndpoint", async function() {
|
||||||
|
|
|
@ -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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 30000);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
proxy.listen(proxyPort + 1, "127.0.0.1", async () => {
|
proxy.listen(proxyPort + 1, "127.0.0.1", async () => {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { getTestContainer, getTestDatabase, removeAllDatabases } from "../common
|
||||||
|
|
||||||
const doc = { id: "myId", pk: "pk" };
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
const containerId = "testcontainer";
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 20000);
|
||||||
const collectionId = "testCollection2";
|
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);
|
this.timeout(process.env.MOCHA_TIMEOUT || 10000);
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||||
|
"extends": ["../../../../tsdoc.json"]
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
/* eslint-disable no-invalid-this */
|
|
||||||
|
|
||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
|
@ -19,7 +18,7 @@ import {
|
||||||
import { FullOperationResponse } from "@azure/core-client";
|
import { FullOperationResponse } from "@azure/core-client";
|
||||||
import { RestError } from "@azure/core-rest-pipeline";
|
import { RestError } from "@azure/core-rest-pipeline";
|
||||||
|
|
||||||
describe("EventGridPublisherClient", function() {
|
describe("EventGridPublisherClient", /** @this Mocha.Context */ function() {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
let res: FullOperationResponse | undefined;
|
let res: FullOperationResponse | undefined;
|
||||||
|
|
||||||
|
@ -32,14 +31,16 @@ describe("EventGridPublisherClient", function() {
|
||||||
describe("#send (EventGrid schema)", function() {
|
describe("#send (EventGrid schema)", function() {
|
||||||
let client: EventGridPublisherClient<"EventGrid">;
|
let client: EventGridPublisherClient<"EventGrid">;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
({ client, recorder } = createRecordedClient(
|
/** @this Mocha.Context */ function() {
|
||||||
this,
|
({ client, recorder } = createRecordedClient(
|
||||||
testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT,
|
this,
|
||||||
"EventGrid",
|
testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_ENDPOINT,
|
||||||
new AzureKeyCredential(testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_API_KEY)
|
"EventGrid",
|
||||||
));
|
new AzureKeyCredential(testEnv.EVENT_GRID_EVENT_GRID_SCHEMA_API_KEY)
|
||||||
});
|
));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -99,14 +100,16 @@ describe("EventGridPublisherClient", function() {
|
||||||
describe("#send error cases (EventGrid schema)", function() {
|
describe("#send error cases (EventGrid schema)", function() {
|
||||||
let client: EventGridPublisherClient<"EventGrid">;
|
let client: EventGridPublisherClient<"EventGrid">;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
({ client, recorder } = createRecordedClient(
|
/** @this Mocha.Context */ function() {
|
||||||
this,
|
({ client, recorder } = createRecordedClient(
|
||||||
removeApiEventsSuffix(testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT),
|
this,
|
||||||
"EventGrid",
|
removeApiEventsSuffix(testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT),
|
||||||
new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY)
|
"EventGrid",
|
||||||
));
|
new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY)
|
||||||
});
|
));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -142,14 +145,16 @@ describe("EventGridPublisherClient", function() {
|
||||||
describe("#send (CloudEvent schema)", function() {
|
describe("#send (CloudEvent schema)", function() {
|
||||||
let client: EventGridPublisherClient<"CloudEvent">;
|
let client: EventGridPublisherClient<"CloudEvent">;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
({ client, recorder } = createRecordedClient(
|
/** @this Mocha.Context */ function() {
|
||||||
this,
|
({ client, recorder } = createRecordedClient(
|
||||||
testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT,
|
this,
|
||||||
"CloudEvent",
|
testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT,
|
||||||
new AzureKeyCredential(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY)
|
"CloudEvent",
|
||||||
));
|
new AzureKeyCredential(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY)
|
||||||
});
|
));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -251,14 +256,16 @@ describe("EventGridPublisherClient", function() {
|
||||||
describe("#send error cases (CloudEvent schema)", function() {
|
describe("#send error cases (CloudEvent schema)", function() {
|
||||||
let client: EventGridPublisherClient<"CloudEvent">;
|
let client: EventGridPublisherClient<"CloudEvent">;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
({ client, recorder } = createRecordedClient(
|
/** @this Mocha.Context */ function() {
|
||||||
this,
|
({ client, recorder } = createRecordedClient(
|
||||||
removeApiEventsSuffix(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT),
|
this,
|
||||||
"CloudEvent",
|
removeApiEventsSuffix(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_ENDPOINT),
|
||||||
new AzureKeyCredential(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY)
|
"CloudEvent",
|
||||||
));
|
new AzureKeyCredential(testEnv.EVENT_GRID_CLOUD_EVENT_SCHEMA_API_KEY)
|
||||||
});
|
));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -292,14 +299,16 @@ describe("EventGridPublisherClient", function() {
|
||||||
describe("#send (Custom Event Schema)", function() {
|
describe("#send (Custom Event Schema)", function() {
|
||||||
let client: EventGridPublisherClient<"Custom">;
|
let client: EventGridPublisherClient<"Custom">;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
({ client, recorder } = createRecordedClient(
|
/** @this Mocha.Context */ function() {
|
||||||
this,
|
({ client, recorder } = createRecordedClient(
|
||||||
testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT,
|
this,
|
||||||
"Custom",
|
testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT,
|
||||||
new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY)
|
"Custom",
|
||||||
));
|
new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY)
|
||||||
});
|
));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -353,14 +362,16 @@ describe("EventGridPublisherClient", function() {
|
||||||
describe("#send error cases (Custom Event Schema)", function() {
|
describe("#send error cases (Custom Event Schema)", function() {
|
||||||
let client: EventGridPublisherClient<"Custom">;
|
let client: EventGridPublisherClient<"Custom">;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
({ client, recorder } = createRecordedClient(
|
/** @this Mocha.Context */ function() {
|
||||||
this,
|
({ client, recorder } = createRecordedClient(
|
||||||
removeApiEventsSuffix(testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT),
|
this,
|
||||||
"Custom",
|
removeApiEventsSuffix(testEnv.EVENT_GRID_CUSTOM_SCHEMA_ENDPOINT),
|
||||||
new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY)
|
"Custom",
|
||||||
));
|
new AzureKeyCredential(testEnv.EVENT_GRID_CUSTOM_SCHEMA_API_KEY)
|
||||||
});
|
));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
|
|
@ -16,10 +16,11 @@ describe("FormRecognizerClient browser only", () => {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
const apiKey = new AzureKeyCredential(testEnv.FORM_RECOGNIZER_API_KEY);
|
const apiKey = new AzureKeyCredential(testEnv.FORM_RECOGNIZER_API_KEY);
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
({ recorder, client } = createRecordedRecognizerClient(this, apiKey));
|
({ recorder, client } = createRecordedRecognizerClient(this, apiKey));
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
/* eslint-disable no-invalid-this */
|
|
||||||
|
|
||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
import { Context } from "mocha";
|
import { Context } from "mocha";
|
||||||
|
|
||||||
|
@ -29,9 +27,11 @@ matrix([[true, false]] as const, async (useAad) => {
|
||||||
describe(`[${useAad ? "AAD" : "API Key"}] FormTrainingClient`, () => {
|
describe(`[${useAad ? "AAD" : "API Key"}] FormTrainingClient`, () => {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(function(this: Context) {
|
beforeEach(
|
||||||
recorder = createRecorder(this);
|
/** @this Mocha.Context */ function(this: Context) {
|
||||||
});
|
recorder = createRecorder(this);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
|
|
@ -28,11 +28,12 @@ matrix([[true, false]] as const, async (useAad) => {
|
||||||
let client: FormRecognizerClient;
|
let client: FormRecognizerClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
recorder = createRecorder(this);
|
recorder = createRecorder(this);
|
||||||
client = new FormRecognizerClient(endpoint(), makeCredential(useAad));
|
client = new FormRecognizerClient(endpoint(), makeCredential(useAad));
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
|
|
|
@ -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) {
|
if (!isNode) {
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
return this.skip();
|
return this.skip();
|
||||||
}
|
}
|
||||||
process.env.AZURE_AUTHORITY_HOST = "http://totallyinsecure.lol";
|
process.env.AZURE_AUTHORITY_HOST = "http://totallyinsecure.lol";
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"ignorePatterns": ["src/generated"],
|
"ignorePatterns": ["src/generated"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-this-alias": "off",
|
"@typescript-eslint/no-this-alias": "off",
|
||||||
"no-invalid-this": "off",
|
|
||||||
"@azure/azure-sdk/ts-package-json-module": "warn",
|
"@azure/azure-sdk/ts-package-json-module": "warn",
|
||||||
"no-use-before-define": "warn"
|
"no-use-before-define": "warn"
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"ignorePatterns": ["src/core"],
|
"ignorePatterns": ["src/core"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-this-alias": "off",
|
"@typescript-eslint/no-this-alias": "off",
|
||||||
"no-invalid-this": "off",
|
|
||||||
"@azure/azure-sdk/ts-package-json-module": "warn",
|
"@azure/azure-sdk/ts-package-json-module": "warn",
|
||||||
"no-use-before-define": "warn"
|
"no-use-before-define": "warn"
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,15 @@ describe("Challenge based authentication tests", () => {
|
||||||
subject: "cn=MyCert"
|
subject: "cn=MyCert"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
certificateSuffix = authentication.suffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
certificateSuffix = authentication.suffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -46,7 +48,7 @@ describe("Challenge based authentication tests", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -84,7 +86,7 @@ describe("Challenge based authentication tests", () => {
|
||||||
sandbox.restore();
|
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.
|
// Our goal is to intercept how our pipelines are storing the challenge.
|
||||||
// The first network call should indeed set the challenge in memory.
|
// The first network call should indeed set the challenge in memory.
|
||||||
// Subsequent network calls should not set new challenges.
|
// Subsequent network calls should not set new challenges.
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe("Certificates client's user agent (only in Node, because of fs)", () =>
|
||||||
assert.equal(SDK_VERSION, packageVersion);
|
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) {
|
if (!isNode) {
|
||||||
this.skip();
|
this.skip();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -32,16 +32,18 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
subject: "cn=MyCert"
|
subject: "cn=MyCert"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
suffix = authentication.suffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
suffix = authentication.suffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
keyVaultUrl = authentication.keyVaultUrl;
|
recorder = authentication.recorder;
|
||||||
credential = authentication.credential;
|
keyVaultUrl = authentication.keyVaultUrl;
|
||||||
secretClient = new SecretClient(keyVaultUrl, credential);
|
credential = authentication.credential;
|
||||||
});
|
secretClient = new SecretClient(keyVaultUrl, credential);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -49,7 +51,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const poller = await client.beginCreateCertificate(
|
const poller = await client.beginCreateCertificate(
|
||||||
certificateName,
|
certificateName,
|
||||||
|
@ -65,7 +67,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const controller = new AbortController();
|
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
|
// 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.");
|
recorder.skip("browser", "Timeout tests don't work on playback mode.");
|
||||||
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
|
|
||||||
await client.beginCreateCertificate(
|
await client.beginCreateCertificate(
|
||||||
|
@ -137,7 +139,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
|
|
||||||
const poller = await client.beginCreateCertificate(
|
const poller = await client.beginCreateCertificate(
|
||||||
|
@ -160,7 +162,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
|
|
||||||
const poller = await client.beginCreateCertificate(
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
await client.beginCreateCertificate(
|
await client.beginCreateCertificate(
|
||||||
certificateName,
|
certificateName,
|
||||||
|
@ -223,7 +225,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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.");
|
recorder.skip("browser", "This test uses the file system.");
|
||||||
// Skipping this test from the live browser test runs, because we use the file system.
|
// Skipping this test from the live browser test runs, because we use the file system.
|
||||||
if (!isNode) {
|
if (!isNode) {
|
||||||
|
@ -272,7 +274,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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.");
|
recorder.skip("browser", "This test uses the file system.");
|
||||||
// Skipping this test from the live browser test runs, because we use the file system.
|
// Skipping this test from the live browser test runs, because we use the file system.
|
||||||
if (!isNode) {
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
await client.beginCreateCertificate(
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
await client.beginCreateCertificate(
|
await client.beginCreateCertificate(
|
||||||
certificateName,
|
certificateName,
|
||||||
|
@ -339,7 +341,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
|
@ -352,7 +354,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
assert.equal(error.statusCode, 404);
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
await client.beginCreateCertificate(
|
await client.beginCreateCertificate(
|
||||||
certificateName,
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
await client.beginCreateCertificate(
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
|
@ -414,7 +416,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can get a deleted certificate", () => {
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
await client.beginCreateCertificate(
|
await client.beginCreateCertificate(
|
||||||
certificateName,
|
certificateName,
|
||||||
|
@ -436,7 +438,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
await testClient.purgeCertificate(certificateName);
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
await client.beginCreateCertificate(
|
await client.beginCreateCertificate(
|
||||||
certificateName,
|
certificateName,
|
||||||
|
@ -460,7 +462,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
await testClient.purgeCertificate(certificateName);
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
let error;
|
let error;
|
||||||
try {
|
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 issuerName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const certificateName = 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);
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
|
|
||||||
await client.beginCreateCertificate(
|
await client.beginCreateCertificate(
|
||||||
|
@ -562,7 +564,7 @@ describe("Certificates client - create, read, update and delete", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
await client.beginCreateCertificate(
|
await client.beginCreateCertificate(
|
||||||
certificateName,
|
certificateName,
|
||||||
|
|
|
@ -26,13 +26,15 @@ describe("Certificates client - list certificates in various ways", () => {
|
||||||
subject: "cn=MyCert"
|
subject: "cn=MyCert"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
suffix = authentication.suffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
suffix = authentication.suffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
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.
|
// Use this while recording to make sure the target keyvault is clean.
|
||||||
// The next tests will produce a more consistent output.
|
// The next tests will produce a more consistent output.
|
||||||
// This test is only useful while developing locally.
|
// This test is only useful while developing locally.
|
||||||
it("can purge all certificates", async function(): Promise<void> {
|
it("can purge all certificates", /** @this Mocha.Context */ async function(): Promise<void> {
|
||||||
// WARNING: When TEST_MODE equals "record", all of the certificates in the indicated KEYVAULT_NAME will be deleted as part of this test.
|
// 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()) {
|
if (!isRecordMode()) {
|
||||||
return this.skip();
|
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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
||||||
for (const name of certificateNames) {
|
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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
||||||
for (const name of certificateNames) {
|
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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
||||||
for (const name of certificateNames) {
|
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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
||||||
for (const name of certificateNames) {
|
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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
|
|
||||||
const certificateTags = ["tag01", "tag02", "tag03"];
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
let totalVersions = 0;
|
let totalVersions = 0;
|
||||||
for await (const page of client.listPropertiesOfCertificateVersions(certificateName).byPage()) {
|
for await (const page of client.listPropertiesOfCertificateVersions(certificateName).byPage()) {
|
||||||
|
|
|
@ -17,13 +17,15 @@ describe("Certificates client - LRO - create", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
certificateSuffix = authentication.suffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
certificateSuffix = authentication.suffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -31,7 +33,7 @@ describe("Certificates client - LRO - create", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -55,7 +57,7 @@ describe("Certificates client - LRO - create", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,13 +17,15 @@ describe("Certificates client - lro - delete", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
certificateSuffix = authentication.suffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
certificateSuffix = authentication.suffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -31,7 +33,7 @@ describe("Certificates client - lro - delete", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -61,7 +63,7 @@ describe("Certificates client - lro - delete", () => {
|
||||||
await testClient.purgeCertificate(certificateName);
|
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(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,13 +21,15 @@ describe("Certificates client - LRO - certificate operation", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
certificateSuffix = authentication.suffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
certificateSuffix = authentication.suffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -35,7 +37,7 @@ describe("Certificates client - LRO - certificate operation", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -64,7 +66,7 @@ describe("Certificates client - LRO - certificate operation", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,13 +18,15 @@ describe("Certificates client - LRO - recoverDelete", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
certificateSuffix = authentication.suffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
certificateSuffix = authentication.suffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -32,7 +34,7 @@ describe("Certificates client - LRO - recoverDelete", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -65,7 +67,7 @@ describe("Certificates client - LRO - recoverDelete", () => {
|
||||||
await testClient.flushCertificate(certificateName);
|
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(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const certificateName = testClient.formatName(
|
const certificateName = testClient.formatName(
|
||||||
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
`${certificatePrefix}-${this!.test!.title}-${certificateSuffix}`
|
||||||
|
|
|
@ -24,16 +24,18 @@ describe("Certificates client - merge and import certificates", () => {
|
||||||
let credential: ClientSecretCredential;
|
let credential: ClientSecretCredential;
|
||||||
let secretClient: SecretClient;
|
let secretClient: SecretClient;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
suffix = authentication.suffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
suffix = authentication.suffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
keyVaultUrl = authentication.keyVaultUrl;
|
recorder = authentication.recorder;
|
||||||
credential = authentication.credential;
|
keyVaultUrl = authentication.keyVaultUrl;
|
||||||
secretClient = new SecretClient(keyVaultUrl, credential);
|
credential = authentication.credential;
|
||||||
});
|
secretClient = new SecretClient(keyVaultUrl, credential);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -41,7 +43,7 @@ describe("Certificates client - merge and import certificates", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
||||||
const createPoller = await client.beginCreateCertificate(
|
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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
const certificateNames = [`${certificateName}0`, `${certificateName}1`];
|
||||||
const createPoller = await client.beginCreateCertificate(
|
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.
|
// 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.
|
// 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<void> {
|
it("can merge a self signed certificate", /** @this Mocha.Context */ async function(): Promise<
|
||||||
|
void
|
||||||
|
> {
|
||||||
recorder.skip(
|
recorder.skip(
|
||||||
undefined,
|
undefined,
|
||||||
"The signed certificate will never be the same, so we can't play it back."
|
"The signed certificate will never be the same, so we can't play it back."
|
||||||
|
|
|
@ -23,13 +23,15 @@ describe("Certificates client - restore certificates and recover backups", () =>
|
||||||
subject: "cn=MyCert"
|
subject: "cn=MyCert"
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
suffix = authentication.suffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
suffix = authentication.suffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -37,7 +39,7 @@ describe("Certificates client - restore certificates and recover backups", () =>
|
||||||
|
|
||||||
// The tests follow
|
// 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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const createPoller = await client.beginCreateCertificate(
|
const createPoller = await client.beginCreateCertificate(
|
||||||
certificateName,
|
certificateName,
|
||||||
|
@ -65,7 +67,7 @@ describe("Certificates client - restore certificates and recover backups", () =>
|
||||||
await testClient.flushCertificate(certificateName);
|
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}`);
|
const certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
|
@ -81,7 +83,7 @@ describe("Certificates client - restore certificates and recover backups", () =>
|
||||||
if (isRecordMode() || isPlaybackMode()) {
|
if (isRecordMode() || isPlaybackMode()) {
|
||||||
// This test can't run live,
|
// This test can't run live,
|
||||||
// since the purge operation currently can't be expected to finish anytime soon.
|
// 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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const createPoller = await client.beginCreateCertificate(
|
const createPoller = await client.beginCreateCertificate(
|
||||||
certificateName,
|
certificateName,
|
||||||
|
@ -141,7 +143,7 @@ describe("Certificates client - restore certificates and recover backups", () =>
|
||||||
|
|
||||||
if (isNode && !isPlaybackMode()) {
|
if (isNode && !isPlaybackMode()) {
|
||||||
// On playback mode, the tests happen too fast for the timeout to work
|
// 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 certificateName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
const createPoller = await client.beginCreateCertificate(
|
const createPoller = await client.beginCreateCertificate(
|
||||||
certificateName,
|
certificateName,
|
||||||
|
|
|
@ -54,6 +54,7 @@ export interface RestoreCertificateBackupPollOperation
|
||||||
/**
|
/**
|
||||||
* Reaches to the service and updates the restore certificate's poll operation.
|
* 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.
|
* @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(
|
async function update(
|
||||||
this: RestoreCertificateBackupPollOperation,
|
this: RestoreCertificateBackupPollOperation,
|
||||||
|
@ -92,6 +93,7 @@ async function cancel(this: RestoreCertificateBackupPollOperation): Promise<neve
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes the create certificate's poll operation
|
* Serializes the create certificate's poll operation
|
||||||
|
* @this RestoreCertificateBackupPollOperation
|
||||||
*/
|
*/
|
||||||
function toString(this: RestoreCertificateBackupPollOperation): string {
|
function toString(this: RestoreCertificateBackupPollOperation): string {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"ignorePatterns": ["src/core"],
|
"ignorePatterns": ["src/core"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-this-alias": "off",
|
"@typescript-eslint/no-this-alias": "off",
|
||||||
"no-invalid-this": "off",
|
|
||||||
"@azure/azure-sdk/ts-package-json-module": "warn",
|
"@azure/azure-sdk/ts-package-json-module": "warn",
|
||||||
"no-use-before-define": "warn"
|
"no-use-before-define": "warn"
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { RemoteCryptographyProvider } from "../../src/cryptography/remoteCryptog
|
||||||
import { ClientSecretCredential } from "@azure/identity";
|
import { ClientSecretCredential } from "@azure/identity";
|
||||||
|
|
||||||
describe("AesCryptographyProvider browser tests", function() {
|
describe("AesCryptographyProvider browser tests", function() {
|
||||||
it("uses the browser replacement when running in the browser", async function() {
|
it("uses the browser replacement when running in the browser", /** @this Mocha.Context */ async function() {
|
||||||
if (isNode) {
|
if (isNode) {
|
||||||
this.skip();
|
this.skip();
|
||||||
}
|
}
|
||||||
|
@ -43,23 +43,25 @@ describe("AesCryptographyProvider internal tests", function() {
|
||||||
const encryptionAlgorithm = `A${keySize}CBCPAD` as AesCbcEncryptionAlgorithm;
|
const encryptionAlgorithm = `A${keySize}CBCPAD` as AesCbcEncryptionAlgorithm;
|
||||||
let jwk: JsonWebKey;
|
let jwk: JsonWebKey;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
if (!isNode) {
|
/** @this Mocha.Context */ function() {
|
||||||
this.skip();
|
if (!isNode) {
|
||||||
|
this.skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
jwk = {
|
||||||
|
keyOps: ["encrypt", "decrypt", "wrapKey", "unwrapKey"],
|
||||||
|
k: getKey(keySize >> 3), // Generate a symmetric key for testing
|
||||||
|
kty: "oct"
|
||||||
|
};
|
||||||
|
|
||||||
|
cryptoClient = new CryptographyClient(jwk);
|
||||||
}
|
}
|
||||||
|
);
|
||||||
jwk = {
|
|
||||||
keyOps: ["encrypt", "decrypt", "wrapKey", "unwrapKey"],
|
|
||||||
k: getKey(keySize >> 3), // Generate a symmetric key for testing
|
|
||||||
kty: "oct"
|
|
||||||
};
|
|
||||||
|
|
||||||
cryptoClient = new CryptographyClient(jwk);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe(`AES-CBC with PKCS padding (${keySize})`, () => {
|
describe(`AES-CBC with PKCS padding (${keySize})`, () => {
|
||||||
describe("local-only tests", async function() {
|
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 text = this.test!.title;
|
||||||
const encryptResult = await cryptoClient.encrypt({
|
const encryptResult = await cryptoClient.encrypt({
|
||||||
algorithm: encryptionAlgorithm,
|
algorithm: encryptionAlgorithm,
|
||||||
|
@ -75,7 +77,7 @@ describe("AesCryptographyProvider internal tests", function() {
|
||||||
assert.equal(uint8ArrayToString(decryptResult.result), text);
|
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;
|
const text = this.test!.title;
|
||||||
jwk.kty = "RSA";
|
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;
|
const text = this.test!.title;
|
||||||
jwk.k = getKey((keySize >> 3) - 1);
|
jwk.k = getKey((keySize >> 3) - 1);
|
||||||
|
|
||||||
|
@ -132,27 +134,29 @@ describe("AesCryptographyProvider internal tests", function() {
|
||||||
let keyVaultKey: KeyVaultKey;
|
let keyVaultKey: KeyVaultKey;
|
||||||
let remoteProvider: RemoteCryptographyProvider;
|
let remoteProvider: RemoteCryptographyProvider;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
recorder = authentication.recorder;
|
const authentication = await authenticate(this);
|
||||||
|
recorder = authentication.recorder;
|
||||||
|
|
||||||
if (!authentication.hsmClient) {
|
if (!authentication.hsmClient) {
|
||||||
// Managed HSM is not deployed for this run due to service resource restrictions so we skip these tests.
|
// 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 is only necessary while Managed HSM is in preview.
|
||||||
this.skip();
|
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() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this.test!.title}-${keySuffix}`);
|
||||||
keyVaultKey = await client.importKey(keyName, jwk, {});
|
keyVaultKey = await client.importKey(keyName, jwk, {});
|
||||||
remoteProvider = new RemoteCryptographyProvider(keyVaultKey, credential);
|
remoteProvider = new RemoteCryptographyProvider(keyVaultKey, credential);
|
||||||
|
@ -174,7 +178,7 @@ describe("AesCryptographyProvider internal tests", function() {
|
||||||
await testClient.flushKey(keyName);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this.test!.title}-${keySuffix}`);
|
||||||
keyVaultKey = await client.importKey(keyName, jwk, {});
|
keyVaultKey = await client.importKey(keyName, jwk, {});
|
||||||
remoteProvider = new RemoteCryptographyProvider(keyVaultKey, credential);
|
remoteProvider = new RemoteCryptographyProvider(keyVaultKey, credential);
|
||||||
|
|
|
@ -26,13 +26,15 @@ describe("Challenge based authentication tests", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
keySuffix = authentication.keySuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
keySuffix = authentication.keySuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -40,7 +42,7 @@ describe("Challenge based authentication tests", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
||||||
|
|
||||||
|
@ -71,7 +73,7 @@ describe("Challenge based authentication tests", () => {
|
||||||
sandbox.restore();
|
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.
|
// Our goal is to intercept how our pipelines are storing the challenge.
|
||||||
// The first network call should indeed set the challenge in memory.
|
// The first network call should indeed set the challenge in memory.
|
||||||
// Subsequent network calls should not set new challenges.
|
// Subsequent network calls should not set new challenges.
|
||||||
|
|
|
@ -135,7 +135,7 @@ describe("internal crypto tests", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Encrypt parameter mapping", async function() {
|
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!);
|
const text = stringToUint8Array(this.test!.title!);
|
||||||
await client.encrypt("RSA1_5", text, { requestOptions: { timeout: 5 } });
|
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!);
|
const text = stringToUint8Array(this.test!.title!);
|
||||||
|
|
||||||
await client.encrypt(
|
await client.encrypt(
|
||||||
|
@ -163,7 +163,7 @@ describe("internal crypto tests", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Decrypt parameter mapping", async function() {
|
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!);
|
const text = stringToUint8Array(this.test!.title!);
|
||||||
await client.decrypt("RSA1_5", text, { requestOptions: { timeout: 5 } });
|
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!);
|
const text = stringToUint8Array(this.test!.title!);
|
||||||
|
|
||||||
await client.decrypt(
|
await client.decrypt(
|
||||||
|
@ -192,7 +192,7 @@ describe("internal crypto tests", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("RSA local cryptography tests", function() {
|
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) {
|
if (!isNode) {
|
||||||
// Local cryptography is not supported in the browser
|
// Local cryptography is not supported in the browser
|
||||||
this.skip();
|
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) {
|
if (isNode) {
|
||||||
this.skip();
|
this.skip();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe("Keys client's user agent (only in Node, because of fs)", () => {
|
||||||
assert.equal(SDK_VERSION, packageVersion);
|
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) {
|
if (!isNode) {
|
||||||
this.skip();
|
this.skip();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -16,26 +16,28 @@ describe("Keys client - create, read, update and delete operations for managed H
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
recorder = authentication.recorder;
|
const authentication = await authenticate(this);
|
||||||
|
recorder = authentication.recorder;
|
||||||
|
|
||||||
if (!authentication.hsmClient) {
|
if (!authentication.hsmClient) {
|
||||||
// Managed HSM is not deployed for this run due to service resource restrictions so we skip these tests.
|
// 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 is only necessary while Managed HSM is in preview.
|
||||||
this.skip();
|
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() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const options: CreateOctKeyOptions = {
|
const options: CreateOctKeyOptions = {
|
||||||
hsm: true
|
hsm: true
|
||||||
|
|
|
@ -24,13 +24,15 @@ describe("Keys client - create, read, update and delete operations", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
keySuffix = authentication.keySuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
keySuffix = authentication.keySuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -38,7 +40,7 @@ describe("Keys client - create, read, update and delete operations", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const result = await client.createKey(keyName, "RSA");
|
const result = await client.createKey(keyName, "RSA");
|
||||||
assert.equal(result.name, keyName, "Unexpected key name in result from createKey().");
|
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
|
// 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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const controller = new AbortController();
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await assertThrowsAbortError(async () => {
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const result = await client.createRsaKey(keyName);
|
const result = await client.createRsaKey(keyName);
|
||||||
assert.equal(result.name, keyName, "Unexpected key name in result from createKey().");
|
assert.equal(result.name, keyName, "Unexpected key name in result from createKey().");
|
||||||
await testClient.flushKey(keyName);
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const options = {
|
const options = {
|
||||||
keySize: 2048
|
keySize: 2048
|
||||||
|
@ -105,7 +107,7 @@ describe("Keys client - create, read, update and delete operations", () => {
|
||||||
await testClient.flushKey(keyName);
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const options = {
|
const options = {
|
||||||
publicExponent: 3
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const result = await client.createEcKey(keyName);
|
const result = await client.createEcKey(keyName);
|
||||||
assert.equal(result.name, keyName, "Unexpected key name in result from createKey().");
|
assert.equal(result.name, keyName, "Unexpected key name in result from createKey().");
|
||||||
await testClient.flushKey(keyName);
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const options: CreateEcKeyOptions = {
|
const options: CreateEcKeyOptions = {
|
||||||
curve: "P-256"
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await assertThrowsAbortError(async () => {
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const options = {
|
const options = {
|
||||||
enabled: false
|
enabled: false
|
||||||
|
@ -169,7 +171,7 @@ describe("Keys client - create, read, update and delete operations", () => {
|
||||||
await testClient.flushKey(keyName);
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const date = new Date("2019-01-01");
|
const date = new Date("2019-01-01");
|
||||||
const notBefore = new Date(date.getTime() + 5000); // 5 seconds later
|
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);
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const date = new Date("2019-01-01");
|
const date = new Date("2019-01-01");
|
||||||
const expiresOn = new Date(date.getTime() + 5000); // 5 seconds later
|
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);
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const { version } = (await client.createRsaKey(keyName)).properties;
|
const { version } = (await client.createRsaKey(keyName)).properties;
|
||||||
const options: UpdateKeyPropertiesOptions = { enabled: false };
|
const options: UpdateKeyPropertiesOptions = { enabled: false };
|
||||||
|
@ -214,7 +216,7 @@ describe("Keys client - create, read, update and delete operations", () => {
|
||||||
await testClient.flushKey(keyName);
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const createOptions = {
|
const createOptions = {
|
||||||
enabled: false
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const { version } = (await client.createRsaKey(keyName)).properties;
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const poller = await client.beginDeleteKey(keyName, testPollerProperties);
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
try {
|
try {
|
||||||
await client.getKey(keyName);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const getResult = await client.getKey(keyName);
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const { version } = (await client.createKey(keyName, "RSA")).properties;
|
const { version } = (await client.createKey(keyName, "RSA")).properties;
|
||||||
const options: GetKeyOptions = { version };
|
const options: GetKeyOptions = { version };
|
||||||
|
@ -327,7 +329,7 @@ describe("Keys client - create, read, update and delete operations", () => {
|
||||||
await testClient.flushKey(keyName);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const poller = await client.beginDeleteKey(keyName, testPollerProperties);
|
const poller = await client.beginDeleteKey(keyName, testPollerProperties);
|
||||||
|
@ -348,7 +350,7 @@ describe("Keys client - create, read, update and delete operations", () => {
|
||||||
await testClient.purgeKey(keyName);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
|
@ -362,7 +364,7 @@ describe("Keys client - create, read, update and delete operations", () => {
|
||||||
assert.equal(error.statusCode, 404);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const poller = await client.beginDeleteKey(keyName, testPollerProperties);
|
const poller = await client.beginDeleteKey(keyName, testPollerProperties);
|
||||||
|
|
|
@ -20,22 +20,24 @@ describe("CryptographyClient for managed HSM (skipped if MHSM is not deployed)",
|
||||||
let keyVaultKey: KeyVaultKey;
|
let keyVaultKey: KeyVaultKey;
|
||||||
let keySuffix: string;
|
let keySuffix: string;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
recorder = authentication.recorder;
|
const authentication = await authenticate(this);
|
||||||
|
recorder = authentication.recorder;
|
||||||
|
|
||||||
if (!authentication.hsmClient) {
|
if (!authentication.hsmClient) {
|
||||||
// Managed HSM is not deployed for this run due to service resource restrictions so we skip these tests.
|
// 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 is only necessary while Managed HSM is in preview.
|
||||||
this.skip();
|
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() {
|
afterEach(async function() {
|
||||||
await testClient?.flushKey(keyName);
|
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() {
|
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 });
|
keyVaultKey = await hsmClient.createKey(keyName, "AES", { keySize: 256 });
|
||||||
cryptoClient = new CryptographyClient(keyVaultKey.id!, credential);
|
cryptoClient = new CryptographyClient(keyVaultKey.id!, credential);
|
||||||
const text = this.test!.title;
|
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));
|
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 });
|
keyVaultKey = await hsmClient.createKey(keyName, "AES", { keySize: 256 });
|
||||||
cryptoClient = new CryptographyClient(keyVaultKey.id!, credential);
|
cryptoClient = new CryptographyClient(keyVaultKey.id!, credential);
|
||||||
const text = this.test!.title;
|
const text = this.test!.title;
|
||||||
|
|
|
@ -29,29 +29,33 @@ describe("CryptographyClient (all decrypts happen remotely)", () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
client = authentication.client;
|
const authentication = await authenticate(this);
|
||||||
recorder = authentication.recorder;
|
client = authentication.client;
|
||||||
testClient = authentication.testClient;
|
recorder = authentication.recorder;
|
||||||
credential = authentication.credential;
|
testClient = authentication.testClient;
|
||||||
keySuffix = authentication.keySuffix;
|
credential = authentication.credential;
|
||||||
keyName = testClient.formatName("cryptography-client-test" + keySuffix);
|
keySuffix = authentication.keySuffix;
|
||||||
keyVaultKey = await client.createKey(keyName, "RSA");
|
keyName = testClient.formatName("cryptography-client-test" + keySuffix);
|
||||||
cryptoClient = new CryptographyClient(keyVaultKey.id!, credential);
|
keyVaultKey = await client.createKey(keyName, "RSA");
|
||||||
});
|
cryptoClient = new CryptographyClient(keyVaultKey.id!, credential);
|
||||||
|
|
||||||
afterEach(async function() {
|
|
||||||
if (!this.currentTest?.isPending()) {
|
|
||||||
await testClient.flushKey(keyName);
|
|
||||||
}
|
}
|
||||||
await recorder.stop();
|
);
|
||||||
});
|
|
||||||
|
afterEach(
|
||||||
|
/** @this Mocha.Context */ async function() {
|
||||||
|
if (!this.currentTest?.isPending()) {
|
||||||
|
await testClient.flushKey(keyName);
|
||||||
|
}
|
||||||
|
await recorder.stop();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// The tests follow
|
// The tests follow
|
||||||
|
|
||||||
if (!isPlaybackMode()) {
|
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 text = this.test!.title;
|
||||||
const encryptResult = await cryptoClient.encrypt({
|
const encryptResult = await cryptoClient.encrypt({
|
||||||
algorithm: "RSA1_5",
|
algorithm: "RSA1_5",
|
||||||
|
@ -65,7 +69,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => {
|
||||||
assert.equal(text, decryptedText);
|
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 text = this.test!.title;
|
||||||
const localProvider = new RsaCryptographyProvider(keyVaultKey.key!);
|
const localProvider = new RsaCryptographyProvider(keyVaultKey.key!);
|
||||||
const encryptResult = await localProvider.encrypt({
|
const encryptResult = await localProvider.encrypt({
|
||||||
|
@ -80,7 +84,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => {
|
||||||
assert.equal(text, decryptedText);
|
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 text = this.test!.title;
|
||||||
const encryptResult = await cryptoClient.encrypt(
|
const encryptResult = await cryptoClient.encrypt(
|
||||||
{
|
{
|
||||||
|
@ -97,7 +101,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => {
|
||||||
assert.equal(text, decryptedText);
|
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 text = this.test!.title;
|
||||||
const localProvider = new RsaCryptographyProvider(keyVaultKey.key!);
|
const localProvider = new RsaCryptographyProvider(keyVaultKey.key!);
|
||||||
const encryptResult = await localProvider.encrypt({
|
const encryptResult = await localProvider.encrypt({
|
||||||
|
@ -112,7 +116,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => {
|
||||||
assert.equal(text, decryptedText);
|
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 customKeyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const customKeyVaultKey = await client.createKey(customKeyName, "RSA");
|
const customKeyVaultKey = await client.createKey(customKeyName, "RSA");
|
||||||
const cryptoClientFromKey = new CryptographyClient(customKeyVaultKey, credential);
|
const cryptoClientFromKey = new CryptographyClient(customKeyVaultKey, credential);
|
||||||
|
@ -162,7 +166,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => {
|
||||||
assert.equal("RSA1_5", unwrappedResult.algorithm);
|
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(
|
recorder.skip(
|
||||||
undefined,
|
undefined,
|
||||||
"Wrapping and unwrapping don't cause a repeatable pattern, so these tests can only run in playback mode"
|
"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()) {
|
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 hsmKeyName = keyName + "2";
|
||||||
const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM");
|
const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM");
|
||||||
const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential);
|
const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential);
|
||||||
|
@ -188,7 +192,7 @@ describe("CryptographyClient (all decrypts happen remotely)", () => {
|
||||||
await testClient.flushKey(hsmKeyName);
|
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 hsmKeyName = keyName + "2";
|
||||||
const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM");
|
const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM");
|
||||||
const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential);
|
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(
|
recorder.skip(
|
||||||
undefined,
|
undefined,
|
||||||
"Wrapping and unwrapping don't cause a repeatable pattern, so this test can only run live"
|
"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);
|
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(
|
recorder.skip(
|
||||||
undefined,
|
undefined,
|
||||||
"Wrapping and unwrapping don't cause a repeatable pattern, so this test can only run live"
|
"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);
|
await testClient.flushKey(hsmKeyName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sign and verify with RS256 through an RSA-HSM key", async function(): Promise<void> {
|
it("sign and verify with RS256 through an RSA-HSM key", /** @this Mocha.Context */ async function(): Promise<
|
||||||
|
void
|
||||||
|
> {
|
||||||
const hsmKeyName = keyName + "2";
|
const hsmKeyName = keyName + "2";
|
||||||
const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM");
|
const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM");
|
||||||
const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential);
|
const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential);
|
||||||
|
@ -264,7 +270,9 @@ describe("CryptographyClient (all decrypts happen remotely)", () => {
|
||||||
await testClient.flushKey(hsmKeyName);
|
await testClient.flushKey(hsmKeyName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sign and verify with RS384 through an RSA-HSM key", async function(): Promise<void> {
|
it("sign and verify with RS384 through an RSA-HSM key", /** @this Mocha.Context */ async function(): Promise<
|
||||||
|
void
|
||||||
|
> {
|
||||||
const hsmKeyName = keyName + "2";
|
const hsmKeyName = keyName + "2";
|
||||||
const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM");
|
const hsmKey = await client.createKey(hsmKeyName, "RSA-HSM");
|
||||||
const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential);
|
const hsmCryptoClient = new CryptographyClient(hsmKey.id!, credential);
|
||||||
|
|
|
@ -16,13 +16,15 @@ describe("Keys client - import keys", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
suffix = authentication.keySuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
suffix = authentication.keySuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -30,7 +32,7 @@ describe("Keys client - import keys", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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}`);
|
const keyName = testClient.formatName(`${prefix}-${this!.test!.title}-${suffix}`);
|
||||||
function toBytes(hex: string): Uint8Array {
|
function toBytes(hex: string): Uint8Array {
|
||||||
if (hex.length % 2) {
|
if (hex.length % 2) {
|
||||||
|
|
|
@ -20,13 +20,15 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this, serviceVersion);
|
/** @this Mocha.Context */ async function() {
|
||||||
keySuffix = authentication.keySuffix;
|
const authentication = await authenticate(this, serviceVersion);
|
||||||
client = authentication.client;
|
keySuffix = authentication.keySuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -37,7 +39,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => {
|
||||||
// Use this while recording to make sure the target keyvault is clean.
|
// Use this while recording to make sure the target keyvault is clean.
|
||||||
// The next tests will produce a more consistent output.
|
// The next tests will produce a more consistent output.
|
||||||
// This test is only useful while developing locally.
|
// This test is only useful while developing locally.
|
||||||
it("can purge all keys", async function(): Promise<void> {
|
it("can purge all keys", /** @this Mocha.Context */ async function(): Promise<void> {
|
||||||
// WARNING: When TEST_MODE equals "record", all of the keys in the indicated KEYVAULT_URI will be deleted as part of this test.
|
// 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()) {
|
if (!isRecordMode()) {
|
||||||
return this.skip();
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
let totalVersions = 0;
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
let totalVersions = 0;
|
let totalVersions = 0;
|
||||||
|
@ -103,7 +105,7 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion, onVersions) => {
|
||||||
await testClient.flushKey(keyName);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
let totalVersions = 0;
|
let totalVersions = 0;
|
||||||
for await (const version of client.listPropertiesOfKeyVersions(keyName)) {
|
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}`);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
let totalVersions = 0;
|
let totalVersions = 0;
|
||||||
for await (const page of client.listPropertiesOfKeyVersions(keyName).byPage()) {
|
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}`);
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
||||||
for (const name of keyNames) {
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
||||||
for (const name of keyNames) {
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
||||||
for (const name of keyNames) {
|
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 keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
const keyNames = [`${keyName}-0`, `${keyName}-1`];
|
||||||
for (const name of keyNames) {
|
for (const name of keyNames) {
|
||||||
|
|
|
@ -33,14 +33,16 @@ describe("Local cryptography public tests", () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
client = authentication.client;
|
const authentication = await authenticate(this);
|
||||||
recorder = authentication.recorder;
|
client = authentication.client;
|
||||||
testClient = authentication.testClient;
|
recorder = authentication.recorder;
|
||||||
credential = authentication.credential;
|
testClient = authentication.testClient;
|
||||||
keySuffix = authentication.keySuffix;
|
credential = authentication.credential;
|
||||||
});
|
keySuffix = authentication.keySuffix;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -51,11 +53,13 @@ describe("Local cryptography public tests", () => {
|
||||||
let customKeyVaultKey: KeyVaultKey;
|
let customKeyVaultKey: KeyVaultKey;
|
||||||
let cryptoClientFromKey: CryptographyClient;
|
let cryptoClientFromKey: CryptographyClient;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
customKeyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
/** @this Mocha.Context */ async function() {
|
||||||
customKeyVaultKey = await client.createKey(customKeyName, "RSA");
|
customKeyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
cryptoClientFromKey = new CryptographyClient(customKeyVaultKey.key!);
|
customKeyVaultKey = await client.createKey(customKeyName, "RSA");
|
||||||
});
|
cryptoClientFromKey = new CryptographyClient(customKeyVaultKey.key!);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
it("the CryptographyClient can be created from a local JsonWebKey object", async function() {
|
it("the CryptographyClient can be created from a local JsonWebKey object", async function() {
|
||||||
assert.isEmpty(cryptoClientFromKey.vaultUrl);
|
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");
|
recorder.skip(undefined, "Local encryption can't be tested on playback");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyVaultKey = await client.createKey(keyName, "RSA");
|
const keyVaultKey = await client.createKey(keyName, "RSA");
|
||||||
|
@ -137,7 +141,7 @@ describe("Local cryptography public tests", () => {
|
||||||
await testClient.flushKey(keyName);
|
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");
|
recorder.skip(undefined, "Local encryption can't be tested on playback");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyVaultKey = await client.createKey(keyName, "RSA");
|
const keyVaultKey = await client.createKey(keyName, "RSA");
|
||||||
|
@ -151,7 +155,7 @@ describe("Local cryptography public tests", () => {
|
||||||
await testClient.flushKey(keyName);
|
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");
|
recorder.skip(undefined, "Local encryption can't be tested on playback");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyVaultKey = await client.createKey(keyName, "RSA");
|
const keyVaultKey = await client.createKey(keyName, "RSA");
|
||||||
|
@ -168,7 +172,7 @@ describe("Local cryptography public tests", () => {
|
||||||
await testClient.flushKey(keyName);
|
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");
|
recorder.skip(undefined, "Local encryption can't be tested on playback");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyVaultKey = await client.createKey(keyName, "RSA");
|
const keyVaultKey = await client.createKey(keyName, "RSA");
|
||||||
|
@ -190,35 +194,43 @@ describe("Local cryptography public tests", () => {
|
||||||
const localSupportedAlgorithmNames = Object.keys(rsaProvider.signatureAlgorithmToHashAlgorithm);
|
const localSupportedAlgorithmNames = Object.keys(rsaProvider.signatureAlgorithmToHashAlgorithm);
|
||||||
|
|
||||||
for (const localAlgorithmName of localSupportedAlgorithmNames) {
|
for (const localAlgorithmName of localSupportedAlgorithmNames) {
|
||||||
it(localAlgorithmName, async function(): Promise<void> {
|
it(
|
||||||
recorder.skip(
|
localAlgorithmName,
|
||||||
"browser",
|
/** @this Mocha.Context */ async function(): Promise<void> {
|
||||||
`Local sign of algorithm ${localAlgorithmName} is only supported in NodeJS`
|
recorder.skip(
|
||||||
);
|
"browser",
|
||||||
|
`Local sign of algorithm ${localAlgorithmName} is only supported in NodeJS`
|
||||||
|
);
|
||||||
|
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
const keyVaultKey = await client.createKey(keyName, "RSA");
|
const keyVaultKey = await client.createKey(keyName, "RSA");
|
||||||
const cryptoClient = new CryptographyClient(keyVaultKey.id!, credential);
|
const cryptoClient = new CryptographyClient(keyVaultKey.id!, credential);
|
||||||
|
|
||||||
// Sign is not implemented yet.
|
// Sign is not implemented yet.
|
||||||
// This boils down to the JWK to PEM conversion, which doesn't support private keys at the moment.
|
// This boils down to the JWK to PEM conversion, which doesn't support private keys at the moment.
|
||||||
const signatureValue = this.test!.title;
|
const signatureValue = this.test!.title;
|
||||||
const hash = createHash(rsaProvider.signatureAlgorithmToHashAlgorithm[localAlgorithmName]);
|
const hash = createHash(
|
||||||
hash.update(signatureValue);
|
rsaProvider.signatureAlgorithmToHashAlgorithm[localAlgorithmName]
|
||||||
const digest = hash.digest();
|
);
|
||||||
const signature = await cryptoClient.sign(localAlgorithmName as SignatureAlgorithm, digest);
|
hash.update(signatureValue);
|
||||||
|
const digest = hash.digest();
|
||||||
|
const signature = await cryptoClient.sign(
|
||||||
|
localAlgorithmName as SignatureAlgorithm,
|
||||||
|
digest
|
||||||
|
);
|
||||||
|
|
||||||
// Local Cryptography Client part
|
// Local Cryptography Client part
|
||||||
const localCryptoClient = new CryptographyClient(keyVaultKey.key!);
|
const localCryptoClient = new CryptographyClient(keyVaultKey.key!);
|
||||||
const verifyResult = await localCryptoClient.verifyData(
|
const verifyResult = await localCryptoClient.verifyData(
|
||||||
localAlgorithmName as LocalSupportedAlgorithmName,
|
localAlgorithmName as LocalSupportedAlgorithmName,
|
||||||
digest,
|
digest,
|
||||||
signature.result
|
signature.result
|
||||||
);
|
);
|
||||||
assert.ok(verifyResult);
|
assert.ok(verifyResult);
|
||||||
|
|
||||||
await testClient.flushKey(keyName);
|
await testClient.flushKey(keyName);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,13 +17,15 @@ describe("Keys client - Long Running Operations - delete", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
keySuffix = authentication.keySuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
keySuffix = authentication.keySuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -31,7 +33,7 @@ describe("Keys client - Long Running Operations - delete", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const poller = await client.beginDeleteKey(keyName, testPollerProperties);
|
const poller = await client.beginDeleteKey(keyName, testPollerProperties);
|
||||||
|
@ -50,7 +52,7 @@ describe("Keys client - Long Running Operations - delete", () => {
|
||||||
await testClient.purgeKey(keyName);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const poller = await client.beginDeleteKey(keyName, testPollerProperties);
|
const poller = await client.beginDeleteKey(keyName, testPollerProperties);
|
||||||
|
|
|
@ -18,13 +18,15 @@ describe("Keys client - Long Running Operations - recoverDelete", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
keySuffix = authentication.keySuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
keySuffix = authentication.keySuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -32,7 +34,7 @@ describe("Keys client - Long Running Operations - recoverDelete", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
|
|
||||||
|
@ -55,7 +57,7 @@ describe("Keys client - Long Running Operations - recoverDelete", () => {
|
||||||
await testClient.flushKey(keyName);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const deletePoller = await client.beginDeleteKey(keyName, testPollerProperties);
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
|
|
|
@ -17,13 +17,15 @@ describe("Keys client - restore keys and recover backups", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
keySuffix = authentication.keySuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
keySuffix = authentication.keySuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -31,7 +33,7 @@ describe("Keys client - restore keys and recover backups", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const deletePoller = await client.beginDeleteKey(keyName, testPollerProperties);
|
const deletePoller = await client.beginDeleteKey(keyName, testPollerProperties);
|
||||||
|
@ -52,7 +54,7 @@ describe("Keys client - restore keys and recover backups", () => {
|
||||||
await testClient.flushKey(keyName);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
|
@ -66,7 +68,7 @@ describe("Keys client - restore keys and recover backups", () => {
|
||||||
assert.equal(error.statusCode, 404);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const result = await client.backupKey(keyName);
|
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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
|
@ -103,7 +105,7 @@ describe("Keys client - restore keys and recover backups", () => {
|
||||||
if (isRecordMode() || isPlaybackMode()) {
|
if (isRecordMode() || isPlaybackMode()) {
|
||||||
// This test can't run live,
|
// This test can't run live,
|
||||||
// since the purge operation currently can't be expected to finish anytime soon.
|
// 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}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
const backup = await client.backupKey(keyName);
|
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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
const keyName = testClient.formatName(`${keyPrefix}-${this!.test!.title}-${keySuffix}`);
|
||||||
await client.createKey(keyName, "RSA");
|
await client.createKey(keyName, "RSA");
|
||||||
|
|
|
@ -53,6 +53,7 @@ export interface RestoreKeyBackupPollOperation
|
||||||
/**
|
/**
|
||||||
* Reaches to the service and updates the restore key's poll operation.
|
* 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.
|
* @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(
|
async function update(
|
||||||
this: RestoreKeyBackupPollOperation,
|
this: RestoreKeyBackupPollOperation,
|
||||||
|
@ -91,6 +92,7 @@ async function cancel(this: RestoreKeyBackupPollOperation): Promise<never> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes the create key's poll operation
|
* Serializes the create key's poll operation
|
||||||
|
* @this RestoreKeyBackupPollOperation
|
||||||
*/
|
*/
|
||||||
function toString(this: RestoreKeyBackupPollOperation): string {
|
function toString(this: RestoreKeyBackupPollOperation): string {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"ignorePatterns": ["src/core"],
|
"ignorePatterns": ["src/core"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-this-alias": "off",
|
"@typescript-eslint/no-this-alias": "off",
|
||||||
"no-invalid-this": "off",
|
|
||||||
"@azure/azure-sdk/ts-package-json-module": "warn",
|
"@azure/azure-sdk/ts-package-json-module": "warn",
|
||||||
"no-use-before-define": "warn"
|
"no-use-before-define": "warn"
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,15 @@ describe("Challenge based authentication tests", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
secretSuffix = authentication.secretSuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
secretSuffix = authentication.secretSuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -40,7 +42,7 @@ describe("Challenge based authentication tests", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -73,7 +75,7 @@ describe("Challenge based authentication tests", () => {
|
||||||
sandbox.restore();
|
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.
|
// Our goal is to intercept how our pipelines are storing the challenge.
|
||||||
// The first network call should indeed set the challenge in memory.
|
// The first network call should indeed set the challenge in memory.
|
||||||
// Subsequent network calls should not set new challenges.
|
// Subsequent network calls should not set new challenges.
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe("Secrets client's user agent (only in Node, because of fs)", () => {
|
||||||
assert.equal(SDK_VERSION, packageVersion);
|
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) {
|
if (!isNode) {
|
||||||
this.skip();
|
this.skip();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,13 +19,15 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
secretSuffix = authentication.secretSuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
secretSuffix = authentication.secretSuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -33,7 +35,7 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
|
|
||||||
// The tests follow
|
// The tests follow
|
||||||
|
|
||||||
it("can add a secret", async function() {
|
it("can add a secret", /** @this Mocha.Context */ async function() {
|
||||||
const secretName = testClient.formatName(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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.
|
// 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.
|
// 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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const secretName = testClient.formatName(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -104,7 +106,7 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
await testClient.flushSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -120,7 +122,7 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
await testClient.flushSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const secretName = testClient.formatName(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -182,7 +184,7 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
await testClient.flushSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const secretName = testClient.formatName(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -234,7 +236,7 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
await testClient.flushSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -247,7 +249,7 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
await testClient.flushSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -262,7 +264,7 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
assert.equal(error.statusCode, 404);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const secretName = testClient.formatName(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -324,7 +326,7 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
assert.equal(error.statusCode, 404);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -351,7 +353,7 @@ describe("Secret client - create, read, update and delete operations", () => {
|
||||||
await testClient.purgeSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,13 +21,15 @@ describe("Secret client - list secrets in various ways", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
secretSuffix = authentication.secretSuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
secretSuffix = authentication.secretSuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
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.
|
// Use this while recording to make sure the target keyvault is clean.
|
||||||
// The next tests will produce a more consistent output.
|
// The next tests will produce a more consistent output.
|
||||||
// This test is only useful while developing locally.
|
// This test is only useful while developing locally.
|
||||||
it("can purge all secrets", async function(): Promise<void> {
|
it("can purge all secrets", /** @this Mocha.Context */ async function(): Promise<void> {
|
||||||
// WARNING: When TEST_MODE equals "record", all of the secrets in the indicated KEYVAULT_URI will be deleted as part of this test.
|
// 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()) {
|
if (!isRecordMode()) {
|
||||||
return this.skip();
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const iter = client.listPropertiesOfSecrets({
|
const iter = client.listPropertiesOfSecrets({
|
||||||
requestOptions: { timeout: 1 }
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const secretName = testClient.formatName(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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}`);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -273,7 +275,7 @@ describe("Secret client - list secrets in various ways", () => {
|
||||||
await testClient.flushSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,13 +18,15 @@ describe("Secrets client - Long Running Operations - delete", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
secretSuffix = authentication.secretSuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
secretSuffix = authentication.secretSuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -32,7 +34,7 @@ describe("Secrets client - Long Running Operations - delete", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -53,7 +55,7 @@ describe("Secrets client - Long Running Operations - delete", () => {
|
||||||
await testClient.purgeSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const secretName = testClient.formatName(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
|
|
|
@ -18,13 +18,15 @@ describe("Secrets client - Long Running Operations - recoverDelete", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
secretSuffix = authentication.secretSuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
secretSuffix = authentication.secretSuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -32,7 +34,7 @@ describe("Secrets client - Long Running Operations - recoverDelete", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -57,7 +59,7 @@ describe("Secrets client - Long Running Operations - recoverDelete", () => {
|
||||||
await testClient.flushSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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
|
// 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.");
|
recorder.skip(undefined, "Timeout tests don't work on playback mode.");
|
||||||
const secretName = testClient.formatName(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
|
|
|
@ -18,13 +18,15 @@ describe("Secret client - restore secrets and recover backups", () => {
|
||||||
let testClient: TestClient;
|
let testClient: TestClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
const authentication = await authenticate(this);
|
/** @this Mocha.Context */ async function() {
|
||||||
secretSuffix = authentication.secretSuffix;
|
const authentication = await authenticate(this);
|
||||||
client = authentication.client;
|
secretSuffix = authentication.secretSuffix;
|
||||||
testClient = authentication.testClient;
|
client = authentication.client;
|
||||||
recorder = authentication.recorder;
|
testClient = authentication.testClient;
|
||||||
});
|
recorder = authentication.recorder;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -32,7 +34,7 @@ describe("Secret client - restore secrets and recover backups", () => {
|
||||||
|
|
||||||
// The tests follow
|
// 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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -62,7 +64,7 @@ describe("Secret client - restore secrets and recover backups", () => {
|
||||||
await testClient.flushSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -83,7 +85,7 @@ describe("Secret client - restore secrets and recover backups", () => {
|
||||||
|
|
||||||
if (isNode && !isPlaybackMode()) {
|
if (isNode && !isPlaybackMode()) {
|
||||||
// On playback mode, the tests happen too fast for the timeout to work
|
// 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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -119,7 +121,7 @@ describe("Secret client - restore secrets and recover backups", () => {
|
||||||
await testClient.flushSecret(secretName);
|
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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -137,7 +139,7 @@ describe("Secret client - restore secrets and recover backups", () => {
|
||||||
if (isRecordMode() || isPlaybackMode()) {
|
if (isRecordMode() || isPlaybackMode()) {
|
||||||
// This test can't run live,
|
// This test can't run live,
|
||||||
// since the purge operation currently can't be expected to finish anytime soon.
|
// 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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
@ -182,7 +184,7 @@ describe("Secret client - restore secrets and recover backups", () => {
|
||||||
|
|
||||||
if (isNode && !isPlaybackMode()) {
|
if (isNode && !isPlaybackMode()) {
|
||||||
// On playback mode, the tests happen too fast for the timeout to work
|
// 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(
|
const secretName = testClient.formatName(
|
||||||
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
`${secretPrefix}-${this!.test!.title}-${secretSuffix}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -54,6 +54,7 @@ export interface RestoreSecretBackupPollOperation
|
||||||
/**
|
/**
|
||||||
* Reaches to the service and updates the restore secret's poll operation.
|
* 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.
|
* @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(
|
async function update(
|
||||||
this: RestoreSecretBackupPollOperation,
|
this: RestoreSecretBackupPollOperation,
|
||||||
|
@ -92,6 +93,7 @@ async function cancel(this: RestoreSecretBackupPollOperation): Promise<never> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes the create secret's poll operation
|
* Serializes the create secret's poll operation
|
||||||
|
* @this RestoreSecretBackupPollOperation
|
||||||
*/
|
*/
|
||||||
function toString(this: RestoreSecretBackupPollOperation): string {
|
function toString(this: RestoreSecretBackupPollOperation): string {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
|
|
|
@ -19,10 +19,11 @@ matrix([[true, false]] as const, async (useAad) => {
|
||||||
let client: MetricsAdvisorAdministrationClient;
|
let client: MetricsAdvisorAdministrationClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
({ recorder, client } = createRecordedAdminClient(this, makeCredential(useAad)));
|
({ recorder, client } = createRecordedAdminClient(this, makeCredential(useAad)));
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
|
@ -78,7 +79,7 @@ matrix([[true, false]] as const, async (useAad) => {
|
||||||
assert.ok(result.latestActiveTimestamp, "Expecting valid latest active timestamp");
|
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(
|
const iterator = client.listDataFeedIngestionStatus(
|
||||||
testEnv.METRICS_ADVISOR_AZURE_SQLSERVER_DATAFEED_ID,
|
testEnv.METRICS_ADVISOR_AZURE_SQLSERVER_DATAFEED_ID,
|
||||||
new Date(Date.UTC(2020, 7, 22)),
|
new Date(Date.UTC(2020, 7, 22)),
|
||||||
|
@ -101,7 +102,6 @@ matrix([[true, false]] as const, async (useAad) => {
|
||||||
const result2 = await iterator2.next();
|
const result2 = await iterator2.next();
|
||||||
assert.notEqual(result2.value.status, "Succeeded");
|
assert.notEqual(result2.value.status, "Succeeded");
|
||||||
} else {
|
} else {
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
this.skip();
|
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) {
|
if (!createdAlertConfigId) {
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
this.skip();
|
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) {
|
if (!createdDetectionConfigId) {
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
this.skip();
|
this.skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,11 @@ matrix([[true, false]] as const, async (useAad) => {
|
||||||
let client: MetricsAdvisorClient;
|
let client: MetricsAdvisorClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
({ recorder, client } = createRecordedAdvisorClient(this, makeCredential(useAad)));
|
({ recorder, client } = createRecordedAdvisorClient(this, makeCredential(useAad)));
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
|
|
|
@ -24,16 +24,17 @@ matrix([[true, false]] as const, async (useAad) => {
|
||||||
let emailHookName: string;
|
let emailHookName: string;
|
||||||
let webHookName: string;
|
let webHookName: string;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
({ recorder, client } = createRecordedAdminClient(this, makeCredential(useAad)));
|
({ recorder, client } = createRecordedAdminClient(this, makeCredential(useAad)));
|
||||||
if (recorder && !emailHookName) {
|
if (recorder && !emailHookName) {
|
||||||
emailHookName = recorder.getUniqueName("js-test-emailHook-");
|
emailHookName = recorder.getUniqueName("js-test-emailHook-");
|
||||||
|
}
|
||||||
|
if (recorder && !webHookName) {
|
||||||
|
webHookName = recorder.getUniqueName("js-test-webHook-");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (recorder && !webHookName) {
|
);
|
||||||
webHookName = recorder.getUniqueName("js-test-webHook-");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
|
|
|
@ -77,11 +77,12 @@ describe("[AccountKey] MixedRealityStsClient functional tests", function() {
|
||||||
let client: MixedRealityStsClient;
|
let client: MixedRealityStsClient;
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
recorder = createRecorder(this);
|
recorder = createRecorder(this);
|
||||||
client = createClient();
|
client = createClient();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
// Stop the recording.
|
// Stop the recording.
|
||||||
|
|
|
@ -62,10 +62,11 @@ describe("SchemaRegistryClient", function() {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
let client: SchemaRegistryClient;
|
let client: SchemaRegistryClient;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
({ client, recorder } = createRecordedClient(this));
|
({ client, recorder } = createRecordedClient(this));
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||||
|
"extends": ["../../../tsdoc.json"]
|
||||||
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
/* eslint-disable no-invalid-this */
|
|
||||||
|
|
||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
import { Recorder, record, isPlaybackMode, isLiveMode } from "@azure/test-utils-recorder";
|
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";
|
const TEST_INDEX_NAME = isLiveMode() ? createRandomIndexName() : "hotel-live-test1";
|
||||||
|
|
||||||
describe("SearchClient", function() {
|
describe("SearchClient", /** @this Mocha.Context */ function() {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
let searchClient: SearchClient<Hotel>;
|
let searchClient: SearchClient<Hotel>;
|
||||||
let indexClient: SearchIndexClient;
|
let indexClient: SearchIndexClient;
|
||||||
|
|
||||||
this.timeout(99999);
|
this.timeout(99999);
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
({ searchClient, indexClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
/** @this Mocha.Context */ async function() {
|
||||||
if (!isPlaybackMode()) {
|
({ searchClient, indexClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
||||||
await createIndex(indexClient, TEST_INDEX_NAME);
|
if (!isPlaybackMode()) {
|
||||||
await delay(WAIT_TIME);
|
await createIndex(indexClient, TEST_INDEX_NAME);
|
||||||
await populateIndex(searchClient);
|
await delay(WAIT_TIME);
|
||||||
|
await populateIndex(searchClient);
|
||||||
|
}
|
||||||
|
recorder = record(this, environmentSetup);
|
||||||
|
// create the clients again, but hooked up to the recorder
|
||||||
|
({ searchClient, indexClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
||||||
}
|
}
|
||||||
recorder = record(this, environmentSetup);
|
);
|
||||||
// create the clients again, but hooked up to the recorder
|
|
||||||
({ searchClient, indexClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
/* eslint-disable no-invalid-this */
|
|
||||||
import { isPlaybackMode, record, Recorder, isLiveMode } from "@azure/test-utils-recorder";
|
import { isPlaybackMode, record, Recorder, isLiveMode } from "@azure/test-utils-recorder";
|
||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
import { SearchIndexClient, SynonymMap, SearchIndex } from "../../../src";
|
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";
|
const TEST_INDEX_NAME = isLiveMode() ? createRandomIndexName() : "hotel-live-test3";
|
||||||
|
|
||||||
describe("SearchIndexClient", function() {
|
describe("SearchIndexClient", /** @this Mocha.Context */ function() {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
let indexClient: SearchIndexClient;
|
let indexClient: SearchIndexClient;
|
||||||
|
|
||||||
this.timeout(99999);
|
this.timeout(99999);
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
({ indexClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
/** @this Mocha.Context */ async function() {
|
||||||
if (!isPlaybackMode()) {
|
({ indexClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
||||||
await createSynonymMaps(indexClient);
|
if (!isPlaybackMode()) {
|
||||||
await createSimpleIndex(indexClient, TEST_INDEX_NAME);
|
await createSynonymMaps(indexClient);
|
||||||
await delay(WAIT_TIME);
|
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<Hotel>(TEST_INDEX_NAME));
|
||||||
}
|
}
|
||||||
recorder = record(this, environmentSetup);
|
);
|
||||||
// create the clients again, but hooked up to the recorder
|
|
||||||
({ indexClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
/* eslint-disable no-invalid-this */
|
|
||||||
import { isPlaybackMode, record, Recorder, isLiveMode } from "@azure/test-utils-recorder";
|
import { isPlaybackMode, record, Recorder, isLiveMode } from "@azure/test-utils-recorder";
|
||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
import {
|
import {
|
||||||
|
@ -28,26 +27,28 @@ import { delay } from "@azure/core-http";
|
||||||
|
|
||||||
const TEST_INDEX_NAME = isLiveMode() ? createRandomIndexName() : "hotel-live-test2";
|
const TEST_INDEX_NAME = isLiveMode() ? createRandomIndexName() : "hotel-live-test2";
|
||||||
|
|
||||||
describe("SearchIndexerClient", function() {
|
describe("SearchIndexerClient", /** @this Mocha.Context */ function() {
|
||||||
let recorder: Recorder;
|
let recorder: Recorder;
|
||||||
let indexerClient: SearchIndexerClient;
|
let indexerClient: SearchIndexerClient;
|
||||||
let indexClient: SearchIndexClient;
|
let indexClient: SearchIndexClient;
|
||||||
|
|
||||||
this.timeout(99999);
|
this.timeout(99999);
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
({ indexClient, indexerClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
/** @this Mocha.Context */ async function() {
|
||||||
if (!isPlaybackMode()) {
|
({ indexClient, indexerClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
||||||
await createDataSourceConnections(indexerClient);
|
if (!isPlaybackMode()) {
|
||||||
await createSkillsets(indexerClient);
|
await createDataSourceConnections(indexerClient);
|
||||||
await createIndex(indexClient, TEST_INDEX_NAME);
|
await createSkillsets(indexerClient);
|
||||||
await delay(5000);
|
await createIndex(indexClient, TEST_INDEX_NAME);
|
||||||
await createIndexers(indexerClient, 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<Hotel>(TEST_INDEX_NAME));
|
||||||
}
|
}
|
||||||
recorder = record(this, environmentSetup);
|
);
|
||||||
// create the clients again, but hooked up to the recorder
|
|
||||||
({ indexClient, indexerClient } = createClients<Hotel>(TEST_INDEX_NAME));
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
|
|
|
@ -26,20 +26,21 @@ describe("batch operations", () => {
|
||||||
// which wouldn't match the recorded one. Fallingback to SAS for recorded tests.
|
// which wouldn't match the recorded one. Fallingback to SAS for recorded tests.
|
||||||
const authMode = !isNode || !isLiveMode() ? "SASConnectionString" : "AccountConnectionString";
|
const authMode = !isNode || !isLiveMode() ? "SASConnectionString" : "AccountConnectionString";
|
||||||
|
|
||||||
beforeEach(async function() {
|
beforeEach(
|
||||||
sinon.stub(Uuid, "generateUuid").returns("fakeId");
|
/** @this Mocha.Context */ async function() {
|
||||||
// eslint-disable-next-line no-invalid-this
|
sinon.stub(Uuid, "generateUuid").returns("fakeId");
|
||||||
recorder = record(this, recordedEnvironmentSetup);
|
recorder = record(this, recordedEnvironmentSetup);
|
||||||
client = createTableClient(tableName, authMode);
|
client = createTableClient(tableName, authMode);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!isPlaybackMode()) {
|
if (!isPlaybackMode()) {
|
||||||
await client.create();
|
await client.create();
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
console.warn("Table already exists");
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
console.warn("Table already exists");
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
sinon.restore();
|
sinon.restore();
|
||||||
|
|
|
@ -18,12 +18,13 @@ describe("TableClient", () => {
|
||||||
// which wouldn't match the recorded one. Fallingback to SAS for recorded tests.
|
// which wouldn't match the recorded one. Fallingback to SAS for recorded tests.
|
||||||
const authMode = !isNode || !isLiveMode() ? "SASConnectionString" : "AccountConnectionString";
|
const authMode = !isNode || !isLiveMode() ? "SASConnectionString" : "AccountConnectionString";
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
recorder = record(this, recordedEnvironmentSetup);
|
recorder = record(this, recordedEnvironmentSetup);
|
||||||
|
|
||||||
client = createTableClient(tableName, authMode);
|
client = createTableClient(tableName, authMode);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
if (!isPlaybackMode()) {
|
if (!isPlaybackMode()) {
|
||||||
|
@ -44,25 +45,26 @@ describe("TableClient", () => {
|
||||||
|
|
||||||
describe("listEntities", () => {
|
describe("listEntities", () => {
|
||||||
// Create required entities for testing list operations
|
// Create required entities for testing list operations
|
||||||
before(async function() {
|
before(
|
||||||
if (!isPlaybackMode()) {
|
/** @this Mocha.Context */ async function() {
|
||||||
// eslint-disable-next-line no-invalid-this
|
if (!isPlaybackMode()) {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
await client.createEntity({
|
|
||||||
partitionKey: listPartitionKey,
|
|
||||||
rowKey: "binary1",
|
|
||||||
foo: new Uint8Array([66, 97, 114])
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let i = 0; i < 20; i++) {
|
|
||||||
await client.createEntity({
|
await client.createEntity({
|
||||||
partitionKey: listPartitionKey,
|
partitionKey: listPartitionKey,
|
||||||
rowKey: `${i}`,
|
rowKey: "binary1",
|
||||||
foo: "testEntity"
|
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 StringEntity = { foo: string };
|
||||||
type NumberEntity = { foo: number };
|
type NumberEntity = { foo: number };
|
||||||
type DateEntity = { foo: Date };
|
type DateEntity = { foo: Date };
|
||||||
|
|
|
@ -14,11 +14,12 @@ describe("TableServiceClient", () => {
|
||||||
const suffix = isNode ? "node" : "browser";
|
const suffix = isNode ? "node" : "browser";
|
||||||
const authMode = !isNode || !isLiveMode() ? "SASConnectionString" : "AccountConnectionString";
|
const authMode = !isNode || !isLiveMode() ? "SASConnectionString" : "AccountConnectionString";
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
recorder = record(this, recordedEnvironmentSetup);
|
recorder = record(this, recordedEnvironmentSetup);
|
||||||
client = createTableServiceClient(authMode);
|
client = createTableServiceClient(authMode);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
|
@ -50,33 +51,35 @@ describe("TableServiceClient", () => {
|
||||||
describe("listTables", () => {
|
describe("listTables", () => {
|
||||||
const tableNames: string[] = [];
|
const tableNames: string[] = [];
|
||||||
const expectedTotalItems = 20;
|
const expectedTotalItems = 20;
|
||||||
before(async function() {
|
before(
|
||||||
// Create tables to be listed
|
/** @this Mocha.Context */ async function() {
|
||||||
if (!isPlaybackMode()) {
|
// Create tables to be listed
|
||||||
// eslint-disable-next-line no-invalid-this
|
if (!isPlaybackMode()) {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
for (let i = 0; i < 20; i++) {
|
for (let i = 0; i < 20; i++) {
|
||||||
const tableName = `ListTableTest${suffix}${i}`;
|
const tableName = `ListTableTest${suffix}${i}`;
|
||||||
await client.createTable(tableName);
|
await client.createTable(tableName);
|
||||||
tableNames.push(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);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.warn(`Failed to delete a table during cleanup`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
|
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`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
it("should list all", async () => {
|
it("should list all", async () => {
|
||||||
const tables = client.listTables();
|
const tables = client.listTables();
|
||||||
|
|
|
@ -25,10 +25,9 @@ describe("TablesSharedKeyCredential", () => {
|
||||||
Date.prototype.toUTCString = originalToUTCString;
|
Date.prototype.toUTCString = originalToUTCString;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("It should sign", async function() {
|
it("It should sign", /** @this Mocha.Context */ async function() {
|
||||||
if (!isNode) {
|
if (!isNode) {
|
||||||
// TablesSharedKeyCredential auth is not supported in Browser
|
// TablesSharedKeyCredential auth is not supported in Browser
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
this.skip();
|
this.skip();
|
||||||
}
|
}
|
||||||
const url =
|
const url =
|
||||||
|
|
|
@ -10,13 +10,14 @@ import { ConnectionString } from "../../src/utils/internalModels";
|
||||||
describe("Utility Helpers", () => {
|
describe("Utility Helpers", () => {
|
||||||
describe("extractConnectionStringParts", () => {
|
describe("extractConnectionStringParts", () => {
|
||||||
describe("Account Connection String", () => {
|
describe("Account Connection String", () => {
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
if (!isNode) {
|
/** @this Mocha.Context */ function() {
|
||||||
// Account connection string is not supported for Browsers
|
if (!isNode) {
|
||||||
// eslint-disable-next-line no-invalid-this
|
// Account connection string is not supported for Browsers
|
||||||
this.skip();
|
this.skip();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
it("should handle connection string without TableEndpoint", () => {
|
it("should handle connection string without TableEndpoint", () => {
|
||||||
const validConnectionString =
|
const validConnectionString =
|
||||||
"DefaultEndpointsProtocol=https;AccountName=testaccount;AccountKey=REDACTED;EndpointSuffix=core.windows.net";
|
"DefaultEndpointsProtocol=https;AccountName=testaccount;AccountKey=REDACTED;EndpointSuffix=core.windows.net";
|
||||||
|
|
|
@ -52,35 +52,36 @@ describe("[AAD] ConfigurationClient functional tests", function() {
|
||||||
// NOTE: use of "function" and not ES6 arrow-style functions with the
|
// 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
|
// beforeEach hook is IMPORTANT due to the use of `this` in the function
|
||||||
// body.
|
// body.
|
||||||
beforeEach(function(this: Context) {
|
beforeEach(
|
||||||
// The recorder has some convenience methods, and we need to store a
|
/** @this Mocha.Context */ function(this: Context) {
|
||||||
// reference to it so that we can `stop()` the recorder later in the
|
// The recorder has some convenience methods, and we need to store a
|
||||||
// `afterEach` hook.
|
// reference to it so that we can `stop()` the recorder later in the
|
||||||
// eslint-disable-next-line no-invalid-this
|
// `afterEach` hook.
|
||||||
recorder = record(this, {
|
recorder = record(this, {
|
||||||
// == Recorder Environment Setup == Add the replaceable variables from
|
// == Recorder Environment Setup == Add the replaceable variables from
|
||||||
// above
|
// above
|
||||||
replaceableVariables,
|
replaceableVariables,
|
||||||
|
|
||||||
// We don't use this in the template, but if we had any query parameters
|
// We don't use this in the template, but if we had any query parameters
|
||||||
// we wished to discard, we could add them here
|
// we wished to discard, we could add them here
|
||||||
queryParametersToSkip: [],
|
queryParametersToSkip: [],
|
||||||
|
|
||||||
// Finally, we need to remove the AAD `access_token` from any requests.
|
// Finally, we need to remove the AAD `access_token` from any requests.
|
||||||
// This is very important, as it cannot be removed using environment
|
// This is very important, as it cannot be removed using environment
|
||||||
// variable or query parameter replacement. The
|
// variable or query parameter replacement. The
|
||||||
// `customizationsOnRecordings` field allows us to make arbitrary
|
// `customizationsOnRecordings` field allows us to make arbitrary
|
||||||
// replacements within recordings.
|
// replacements within recordings.
|
||||||
customizationsOnRecordings: [
|
customizationsOnRecordings: [
|
||||||
(recording: any): any =>
|
(recording: any): any =>
|
||||||
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`)
|
recording.replace(/"access_token":"[^"]*"/g, `"access_token":"access_token"`)
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
// We'll be able to refer to the instantiated `client` in tests, since we
|
// We'll be able to refer to the instantiated `client` in tests, since we
|
||||||
// initialize it before each test
|
// initialize it before each test
|
||||||
client = createConfigurationClient();
|
client = createConfigurationClient();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// After each test, we need to stop the recording.
|
// After each test, we need to stop the recording.
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||||
|
"extends": ["../../../tsdoc.json"]
|
||||||
|
}
|
|
@ -41,7 +41,9 @@ versionsToTest(serviceVersions, {}, (serviceVersion, onVersions) => {
|
||||||
console.log(`creating test client for service version ${serviceVersion}`);
|
console.log(`creating test client for service version ${serviceVersion}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async function() { /** empty */});
|
afterEach(async function() {
|
||||||
|
/** empty */
|
||||||
|
});
|
||||||
|
|
||||||
it("test case 2", function() {
|
it("test case 2", function() {
|
||||||
if (serviceVersion === "7.0") {
|
if (serviceVersion === "7.0") {
|
||||||
|
@ -50,7 +52,9 @@ versionsToTest(serviceVersions, {}, (serviceVersion, onVersions) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("nested test suite 3a", function() {
|
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() {
|
onVersions(["7.0"]).describe("nested test suite 3b", function() {
|
||||||
|
|
|
@ -19,28 +19,29 @@ const testDataEn = [
|
||||||
"I didn't like the last book I read at all."
|
"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 recorder: Recorder;
|
||||||
let client: TextAnalyticsClient;
|
let client: TextAnalyticsClient;
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
const CLITimeout = this.timeout();
|
const CLITimeout = this.timeout();
|
||||||
const fastTimeout = 10000;
|
const fastTimeout = 10000;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
recorder = createRecorder(this);
|
recorder = createRecorder(this);
|
||||||
client = createClient("APIKey");
|
client = createClient("APIKey");
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("fast tests", function() {
|
describe("fast tests", function() {
|
||||||
before(function() {
|
before(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
this.timeout(fastTimeout);
|
this.timeout(fastTimeout);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
it("#analyzeSentiment", async function() {
|
it("#analyzeSentiment", async function() {
|
||||||
const results = await client.analyzeSentiment(testDataEn);
|
const results = await client.analyzeSentiment(testDataEn);
|
||||||
|
@ -88,10 +89,11 @@ describe("[API Key] TextAnalyticsClient", function() {
|
||||||
describe("LROs", function() {
|
describe("LROs", function() {
|
||||||
const pollingInterval = isPlaybackMode() ? 0 : 2000;
|
const pollingInterval = isPlaybackMode() ? 0 : 2000;
|
||||||
|
|
||||||
before(function() {
|
before(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
this.timeout(isPlaybackMode() ? fastTimeout : CLITimeout);
|
this.timeout(isPlaybackMode() ? fastTimeout : CLITimeout);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
describe("#health", function() {
|
describe("#health", function() {
|
||||||
it("input strings", async function() {
|
it("input strings", async function() {
|
||||||
|
|
|
@ -35,35 +35,36 @@ const testDataEs = [
|
||||||
"Los caminos que llevan hasta Monte Rainier son espectaculares y hermosos.",
|
"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."
|
"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 recorder: Recorder;
|
||||||
let client: TextAnalyticsClient;
|
let client: TextAnalyticsClient;
|
||||||
// eslint-disable-next-line no-invalid-this
|
|
||||||
const CLITimeout = this.timeout();
|
const CLITimeout = this.timeout();
|
||||||
const fastTimeout = 10000;
|
const fastTimeout = 10000;
|
||||||
|
|
||||||
let getId: () => string;
|
let getId: () => string;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
recorder = createRecorder(this);
|
recorder = createRecorder(this);
|
||||||
client = createClient("AAD");
|
client = createClient("AAD");
|
||||||
let nextId = 0;
|
let nextId = 0;
|
||||||
getId = function() {
|
getId = function() {
|
||||||
nextId += 1;
|
nextId += 1;
|
||||||
return nextId.toString();
|
return nextId.toString();
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
afterEach(async function() {
|
afterEach(async function() {
|
||||||
await recorder.stop();
|
await recorder.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("fast tests", function() {
|
describe("fast tests", function() {
|
||||||
before(function() {
|
before(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
this.timeout(fastTimeout);
|
this.timeout(fastTimeout);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
describe("#analyzeSentiment", function() {
|
describe("#analyzeSentiment", function() {
|
||||||
it("client throws on empty list", async function() {
|
it("client throws on empty list", async function() {
|
||||||
|
@ -929,10 +930,11 @@ describe("[AAD] TextAnalyticsClient", function() {
|
||||||
describe("LROs", function() {
|
describe("LROs", function() {
|
||||||
const pollingInterval = isPlaybackMode() ? 0 : 2000;
|
const pollingInterval = isPlaybackMode() ? 0 : 2000;
|
||||||
|
|
||||||
before(function() {
|
before(
|
||||||
// eslint-disable-next-line no-invalid-this
|
/** @this Mocha.Context */ function() {
|
||||||
this.timeout(isPlaybackMode() ? fastTimeout : CLITimeout);
|
this.timeout(isPlaybackMode() ? fastTimeout : CLITimeout);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
describe("#analyze", function() {
|
describe("#analyze", function() {
|
||||||
it("single entity recognition action", async function() {
|
it("single entity recognition action", async function() {
|
||||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче