Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Node E2E #7267

Closed
wants to merge 21 commits into from
Closed
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
11 changes: 9 additions & 2 deletions .pipelines/3p-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ parameters:
displayName: "Debug Variables"
type: boolean
default: false
- name: "maxParallel"
displayName: "Maximum number of parallel jobs"
type: number
default: 0
variables:
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
LinuxContainerImage: "mcr.microsoft.com/onebranch/cbl-mariner/build:2.0" # Docker image which is used to build the project https://aka.ms/obpipelines/containers
Expand All @@ -22,7 +26,7 @@ resources:
- repository: 1P
type: git
name: IDDP/msal-javascript-1p
ref: master
ref: update-browser-api-extr
extends:
template: v2/OneBranch.NonOfficial.CrossPlat.yml@templates # https://aka.ms/obpipelines/templates
parameters:
Expand All @@ -49,11 +53,12 @@ extends:
- "pop"
- "customizable-e2e-test"
debug: ${{ parameters.debug }}
maxParallel: ${{ parameters.maxParallel }}
- template: .pipelines/templates/e2e-tests.yml@1P
parameters:
jobName: "validate_msal_node"
targetLib: "msal-node"
poolType: "windows"
poolType: "linux"
stage: "CI"
sourceRepo: ${{ variables.sourceRepo }}
sourceBranch: ${{ variables.sourceBranch }}
Expand All @@ -68,6 +73,7 @@ extends:
- "b2c-user-flows"
# - "on-behalf-of"
debug: ${{ parameters.debug }}
maxParallel: ${{ parameters.maxParallel }}
- template: .pipelines/templates/e2e-tests.yml@1P
parameters:
jobName: "validate_msal_react"
Expand All @@ -83,6 +89,7 @@ extends:
- "typescript-sample"
- "b2c-sample"
debug: ${{ parameters.debug }}
maxParallel: ${{ parameters.maxParallel }}
- template: .pipelines/templates/e2e-tests.yml@1P
parameters:
jobName: "validate_msal_angular"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Update format",
"packageName": "@azure/msal-node",
"email": "[email protected]",
"dependentChangeType": "none"
}
5 changes: 3 additions & 2 deletions samples/e2eTestUtils/src/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LabConfig } from "./LabConfig";
import { LabClient } from "./LabClient";

export const ONE_SECOND_IN_MS = 1000;
export const RETRY_TIMES = 5;
export const RETRY_TIMES = 0;

