Skip to content

Commit

Permalink
MSAL-Node Tests: Fixed file extensions on all imports & added MS lice…
Browse files Browse the repository at this point in the history
…nse to all files (#7454)

Addressed tech debt in the msal-node tests.

1. Added ".js" to all file names in imports
2. Added the MS license at the top of all files
  • Loading branch information
Robbie-Microsoft authored Dec 21, 2024
1 parent c837638 commit 958da50
Show file tree
Hide file tree
Showing 29 changed files with 204 additions and 109 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Fixed file extentions on imports. Added MS license to all files. (#7454)",
"packageName": "@azure/msal-node",
"email": "rginsburg@microsoft.com",
"dependentChangeType": "none"
}
13 changes: 9 additions & 4 deletions lib/msal-node/test/cache/Storage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import {
LogLevel,
Logger,
Expand All @@ -12,15 +17,15 @@ import {
import {
JsonCache,
InMemoryCache,
} from "./../../src/cache/serializer/SerializerTypes";
import { Deserializer } from "./../../src/cache/serializer/Deserializer";
import { NodeStorage } from "../../src/cache/NodeStorage";
} from "./../../src/cache/serializer/SerializerTypes.js";
import { Deserializer } from "./../../src/cache/serializer/Deserializer.js";
import { NodeStorage } from "../../src/cache/NodeStorage.js";
import { version, name } from "../../package.json";
import {
DEFAULT_CRYPTO_IMPLEMENTATION,
DEFAULT_OPENID_CONFIG_RESPONSE,
TEST_CONSTANTS,
} from "../utils/TestConstants";
} from "../utils/TestConstants.js";

const cacheJson = require("./serializer/cache.json");
const clientId = TEST_CONSTANTS.CLIENT_ID;
Expand Down
17 changes: 11 additions & 6 deletions lib/msal-node/test/cache/TokenCache.spec.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import {
LogLevel,
Logger,
TokenCacheContext,
ICachePlugin,
buildStaticAuthorityOptions,
} from "@azure/msal-common";
import { NodeStorage } from "../../src/cache/NodeStorage";
import { TokenCache } from "../../src/cache/TokenCache";
import { NodeStorage } from "../../src/cache/NodeStorage.js";
import { TokenCache } from "../../src/cache/TokenCache.js";
import { existsSync, watch, promises, FSWatcher } from "fs";
import { version, name } from "../../package.json";
import {
DEFAULT_CRYPTO_IMPLEMENTATION,
ID_TOKEN_CLAIMS,
} from "../utils/TestConstants";
import { Deserializer } from "../../src/cache/serializer/Deserializer";
import { JsonCache } from "../../src";
import { MSALCommonModule } from "../utils/MockUtils";
} from "../utils/TestConstants.js";
import { Deserializer } from "../../src/cache/serializer/Deserializer.js";
import { JsonCache } from "../../src/index.js";
import { MSALCommonModule } from "../utils/MockUtils.js";

const msalCommon: MSALCommonModule = jest.requireActual(
"@azure/msal-common/node"
Expand Down
5 changes: 5 additions & 0 deletions lib/msal-node/test/cache/cacheConstants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import {
AccessTokenEntity,
IdTokenEntity,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import { DistributedCachePlugin } from "../../../src/cache/distributed/DistributedCachePlugin.js";
import {
AccountEntity,
Expand Down
11 changes: 8 additions & 3 deletions lib/msal-node/test/cache/serializer/Deserializer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import {
JsonCache,
InMemoryCache,
} from "../../../src/cache/serializer/SerializerTypes";
import { Deserializer } from "../../../src/cache/serializer/Deserializer";
import { MockCache } from "../cacheConstants";
} from "../../../src/cache/serializer/SerializerTypes.js";
import { Deserializer } from "../../../src/cache/serializer/Deserializer.js";
import { MockCache } from "../cacheConstants.js";

const cacheJson = require("./cache.json");

Expand Down
13 changes: 9 additions & 4 deletions lib/msal-node/test/cache/serializer/Serializer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import {
JsonCache,
InMemoryCache,
} from "../../../src/cache/serializer/SerializerTypes";
import { Serializer } from "../../../src/cache/serializer/Serializer";
import { Deserializer } from "../../../src/cache/serializer/Deserializer";
import { MockCache } from "../cacheConstants";
} from "../../../src/cache/serializer/SerializerTypes.js";
import { Serializer } from "../../../src/cache/serializer/Serializer.js";
import { Deserializer } from "../../../src/cache/serializer/Deserializer.js";
import { MockCache } from "../cacheConstants.js";

const cachedJson = require("./cache.json");

Expand Down
17 changes: 11 additions & 6 deletions lib/msal-node/test/client/ClientAssertion.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { ClientAssertion } from "../../src/client/ClientAssertion";
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import { ClientAssertion } from "../../src/client/ClientAssertion.js";
import {
DEFAULT_OPENID_CONFIG_RESPONSE,
TEST_CONSTANTS,
} from "../utils/TestConstants";
import { CryptoProvider } from "../../src/crypto/CryptoProvider";
import { EncodingUtils } from "../../src/utils/EncodingUtils";
import { JwtConstants } from "../../src/utils/Constants";
import { getClientAssertionCallback } from "./ClientTestUtils";
} from "../utils/TestConstants.js";
import { CryptoProvider } from "../../src/crypto/CryptoProvider.js";
import { EncodingUtils } from "../../src/utils/EncodingUtils.js";
import { JwtConstants } from "../../src/utils/Constants.js";
import { getClientAssertionCallback } from "./ClientTestUtils.js";
import { getClientAssertion } from "@azure/msal-common";
import jwt from "jsonwebtoken";

