Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe("ClientCertificateCredential (internal)", () => {
await credential.getToken(scope);
const result = await persistence?.load();
const parsedResult = JSON.parse(result!);
assert.ok(parsedResult.AccessToken);
assert.isDefined(parsedResult.AccessToken);
});

it("Authenticates silently with tokenCachePersistenceOptions", async (ctx) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("ClientSecretCredential (internal)", () => {
await credential.getToken(scope);
const result = await persistence?.load();
const parsedResult = JSON.parse(result!);
assert.ok(parsedResult.AccessToken);
assert.isDefined(parsedResult.AccessToken);
});

// TODO:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe("DeviceCodeCredential (internal)", () => {
await credential.getToken(scope);
const result = await persistence?.load();
const parsedResult = JSON.parse(result!);
assert.ok(parsedResult.AccessToken);
assert.isDefined(parsedResult.AccessToken);
});

it("Authenticates silently with tokenCachePersistenceOptions", async (ctx) => {
Expand Down Expand Up @@ -100,7 +100,7 @@ describe("DeviceCodeCredential (internal)", () => {
// The cache should have a token a this point
const result = await persistence?.load();
const parsedResult = JSON.parse(result!);
assert.ok(parsedResult.AccessToken);
assert.isDefined(parsedResult.AccessToken);

await credential.getToken(scope);
expect(getTokenSilentSpy).toHaveBeenCalledTimes(2);
Expand Down Expand Up @@ -135,7 +135,7 @@ describe("DeviceCodeCredential (internal)", () => {
);

const account = await credential.authenticate(scope);
assert.ok(account);
assert.isDefined(account);
expect(getTokenSilentSpy).toHaveBeenCalledTimes(1);
expect(doGetTokenSpy).toHaveBeenCalledTimes(1);

Expand All @@ -151,11 +151,11 @@ describe("DeviceCodeCredential (internal)", () => {
// The cache should have a token a this point
const result = await persistence?.load();
const parsedResult = JSON.parse(result!);
assert.ok(parsedResult.AccessToken);
assert.isDefined(parsedResult.AccessToken);

const token = await credential2.getToken(scope);
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
assert.isDefined(token?.token);
assert.isTrue(token?.expiresOnTimestamp! > Date.now());
expect(getTokenSilentSpy).toHaveBeenCalledTimes(2);

// Resolved with issue - https://github.com/Azure/azure-sdk-for-js/issues/24349
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("UsernamePasswordCredential (internal)", () => {
await credential.getToken(scope);
const result = await persistence?.load();
const parsedResult = JSON.parse(result!);
assert.ok(parsedResult.AccessToken);
assert.isDefined(parsedResult.AccessToken);
});

it("Authenticates silently with tokenCachePersistenceOptions", async (ctx) => {
Expand Down Expand Up @@ -96,7 +96,7 @@ describe("UsernamePasswordCredential (internal)", () => {
// The cache should have a token a this point
const result = await persistence?.load();
const parsedResult = JSON.parse(result!);
assert.ok(parsedResult.AccessToken);
assert.isDefined(parsedResult.AccessToken);

await credential.getToken(scope);
expect(getTokenSilentSpy).toHaveBeenCalledTimes(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe.skip("VisualStudioCodeCredential", () => {

const token = await cred.getToken(scope);

assert.ok(token.expiresOnTimestamp);
assert.ok(token.token);
assert.isDefined(token.expiresOnTimestamp);
assert.isDefined(token.token);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe("AzureCliCredential (internal)", function () {
error = e;
}

assert.ok(error);
assert.isDefined(error);
assert.equal(error?.name, "CredentialUnavailableError");
assert.equal(
error?.message,
Expand All @@ -203,7 +203,7 @@ describe("AzureCliCredential (internal)", function () {
error = e;
}

assert.ok(error);
assert.isDefined(error);
assert.equal(error?.name, "CredentialUnavailableError");
assert.equal(
error?.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe("AzureDeveloperCliCredential (internal)", function () {

// Verify the command includes --no-prompt to prevent hanging on debug prompts
const command = azdCommands[0];
assert.ok(command.includes("--no-prompt"), "Command should include --no-prompt flag");
assert.isTrue(command.includes("--no-prompt"), "Command should include --no-prompt flag");
assert.deepEqual(azdCommands, [
"azd auth token --output json --no-prompt --scope https://service/.default",
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("AzurePowerShellCredential", function () {
error = e;
}

assert.ok(error);
assert.isDefined(error);
assert.equal(error?.name, "CredentialUnavailableError");
assert.equal(error?.message, powerShellPublicErrorMessages.login);
});
Expand All @@ -78,7 +78,7 @@ describe("AzurePowerShellCredential", function () {
error = e;
}

assert.ok(error);
assert.isDefined(error);
assert.equal(error?.name, "CredentialUnavailableError");
assert.equal(error?.message, powerShellPublicErrorMessages.installed);
});
Expand All @@ -95,7 +95,7 @@ describe("AzurePowerShellCredential", function () {
error = e;
}

assert.ok(error);
assert.isDefined(error);
assert.equal(error?.name, "CredentialUnavailableError");
assert.equal(
error?.message,
Expand All @@ -119,7 +119,7 @@ describe("AzurePowerShellCredential", function () {
error = e;
}

assert.ok(error);
assert.isDefined(error);
assert.equal(error?.name, "CredentialUnavailableError");
assert.equal(
error?.message,
Expand Down Expand Up @@ -206,7 +206,7 @@ describe("AzurePowerShellCredential", function () {
error = e;
}

assert.ok(error);
assert.isDefined(error);
assert.equal(error?.name, "CredentialUnavailableError");
assert.equal(
error?.message,
Expand All @@ -228,7 +228,7 @@ describe("AzurePowerShellCredential", function () {
error = e;
}

assert.ok(error);
assert.isDefined(error);
assert.equal(error?.name, "CredentialUnavailableError");
assert.equal(
error?.message,
Expand All @@ -254,7 +254,7 @@ describe("AzurePowerShellCredential", function () {
error = e;
}

assert.ok(error);
assert.isDefined(error);
assert.equal(error?.name, "CredentialUnavailableError");
assert.equal(
error?.message,
Expand Down Expand Up @@ -307,8 +307,8 @@ describe("AzurePowerShellCredential", function () {
it.skip("authenticates without mocks", async function () {
const credential = new AzurePowerShellCredential();
const token = await credential.getToken(scope);
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp!);
assert.isDefined(token?.token);
assert.isDefined(token?.expiresOnTimestamp!);
});

for (const tenantId of [
Expand Down
12 changes: 6 additions & 6 deletions sdk/identity/identity/test/internal/node/caeARM.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ async function challengeFlow(

// First, we retrieve a graph token valid with access to the management service.
const managementToken = await credential.getToken(managementScope);
assert.ok(managementToken?.token);
assert.ok(managementToken?.expiresOnTimestamp! > Date.now());
assert.isDefined(managementToken?.token);
assert.isTrue(managementToken?.expiresOnTimestamp! > Date.now());
resultingAccessTokens.push(managementToken!);

const client = new IdentityClient(recorder.configureClientOptions({}));
Expand All @@ -57,8 +57,8 @@ async function challengeFlow(

// Then, we retrieve a graph token valid to revoke the active sessions.
const graphToken = await credential.getToken(graphScope);
assert.ok(graphToken?.token);
assert.ok(graphToken?.expiresOnTimestamp! > Date.now());
assert.isDefined(graphToken?.token);
assert.isTrue(graphToken?.expiresOnTimestamp! > Date.now());

const subscriptionsRequest2 = await client.sendPostRequestAsync(revokeUrl, {
headers: {
Expand Down Expand Up @@ -123,8 +123,8 @@ async function challengeFlow(
// Getting a new token at this point should return a token different from the initially obtained.
// Recordings help us verify that the internal flow indeed happened.
const finalAccessToken = await credential.getToken(managementScope);
assert.ok(finalAccessToken?.token);
assert.ok(finalAccessToken?.expiresOnTimestamp! > Date.now());
assert.isDefined(finalAccessToken?.token);
assert.isTrue(finalAccessToken?.expiresOnTimestamp! > Date.now());
resultingAccessTokens.push(finalAccessToken!);

return resultingAccessTokens;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe("ClientCertificateCredential (internal)", function () {
} catch (e: any) {
error = e;
}
assert.ok(error);
assert.isDefined(error);
assert.equal(
(error as Error).message,
"ClientCertificateCredential: To avoid unexpected behaviors, providing both the contents of a PEM certificate and the path to a PEM certificate is forbidden. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.",
Expand All @@ -113,7 +113,7 @@ describe("ClientCertificateCredential (internal)", function () {
error = _error;
}

assert.ok(error);
assert.isDefined(error);
assert.deepEqual(error?.message, `ENOENT: no such file or directory, open '${fullPath}'`);
});

Expand All @@ -129,7 +129,7 @@ describe("ClientCertificateCredential (internal)", function () {
error = _error;
}

assert.ok(error);
assert.isDefined(error);
assert.deepEqual(
error?.message,
`The file at the specified path does not contain a PEM-encoded certificate.`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ describe("ClientSecretCredential (internal)", function () {
const spy = vi.spyOn(process.stderr, "write");

const token = await credential.getToken(scope);
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
assert.isDefined(token?.token);
assert.isTrue(token?.expiresOnTimestamp! > Date.now());
const expectedCall = spy.mock.calls.find((x) =>
(x[0] as any as string).match(/Authenticated account/),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ describe("UsernamePasswordCredential (internal)", function () {
const spy = vi.spyOn(process.stderr, "write");

const token = await credential.getToken(scope);
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
assert.isDefined(token?.token);
assert.isTrue(token?.expiresOnTimestamp! > Date.now());
const expectedArgument = spy.mock.calls[spy.mock.calls.length - 2][0];
expect(expectedArgument).toBeDefined();
const expectedMessage = `azure:identity:info [Authenticated account] Client ID: ${clientId}. Tenant ID: ${tenantId}. User Principal Name: HIDDEN. Object ID (user): HIDDEN`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ describe("WorkloadIdentityCredential", function () {
vi.stubEnv("AZURE_TENANT_ID", tenantId);
const credential = new ManagedIdentityCredential("dummy-clientId");
const token = await credential.getToken(scope);
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
assert.isDefined(token?.token);
assert.isTrue(token?.expiresOnTimestamp! > Date.now());
});

it("authenticates with DefaultAzure Credential", async function () {
Expand Down Expand Up @@ -137,6 +137,6 @@ function validateWorkloadIdentityCredential(
: undefined;
assert.equal(actualFederatedTokenFilePath, expectedFederatedTokenFilePath);
assert.equal(actualTenantId, expectedTenantId);
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
assert.isDefined(token?.token);
assert.isTrue(token?.expiresOnTimestamp! > Date.now());
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ describe("AuthorityValidation", function () {
);

const token = await credential.getToken(scope);
assert.ok(token?.token);
assert.isDefined(token?.token);
assert.isNotNaN(token?.expiresOnTimestamp);
assert.isNotNull(token?.expiresOnTimestamp);
assert.ok(token?.expiresOnTimestamp > Date.now());
assert.isTrue(token?.expiresOnTimestamp > Date.now());
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe("AzurePipelinesCredential", function () {
systemAccessToken,
);
const token = await credential.getToken(scope);
assert.ok(token?.token);
assert.isDefined(token?.token);
assert.isDefined(token?.expiresOnTimestamp);
if (token?.expiresOnTimestamp) assert.ok(token?.expiresOnTimestamp > Date.now());
if (token?.expiresOnTimestamp) assert.isTrue(token?.expiresOnTimestamp > Date.now());
});

it("fails with invalid service connection", async function (ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ describe("ClientCertificateCredential", function () {
);

const token = await credential.getToken(scope);
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
assert.isDefined(token?.token);
assert.isTrue(token?.expiresOnTimestamp! > Date.now());
});

it("authenticates with a PEM certificate string directly", async function () {
Expand All @@ -66,8 +66,8 @@ describe("ClientCertificateCredential", function () {
);

const token = await credential.getToken(scope);
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
assert.isDefined(token?.token);
assert.isTrue(token?.expiresOnTimestamp! > Date.now());
});

it("allows cancelling the authentication", async function (ctx) {
Expand Down Expand Up @@ -106,7 +106,7 @@ describe("ClientCertificateCredential", function () {
error = e;
}
assert.equal(error?.name, "CredentialUnavailableError");
assert.ok(error?.message.includes("endpoints_resolution_error"));
assert.isTrue(error?.message.includes("endpoints_resolution_error"));
});

it("supports tracing", async function (ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe("ClientSecretCredential", function () {
);

const token = await credential.getToken(scope);
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
assert.isDefined(token?.token);
assert.isTrue(token?.expiresOnTimestamp! > Date.now());
});

it("authenticates when cae enabled", async function () {
Expand All @@ -50,8 +50,8 @@ describe("ClientSecretCredential", function () {
);

const token = await credential.getToken(scope, { enableCae: true });
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
assert.isDefined(token?.token);
assert.isTrue(token?.expiresOnTimestamp! > Date.now());
});

it("allows cancelling the authentication", async function () {
Expand Down Expand Up @@ -79,7 +79,7 @@ describe("ClientSecretCredential", function () {
error = e;
}
assert.equal(error?.name, "CredentialUnavailableError");
assert.ok(error?.message.includes("endpoints_resolution_error"));
assert.isTrue(error?.message.includes("endpoints_resolution_error"));
});

it("supports tracing", async () => {
Expand Down
Loading
Loading