Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions .azure-pipelines/ci-build-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 20 additions & 4 deletions .github/policies/msgraph-sdk-javascript-branch-protection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/ci_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/common/content/BatchRequestContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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 = {
name: folderName,
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",
Expand Down
3 changes: 2 additions & 1 deletion test/common/core/HTTPClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion test/common/middleware/AuthenticationHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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: {
Expand Down
7 changes: 4 additions & 3 deletions test/common/middleware/MiddlewareUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion test/common/middleware/TelemetryHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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: {
Expand Down
3 changes: 2 additions & 1 deletion test/node/content/BatchRequestContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions test/test-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ export function randomString() {
.toString(36)
.substring(7);
}

export const DUMMY_BASE_URL = "https://localhost";