Expand Down
11 changes: 7 additions & 4 deletions lib/msal-node/test/client/ClientCredentialClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import {
CacheHelpers,
GrantType,
} from "@azure/msal-common";
import { ClientCredentialClient, UsernamePasswordClient } from "../../src";
import {
ClientCredentialClient,
UsernamePasswordClient,
} from "../../src/index.js";
import {
AUTHENTICATION_RESULT_DEFAULT_SCOPES,
CAE_CONSTANTS,
Expand All @@ -33,14 +36,14 @@ import {
DSTS_OPENID_CONFIG_RESPONSE,
TEST_CONFIG,
TEST_TOKENS,
} from "../test_kit/StringConstants";
} from "../test_kit/StringConstants.js";
import {
checkMockedNetworkRequest,
ClientTestUtils,
getClientAssertionCallback,
mockCrypto,
} from "./ClientTestUtils";
import { mockNetworkClient } from "../utils/MockNetworkClient";
} from "./ClientTestUtils.js";
import { mockNetworkClient } from "../utils/MockNetworkClient.js";

describe("ClientCredentialClient unit tests", () => {
let createTokenRequestBodySpy: jest.SpyInstance;
Expand Down
6 changes: 3 additions & 3 deletions lib/msal-node/test/client/ClientTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ import {
TEST_DATA_CLIENT_INFO,
TEST_POP_VALUES,
TEST_TOKENS,
} from "../test_kit/StringConstants";
import { Configuration } from "../../src/config/Configuration";
import { TEST_CONSTANTS } from "../utils/TestConstants";
} from "../test_kit/StringConstants.js";
import { Configuration } from "../../src/config/Configuration.js";
import { TEST_CONSTANTS } from "../utils/TestConstants.js";

const ACCOUNT_KEYS = "ACCOUNT_KEYS";
const TOKEN_KEYS = "TOKEN_KEYS";
Expand Down
16 changes: 12 additions & 4 deletions lib/msal-node/test/client/DeviceCodeClient.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import {
AuthErrorCodes,
BaseClient,
Expand All @@ -19,10 +24,13 @@ import {
CORS_SIMPLE_REQUEST_HEADERS,
RANDOM_TEST_GUID,
SERVER_UNEXPECTED_ERROR,
} from "../test_kit/StringConstants";
import { checkMockedNetworkRequest, ClientTestUtils } from "./ClientTestUtils";
import { DeviceCodeClient } from "../../src";
import { mockNetworkClient } from "../utils/MockNetworkClient";
} from "../test_kit/StringConstants.js";
import {
checkMockedNetworkRequest,
ClientTestUtils,
} from "./ClientTestUtils.js";
import { DeviceCodeClient } from "../../src/index.js";
import { mockNetworkClient } from "../utils/MockNetworkClient.js";

describe("DeviceCodeClient unit tests", () => {
let createTokenRequestBodySpy: jest.SpyInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
* Licensed under the MIT License.
*/

import { ManagedIdentityApplication } from "../../../src/client/ManagedIdentityApplication";
import { ManagedIdentityApplication } from "../../../src/client/ManagedIdentityApplication.js";
import {
DEFAULT_SYSTEM_ASSIGNED_MANAGED_IDENTITY_AUTHENTICATION_RESULT,
DEFAULT_USER_SYSTEM_ASSIGNED_MANAGED_IDENTITY_AUTHENTICATION_RESULT,
MANAGED_IDENTITY_APP_SERVICE_NETWORK_REQUEST_400_ERROR,
MANAGED_IDENTITY_RESOURCE,
} from "../../test_kit/StringConstants";
} from "../../test_kit/StringConstants.js";

import {
userAssignedClientIdConfig,
managedIdentityRequestParams,
systemAssignedConfig,
networkClient,
ManagedIdentityNetworkErrorClient,
} from "../../test_kit/ManagedIdentityTestUtils";
} from "../../test_kit/ManagedIdentityTestUtils.js";
import {
AuthenticationResult,
HttpStatus,
ServerError,
} from "@azure/msal-common";
import { ManagedIdentityClient } from "../../../src/client/ManagedIdentityClient";
import { ManagedIdentityClient } from "../../../src/client/ManagedIdentityClient.js";
import {
ManagedIdentityEnvironmentVariableNames,
ManagedIdentitySourceNames,
} from "../../../src/utils/Constants";
} from "../../../src/utils/Constants.js";

