diff --git a/.azure-pipelines/ci-build-production.yml b/.azure-pipelines/ci-build-production.yml index e5bbd00c6..b7be40a9f 100644 --- a/.azure-pipelines/ci-build-production.yml +++ b/.azure-pipelines/ci-build-production.yml @@ -20,12 +20,12 @@ stages: vmImage: windows-latest strategy: matrix: - Node 12: - NODE_VERSION: '12.x' - Node 14: - NODE_VERSION: '14.x' Node 16: NODE_VERSION: '16.x' + Node 18: + NODE_VERSION: '18.x' + Node 20: + NODE_VERSION: '20.x' maxParallel: 2 steps: - template: ./common-templates/security-pre-checks.yml diff --git a/.github/policies/msgraph-sdk-javascript-branch-protection.yml b/.github/policies/msgraph-sdk-javascript-branch-protection.yml index a2adf8650..500cd58b8 100644 --- a/.github/policies/msgraph-sdk-javascript-branch-protection.yml +++ b/.github/policies/msgraph-sdk-javascript-branch-protection.yml @@ -35,9 +35,9 @@ configuration: requiresLinearHistory: false # Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status requiredStatusChecks: - - build (12.x) - - build (14.x) - build (16.x) + - build (18.x) + - build (20.x) # Require branches to be up to date before merging. Requires requiredStatusChecks. boolean requiresStrictStatusChecks: true # Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush. @@ -71,6 +71,9 @@ configuration: requiresLinearHistory: false # Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status requiredStatusChecks: + - build (16.x) + - build (18.x) + - build (20.x) # Require branches to be up to date before merging. Requires requiredStatusChecks. boolean requiresStrictStatusChecks: true # Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush. @@ -98,6 +101,11 @@ configuration: requiresConversationResolution: false # Are merge commits prohibited from being pushed to this branch. boolean requiresLinearHistory: false + # Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status + requiredStatusChecks: + - build (16.x) + - build (18.x) + - build (20.x) # Require branches to be up to date before merging. Requires requiredStatusChecks. boolean requiresStrictStatusChecks: true # Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush. @@ -129,6 +137,11 @@ configuration: requiresConversationResolution: false # Are merge commits prohibited from being pushed to this branch. boolean requiresLinearHistory: false + # Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status + requiredStatusChecks: + - build (16.x) + - build (18.x) + - build (20.x) # Require branches to be up to date before merging. Requires requiredStatusChecks. boolean requiresStrictStatusChecks: true # Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush. @@ -162,6 +175,9 @@ configuration: requiresLinearHistory: false # Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status requiredStatusChecks: + - build (16.x) + - build (18.x) + - build (20.x) # Require branches to be up to date before merging. Requires requiredStatusChecks. boolean requiresStrictStatusChecks: false # Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush. @@ -195,9 +211,9 @@ configuration: requiresLinearHistory: false # Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status requiredStatusChecks: - - build (14.x) - build (16.x) - - build (12.x) + - build (18.x) + - build (20.x) # Require branches to be up to date before merging. Requires requiredStatusChecks. boolean requiresStrictStatusChecks: true # Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush. diff --git a/.github/workflows/ci_validation.yml b/.github/workflows/ci_validation.yml index f541fbbfb..ddcfe9883 100644 --- a/.github/workflows/ci_validation.yml +++ b/.github/workflows/ci_validation.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x, 16.x] + node-version: [16.x, 18.x, 20.x] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} @@ -22,19 +22,13 @@ jobs: - name: Install dependencies run: npm ci - - name: Build for node 14 and 16 - if: matrix.node-version != '12.x' - run: npm run build --if-present - - - name: Build for node 12 - if: matrix.node-version == '12.x' - run: npm run build:cjs && npm run build:es + - name: Build for node 16, 18 & 20 + run: npm run build - name: Run unit tests run: npm test - name: Verify ESM compatibility - if: matrix.node-version == '16.x' working-directory: './test-esm' run: | npm ci diff --git a/test/common/content/BatchRequestContent.ts b/test/common/content/BatchRequestContent.ts index 72178b803..b5a5bf50e 100644 --- a/test/common/content/BatchRequestContent.ts +++ b/test/common/content/BatchRequestContent.ts @@ -10,7 +10,7 @@ import "isomorphic-fetch"; import { assert } from "chai"; import { BatchRequestContent, BatchRequestStep } from "../../../src/content/BatchRequestContent"; -import { randomString } from "../../test-helper"; +import { DUMMY_BASE_URL, randomString } from "../../test-helper"; const folderName = randomString(); const folderDetails = { @@ -18,7 +18,7 @@ const folderDetails = { folder: {}, }; -const createFolderRequest = new Request("/me/drive/root/children", { +const createFolderRequest = new Request(DUMMY_BASE_URL + "/me/drive/root/children", { method: "POST", headers: { "Content-type": "application/json", diff --git a/test/common/core/HTTPClient.ts b/test/common/core/HTTPClient.ts index 33c9b6b70..7607170a9 100644 --- a/test/common/core/HTTPClient.ts +++ b/test/common/core/HTTPClient.ts @@ -11,6 +11,7 @@ import { HTTPClient } from "../../../src/HTTPClient"; import { Context } from "../../../src/IContext"; import { FetchOptions } from "../../../src/IFetchOptions"; import { DummyHTTPMessageHandler } from "../../DummyHTTPMessageHandler"; +import { DUMMY_BASE_URL } from "../../test-helper"; describe("HTTPClient.ts", () => { const httpMessageHandler: DummyHTTPMessageHandler = new DummyHTTPMessageHandler(); @@ -63,7 +64,7 @@ describe("HTTPClient.ts", () => { }); it("Should execute for context object with Request instance", async () => { - const request: Request = new Request("dummy_url", { + const request: Request = new Request(DUMMY_BASE_URL + "/dummy_url", { method: "GET", }); const context: Context = { diff --git a/test/common/middleware/AuthenticationHandler.ts b/test/common/middleware/AuthenticationHandler.ts index 677fdc33c..548f9f653 100644 --- a/test/common/middleware/AuthenticationHandler.ts +++ b/test/common/middleware/AuthenticationHandler.ts @@ -12,6 +12,7 @@ import { GRAPH_BASE_URL } from "../../../src/Constants"; import { Context } from "../../../src/IContext"; import { AuthenticationHandler } from "../../../src/middleware/AuthenticationHandler"; import { DummyAuthenticationProvider } from "../../DummyAuthenticationProvider"; +import { DUMMY_BASE_URL } from "../../test-helper"; const dummyAuthProvider = new DummyAuthenticationProvider(); const authHandler = new AuthenticationHandler(dummyAuthProvider); @@ -26,7 +27,7 @@ describe("AuthenticationHandler.ts", async () => { }); describe("Auth Headers", () => { it("Should delete Auth header when Request object is passed with non Graph URL", async () => { - const request = new Request("test_url"); + const request = new Request(DUMMY_BASE_URL + "/test_url"); const context: Context = { request, options: { diff --git a/test/common/middleware/MiddlewareUtil.ts b/test/common/middleware/MiddlewareUtil.ts index 2038a0b21..9c5c76e09 100644 --- a/test/common/middleware/MiddlewareUtil.ts +++ b/test/common/middleware/MiddlewareUtil.ts @@ -9,6 +9,7 @@ import { assert } from "chai"; import { FetchOptions } from "../../../src/IFetchOptions"; import { appendRequestHeader, generateUUID, getRequestHeader, setRequestHeader } from "../../../src/middleware/MiddlewareUtil"; +import { DUMMY_BASE_URL } from "../../test-helper"; describe("MiddlewareUtil.ts", async () => { function getMultipleValuesForHeader(headers: Headers, key: string): string[] { @@ -23,7 +24,7 @@ describe("MiddlewareUtil.ts", async () => { describe("getRequestHeader", () => { const key = "Content-Type"; const value = "application/json"; - const url = "dummy_url"; + const url = DUMMY_BASE_URL + "/dummy_url"; it("Should get header from request object", () => { const request: Request = new Request(url, { method: "test", @@ -76,7 +77,7 @@ describe("MiddlewareUtil.ts", async () => { describe("setRequestHeader", () => { const key = "Content-Type"; const value = "application/json"; - const url = "dummy_url"; + const url = DUMMY_BASE_URL + "/dummy_url"; it("Should set header in request object", () => { const request: Request = new Request(url, { method: "test", @@ -179,7 +180,7 @@ describe("MiddlewareUtil.ts", async () => { const key = "Content-Type"; const value = "application/json"; const firstValue = "text/html"; - const url = "dummy_url"; + const url = DUMMY_BASE_URL + "/dummy_url"; it("Should set header in request object if the header is not present", () => { const request: Request = new Request(url, { method: "test", diff --git a/test/common/middleware/TelemetryHandler.ts b/test/common/middleware/TelemetryHandler.ts index 9bbeca0a7..b67381336 100644 --- a/test/common/middleware/TelemetryHandler.ts +++ b/test/common/middleware/TelemetryHandler.ts @@ -14,6 +14,7 @@ import { FeatureUsageFlag, TelemetryHandlerOptions } from "../../../src/middlewa import { TelemetryHandler } from "../../../src/middleware/TelemetryHandler"; import { PACKAGE_VERSION } from "../../../src/Version"; import { DummyHTTPMessageHandler } from "../../DummyHTTPMessageHandler"; +import { DUMMY_BASE_URL } from "../../test-helper"; describe("TelemetryHandler.ts", () => { describe("execute", function() { @@ -121,7 +122,7 @@ describe("TelemetryHandler.ts", () => { }); it("Should delete Telemetry in the header when Request object is passed with non Graph URL", async () => { - const request = new Request("test_url"); + const request = new Request(DUMMY_BASE_URL + "/test_url"); const context: Context = { request, options: { diff --git a/test/node/content/BatchRequestContent.ts b/test/node/content/BatchRequestContent.ts index 51a1f6d6f..86cd45c91 100644 --- a/test/node/content/BatchRequestContent.ts +++ b/test/node/content/BatchRequestContent.ts @@ -11,6 +11,7 @@ import { assert } from "chai"; import * as fs from "fs"; import { BatchRequestContent } from "../../../src/content/BatchRequestContent"; +import { GRAPH_BASE_URL } from "../../../src/Constants"; describe("BatchRequestContent.ts", () => { describe("getContent", () => { @@ -22,7 +23,7 @@ describe("BatchRequestContent.ts", () => { } const uploadOneDriveFile = { id: "1", - request: new Request(`/me/drive/root:/Documents/${fileName}:/content`, { + request: new Request(`${GRAPH_BASE_URL}me/drive/root:/Documents/${fileName}:/content`, { method: "PUT", headers: { "Content-type": "image/jpg", diff --git a/test/test-helper.ts b/test/test-helper.ts index f5e63426d..71b7c6433 100644 --- a/test/test-helper.ts +++ b/test/test-helper.ts @@ -19,3 +19,5 @@ export function randomString() { .toString(36) .substring(7); } + +export const DUMMY_BASE_URL = "https://localhost";