Skip to content

Commit

Permalink
Removed redundant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbie-Microsoft committed May 10, 2024
1 parent aa22e65 commit 9b150bc
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "../../test_kit/StringConstants";

import {
ManagedIdentityTestUtils,
userAssignedClientIdConfig,
managedIdentityRequestParams,
systemAssignedConfig,
Expand Down Expand Up @@ -47,8 +46,6 @@ describe("Acquires a token successfully via an App Service Managed Identity", ()
});

test("acquires a User Assigned Client Id token", async () => {
expect(ManagedIdentityTestUtils.isAppService()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication(userAssignedClientIdConfig);
expect(managedIdentityApplication.getManagedIdentitySource()).toBe(
Expand Down Expand Up @@ -77,8 +74,6 @@ describe("Acquires a token successfully via an App Service Managed Identity", ()
});

test("acquires a token", async () => {
expect(ManagedIdentityTestUtils.isAppService()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken(
managedIdentityRequestParams
Expand All @@ -91,8 +86,6 @@ describe("Acquires a token successfully via an App Service Managed Identity", ()
});

test("returns an already acquired token from the cache", async () => {
expect(ManagedIdentityTestUtils.isAppService()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken({
resource: MANAGED_IDENTITY_RESOURCE,
Expand Down
15 changes: 0 additions & 15 deletions lib/msal-node/test/client/ManagedIdentitySources/AzureArc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from "../../test_kit/StringConstants";

import {
ManagedIdentityTestUtils,
ManagedIdentityNetworkClient,
ManagedIdentityNetworkErrorClient,
systemAssignedConfig,
Expand Down Expand Up @@ -73,8 +72,6 @@ describe("Acquires a token successfully via an Azure Arc Managed Identity", () =
});

test("acquires a token", async () => {
expect(ManagedIdentityTestUtils.isAzureArc()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken(
managedIdentityRequestParams
Expand All @@ -87,8 +84,6 @@ describe("Acquires a token successfully via an Azure Arc Managed Identity", () =
});

test("returns an already acquired token from the cache", async () => {
expect(ManagedIdentityTestUtils.isAzureArc()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken({
resource: MANAGED_IDENTITY_RESOURCE,
Expand All @@ -110,8 +105,6 @@ describe("Acquires a token successfully via an Azure Arc Managed Identity", () =
});

test("attempts to acquire a token, a 401 and www-authenticate header are returned form the azure arc managed identity, then retries the network request with the www-authenticate header", async () => {
expect(ManagedIdentityTestUtils.isAzureArc()).toBe(true);

const networkClient: ManagedIdentityNetworkClient =
new ManagedIdentityNetworkClient(MANAGED_IDENTITY_RESOURCE_ID);

Expand Down Expand Up @@ -179,8 +172,6 @@ describe("Acquires a token successfully via an Azure Arc Managed Identity", () =

describe("Errors", () => {
test("throws an error when a user assigned managed identity is used", async () => {
expect(ManagedIdentityTestUtils.isAzureArc()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication(userAssignedClientIdConfig);
expect(managedIdentityApplication.getManagedIdentitySource()).toBe(
Expand All @@ -199,8 +190,6 @@ describe("Acquires a token successfully via an Azure Arc Managed Identity", () =
});

test("throws an error when the www-authenticate header is missing", async () => {
expect(ManagedIdentityTestUtils.isAzureArc()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication({
system: {
Expand All @@ -227,8 +216,6 @@ describe("Acquires a token successfully via an Azure Arc Managed Identity", () =
});

test("throws an error when the www-authenticate header is in an unsupported format", async () => {
expect(ManagedIdentityTestUtils.isAzureArc()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication({
system: {
Expand All @@ -254,8 +241,6 @@ describe("Acquires a token successfully via an Azure Arc Managed Identity", () =
});

test("throws an error when the secret file cannot be found", async () => {
expect(ManagedIdentityTestUtils.isAzureArc()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication({
system: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from "../../test_kit/StringConstants";

import {
ManagedIdentityTestUtils,
userAssignedClientIdConfig,
managedIdentityRequestParams,
systemAssignedConfig,
Expand Down Expand Up @@ -56,8 +55,6 @@ describe("Acquires a token successfully via an App Service Managed Identity", ()
});

test("acquires a token", async () => {
expect(ManagedIdentityTestUtils.isCloudShell()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken(
managedIdentityRequestParams
Expand All @@ -70,8 +67,6 @@ describe("Acquires a token successfully via an App Service Managed Identity", ()
});

test("returns an already acquired token from the cache", async () => {
expect(ManagedIdentityTestUtils.isCloudShell()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken({
resource: MANAGED_IDENTITY_RESOURCE,
Expand All @@ -95,8 +90,6 @@ describe("Acquires a token successfully via an App Service Managed Identity", ()

describe("Errors", () => {
test("throws an error when a user assigned managed identity is used", async () => {
expect(ManagedIdentityTestUtils.isCloudShell()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication(userAssignedClientIdConfig);
expect(managedIdentityApplication.getManagedIdentitySource()).toBe(
Expand Down
43 changes: 0 additions & 43 deletions lib/msal-node/test/client/ManagedIdentitySources/Imds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from "../../test_kit/StringConstants";

import {
ManagedIdentityTestUtils,
ManagedIdentityNetworkClient,
ManagedIdentityNetworkErrorClient,
networkClient,
Expand Down Expand Up @@ -86,8 +85,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {

describe("User Assigned", () => {
test("acquires a User Assigned Client Id token", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication(userAssignedClientIdConfig);
expect(managedIdentityApplication.getManagedIdentitySource()).toBe(
Expand All @@ -105,8 +102,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("acquires a User Assigned Object Id token", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication(userAssignedObjectIdConfig);
expect(managedIdentityApplication.getManagedIdentitySource()).toBe(
Expand All @@ -124,8 +119,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("acquires a User Assigned Resource Id token", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication(userAssignedResourceIdConfig);
expect(managedIdentityApplication.getManagedIdentitySource()).toBe(
Expand Down Expand Up @@ -155,8 +148,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("acquires a token", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken(
managedIdentityRequestParams
Expand All @@ -169,8 +160,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("returns an already acquired token from the cache", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken({
resource: MANAGED_IDENTITY_RESOURCE,
Expand Down Expand Up @@ -205,8 +194,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("returns a 500 error response from the network request, just the first time", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const sendGetRequestAsyncSpy: jest.SpyInstance = jest
.spyOn(networkClient, <any>"sendGetRequestAsync")
// override the networkClient's sendGetRequestAsync method to return a 500.
Expand All @@ -230,8 +217,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("returns a 500 error response from the network request permanently", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const sendGetRequestAsyncSpy: jest.SpyInstance = jest
.spyOn(networkClient, <any>"sendGetRequestAsync")
// permanently override the networkClient's sendGetRequestAsync method to return a 500
Expand Down Expand Up @@ -269,8 +254,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("returns a 500 error response from the network request, just the first time, with no retry-after header", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const sendGetRequestAsyncSpy: jest.SpyInstance = jest
.spyOn(networkClient, <any>"sendGetRequestAsync")
// override the networkClient's sendGetRequestAsync method to return a 500.
Expand Down Expand Up @@ -304,8 +287,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("returns a 500 error response from the network request, just the first time, with a retry-after header of 3 seconds", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const headers: Record<string, string> = {
"Retry-After": "3", // 3 seconds
};
Expand Down Expand Up @@ -344,8 +325,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("returns a 500 error response from the network request, just the first time, with a retry-after header of 3 seconds (extrapolated from an http-date)", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

var retryAfterHttpDate = new Date();
retryAfterHttpDate.setSeconds(
retryAfterHttpDate.getSeconds() + 4 // 4 seconds. An extra second has been added to account for this date operation
Expand Down Expand Up @@ -388,8 +367,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("returns a 500 error response from the network request permanently", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const sendGetRequestAsyncSpy: jest.SpyInstance = jest
.spyOn(networkClient, <any>"sendGetRequestAsync")
// permanently override the networkClient's sendGetRequestAsync method to return a 500
Expand All @@ -415,8 +392,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("makes three acquireToken calls on the same managed identity application (which returns a 500 error response from the network request permanently) to ensure that retry policy lifetime is per request", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const sendGetRequestAsyncSpyApp: jest.SpyInstance = jest
.spyOn(networkClient, <any>"sendGetRequestAsync")
// permanently override the networkClient's sendGetRequestAsync method to return a 500
Expand Down Expand Up @@ -452,8 +427,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
}, 15000); // triple the timeout value for this test because there are 3 acquireToken calls (3 x 1 second in between retries)

test("ensures that a retry does not happen when the http status code from a failed network response is not included in the retry policy", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const sendGetRequestAsyncSpyApp: jest.SpyInstance = jest
.spyOn(networkClient, <any>"sendGetRequestAsync")
// permanently override the networkClient's sendGetRequestAsync method to return a 400
Expand All @@ -476,8 +449,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("ensures that a retry does not happen when the http status code from a failed network response is included in the retry policy, but the retry policy has been disabled", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const managedIdentityApplicationNoRetry: ManagedIdentityApplication =
new ManagedIdentityApplication({
system: {
Expand Down Expand Up @@ -526,8 +497,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("acquires a token from the network and then the same token from the cache, then acquires a different token for another scope", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

let networkManagedIdentityResult: AuthenticationResult =
await systemAssignedManagedIdentityApplication.acquireToken({
resource: MANAGED_IDENTITY_RESOURCE,
Expand Down Expand Up @@ -560,8 +529,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("ignores a cached token when forceRefresh is set to true", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

let networkManagedIdentityResult: AuthenticationResult =
await systemAssignedManagedIdentityApplication.acquireToken({
resource: MANAGED_IDENTITY_RESOURCE,
Expand Down Expand Up @@ -594,8 +561,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("proactively refreshes a token in the background when its refresh_in value is expired.", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

let networkManagedIdentityResult: AuthenticationResult =
await systemAssignedManagedIdentityApplication.acquireToken({
resource: MANAGED_IDENTITY_RESOURCE,
Expand Down Expand Up @@ -672,8 +637,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
}, 10000); // double the timeout value for this test because it waits two seconds in between the acquireToken call and the cache lookup

test("requests three tokens with two different resources while switching between user and system assigned, then requests them again to verify they are retrieved from the cache, then verifies that their cache keys are correct", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

// the imported systemAssignedManagedIdentityApplication is the default System Assigned Managed Identity Application.
// for reference, in this case it is equivalent to systemAssignedManagedIdentityApplicationResource1

Expand Down Expand Up @@ -822,8 +785,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {

describe("Errors", () => {
test("throws an error when an invalid resource is provided", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const systemAssignedManagedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication(systemAssignedConfig);
expect(
Expand All @@ -842,8 +803,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("throws an error when more than one managed identity type is provided", () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const badUserAssignedClientIdConfig: ManagedIdentityConfiguration =
{
system: {
Expand All @@ -865,8 +824,6 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => {
});

test("managed identity token response contains an error message and correlation id when an error is returned from the managed identity", async () => {
expect(ManagedIdentityTestUtils.isIMDS()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication({
system: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "../../test_kit/StringConstants";

import {
ManagedIdentityTestUtils,
userAssignedClientIdConfig,
managedIdentityRequestParams,
systemAssignedConfig,
Expand Down Expand Up @@ -53,8 +52,6 @@ describe("Acquires a token successfully via an App Service Managed Identity", ()
});

test("acquires a User Assigned Client Id token", async () => {
expect(ManagedIdentityTestUtils.isServiceFabric()).toBe(true);

const managedIdentityApplication: ManagedIdentityApplication =
new ManagedIdentityApplication(userAssignedClientIdConfig);
expect(managedIdentityApplication.getManagedIdentitySource()).toBe(
Expand Down Expand Up @@ -83,8 +80,6 @@ describe("Acquires a token successfully via an App Service Managed Identity", ()
});

test("acquires a token", async () => {
expect(ManagedIdentityTestUtils.isServiceFabric()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken(
managedIdentityRequestParams
Expand All @@ -97,8 +92,6 @@ describe("Acquires a token successfully via an App Service Managed Identity", ()
});

test("returns an already acquired token from the cache", async () => {
expect(ManagedIdentityTestUtils.isServiceFabric()).toBe(true);

const networkManagedIdentityResult: AuthenticationResult =
await managedIdentityApplication.acquireToken({
resource: MANAGED_IDENTITY_RESOURCE,
Expand Down
Loading

0 comments on commit 9b150bc

Please sign in to comment.