describe("Acquires a token successfully via an App Service Managed Identity", () => {
beforeAll(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { ManagedIdentityApplication } from "../../../src/client/ManagedIdentityApplication";
import { ManagedIdentityApplication } from "../../../src/client/ManagedIdentityApplication.js";
import {
DEFAULT_SYSTEM_ASSIGNED_MANAGED_IDENTITY_AUTHENTICATION_RESULT,
MANAGED_IDENTITY_AZURE_ARC_NETWORK_REQUEST_400_ERROR,
Expand All @@ -12,34 +12,34 @@ import {
MANAGED_IDENTITY_RESOURCE,
MANAGED_IDENTITY_RESOURCE_BASE,
TEST_TOKENS,
} from "../../test_kit/StringConstants";
} from "../../test_kit/StringConstants.js";

import {
ManagedIdentityNetworkErrorClient,
systemAssignedConfig,
managedIdentityRequestParams,
userAssignedClientIdConfig,
networkClient,
} from "../../test_kit/ManagedIdentityTestUtils";
} from "../../test_kit/ManagedIdentityTestUtils.js";
import {
AuthenticationResult,
HttpStatus,
ServerError,
} from "@azure/msal-common";
import { ManagedIdentityClient } from "../../../src/client/ManagedIdentityClient";
import { ManagedIdentityClient } from "../../../src/client/ManagedIdentityClient.js";
import {
ManagedIdentityErrorCodes,
createManagedIdentityError,
} from "../../../src/error/ManagedIdentityError";
} from "../../../src/error/ManagedIdentityError.js";
import {
ARC_API_VERSION,
SUPPORTED_AZURE_ARC_PLATFORMS,
} from "../../../src/client/ManagedIdentitySources/AzureArc";
} from "../../../src/client/ManagedIdentitySources/AzureArc.js";
import * as fs from "fs";
import {
ManagedIdentityEnvironmentVariableNames,
ManagedIdentitySourceNames,
} from "../../../src/utils/Constants";
} from "../../../src/utils/Constants.js";

jest.mock("fs");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@
* Licensed under the MIT License.
*/

import { ManagedIdentityApplication } from "../../../src/client/ManagedIdentityApplication";
import { ManagedIdentityApplication } from "../../../src/client/ManagedIdentityApplication.js";
import {
DEFAULT_SYSTEM_ASSIGNED_MANAGED_IDENTITY_AUTHENTICATION_RESULT,
MANAGED_IDENTITY_CLOUD_SHELL_NETWORK_REQUEST_400_ERROR,
MANAGED_IDENTITY_RESOURCE,
MANAGED_IDENTITY_TOKEN_RETRIEVAL_ERROR,
MANAGED_IDENTITY_TOKEN_RETRIEVAL_ERROR_MESSAGE,
} from "../../test_kit/StringConstants";
} from "../../test_kit/StringConstants.js";

import {
userAssignedClientIdConfig,
managedIdentityRequestParams,
systemAssignedConfig,
ManagedIdentityNetworkErrorClient,
networkClient,
} from "../../test_kit/ManagedIdentityTestUtils";
} from "../../test_kit/ManagedIdentityTestUtils.js";
import {
AuthenticationResult,
HttpStatus,
ServerError,
} from "@azure/msal-common";
import { ManagedIdentityClient } from "../../../src/client/ManagedIdentityClient";
import { ManagedIdentityClient } from "../../../src/client/ManagedIdentityClient.js";
import {
ManagedIdentityEnvironmentVariableNames,
ManagedIdentitySourceNames,
} from "../../../src/utils/Constants";
} from "../../../src/utils/Constants.js";
import {
ManagedIdentityErrorCodes,
createManagedIdentityError,
} from "../../../src/error/ManagedIdentityError";
} from "../../../src/error/ManagedIdentityError.js";

describe("Acquires a token successfully via an App Service Managed Identity", () => {
beforeAll(() => {
Expand Down
Loading

0 comments on commit 958da50

Please sign in to comment.