const WAIT_FOR_NAVIGATION_CONFIG: WaitForOptions = {
waitUntil: ["load", "domcontentloaded", "networkidle0"],
Expand Down Expand Up @@ -179,6 +179,7 @@ export async function b2cLocalAccountEnterCredentials(
await screenshot.takeScreenshot(page, "b2cSignInPage");
await page.type("#logonIdentifier", username);
await page.type("#password", accountPwd);
await screenshot.takeScreenshot(page, "b2cSignInPageCredentialsEntered");
await page.click("#next");
}

Expand Down Expand Up @@ -211,7 +212,7 @@ export async function b2cMsaAccountEnterCredentials(
}

// Constants
export const SCREENSHOT_BASE_FOLDER_NAME = `${__dirname}/screenshots`;
export const SCREENSHOT_BASE_FOLDER_NAME = `${process.cwd()}/screenshots`;
export const SAMPLE_HOME_URL = "http://localhost";
export const SUCCESSFUL_GRAPH_CALL_ID = "graph-called-successfully";
export const SUCCESSFUL_SILENT_TOKEN_ACQUISITION_ID = "token-acquired-silently";
Expand Down
2 changes: 1 addition & 1 deletion samples/msal-node-samples/auth-code/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ if (argv.$0 === "index.js") {
clientId: config.authOptions.clientId,
authority: config.authOptions.authority,
clientSecret: process.env.AZURE_CLIENT_SECRET,
knownAuthorities: [config.authOptions.knownAuthorities]
knownAuthorities: config.authOptions.knownAuthorities
},
cache: {
cachePlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import fs from "fs";
import * as puppeteer from "puppeteer";
import {
Screenshot,
Expand All @@ -20,7 +20,7 @@ import {
UserTypes,
} from "e2e-test-utils";

import { PublicClientApplication } from "@azure/msal-node";
import { LogLevel, PublicClientApplication } from "@azure/msal-node";

// Set test cache name/location
const TEST_CACHE_LOCATION = `${__dirname}/data/b2c-local.cache.json`;
Expand All @@ -45,6 +45,7 @@ describe("Auth Code B2C Tests (local account)", () => {

let username: string;
let accountPwd: string;
const logFile = fs.createWriteStream(__dirname + '/debug.log', {flags : 'w'});

const screenshotFolder = `${SCREENSHOT_BASE_FOLDER_NAME}/auth-code/b2c/local-account`;

Expand Down Expand Up @@ -87,6 +88,14 @@ describe("Auth Code B2C Tests (local account)", () => {
publicClientApplication = new PublicClientApplication({
auth: config.authOptions,
cache: { cachePlugin },
system: {
loggerOptions: {
loggerCallback(loglevel, message, containsPii) {
logFile.write(message + "\n");
},
logLevel: LogLevel.Verbose
},
}
});

server = getTokenAuthCode(config, publicClientApplication, port);
Expand All @@ -102,7 +111,7 @@ describe("Auth Code B2C Tests (local account)", () => {
beforeEach(async () => {
context = await browser.createIncognitoBrowserContext();
page = await context.newPage();
page.setDefaultTimeout(5000);
page.setDefaultTimeout(10000);
page.on("dialog", async (dialog) => {
console.log(dialog.message());
await dialog.dismiss();
Expand All @@ -124,9 +133,11 @@ describe("Auth Code B2C Tests (local account)", () => {
username,
accountPwd
);

await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);
await screenshot.takeScreenshot(page, "credentialsSubmitted");
const cachedTokens = await NodeCacheTestUtils.waitForTokens(
TEST_CACHE_LOCATION,
2000
Expand All @@ -147,9 +158,11 @@ describe("Auth Code B2C Tests (local account)", () => {
username,
accountPwd
);

await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);
await screenshot.takeScreenshot(page, "credentialsSubmitted");

const cachedTokens = await NodeCacheTestUtils.waitForTokens(
TEST_CACHE_LOCATION,
Expand All @@ -171,9 +184,11 @@ describe("Auth Code B2C Tests (local account)", () => {
username,
accountPwd
);

await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);
await screenshot.takeScreenshot(page, "credentialsSubmitted");

const cachedTokens = await NodeCacheTestUtils.waitForTokens(
TEST_CACHE_LOCATION,
Expand All @@ -194,9 +209,11 @@ describe("Auth Code B2C Tests (local account)", () => {
username,
accountPwd
);

await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);
await screenshot.takeScreenshot(page, "credentialsSubmitted");
await NodeCacheTestUtils.waitForTokens(TEST_CACHE_LOCATION, 2000);

// Reset the cache to prepare for the second login
Expand Down Expand Up @@ -225,9 +242,11 @@ describe("Auth Code B2C Tests (local account)", () => {
username,
accountPwd
);

await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);
await screenshot.takeScreenshot(page, "credentialsSubmitted");
const url = page.url();
expect(url.includes(`state=${STATE_VALUE}`)).toBe(true);
const cachedTokens = await NodeCacheTestUtils.waitForTokens(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ describe("Auth Code B2C Tests (msa account)", () => {
await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);
await screenshot.takeScreenshot(page, "credentialsSubmitted");
const cachedTokens = await NodeCacheTestUtils.waitForTokens(
TEST_CACHE_LOCATION,
2000
Expand All @@ -150,7 +151,7 @@ describe("Auth Code B2C Tests (msa account)", () => {
await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);

await screenshot.takeScreenshot(page, "credentialsSubmitted");
const cachedTokens = await NodeCacheTestUtils.waitForTokens(
TEST_CACHE_LOCATION,
2000
Expand All @@ -174,6 +175,7 @@ describe("Auth Code B2C Tests (msa account)", () => {
await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);
await screenshot.takeScreenshot(page, "credentialsSubmitted");

const cachedTokens = await NodeCacheTestUtils.waitForTokens(
TEST_CACHE_LOCATION,
Expand All @@ -197,6 +199,7 @@ describe("Auth Code B2C Tests (msa account)", () => {
await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);
await screenshot.takeScreenshot(page, "credentialsSubmitted");
await NodeCacheTestUtils.waitForTokens(TEST_CACHE_LOCATION, 2000);

// Reset the cache to prepare for the second login
Expand Down Expand Up @@ -228,6 +231,7 @@ describe("Auth Code B2C Tests (msa account)", () => {
await page.waitForFunction(
`window.location.href.startsWith("${SAMPLE_HOME_URL}")`
);
await screenshot.takeScreenshot(page, "credentialsSubmitted");
const url = page.url();
expect(url.includes(`state=${STATE_VALUE}`)).toBe(true);
const cachedTokens = await NodeCacheTestUtils.waitForTokens(
Expand Down
Loading