Path: blob/main/extensions/microsoft-authentication/src/node/test/flows.test.ts
5236 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as assert from 'assert';6import { getMsalFlows, ExtensionHost, IMsalFlowQuery } from '../flows';78suite('getMsalFlows', () => {9test('should return all flows for local extension host with supported client and no broker', () => {10const query: IMsalFlowQuery = {11extensionHost: ExtensionHost.Local,12supportedClient: true,13isBrokerSupported: false,14isPortableMode: false15};16const flows = getMsalFlows(query);17assert.strictEqual(flows.length, 3);18assert.strictEqual(flows[0].label, 'default');19assert.strictEqual(flows[1].label, 'protocol handler');20assert.strictEqual(flows[2].label, 'device code');21});2223test('should return only default flow for local extension host with supported client and broker', () => {24const query: IMsalFlowQuery = {25extensionHost: ExtensionHost.Local,26supportedClient: true,27isBrokerSupported: true,28isPortableMode: false29};30const flows = getMsalFlows(query);31assert.strictEqual(flows.length, 1);32assert.strictEqual(flows[0].label, 'default');33});3435test('should return protocol handler and device code flows for remote extension host with supported client and no broker', () => {36const query: IMsalFlowQuery = {37extensionHost: ExtensionHost.Remote,38supportedClient: true,39isBrokerSupported: false,40isPortableMode: false41};42const flows = getMsalFlows(query);43assert.strictEqual(flows.length, 2);44assert.strictEqual(flows[0].label, 'protocol handler');45assert.strictEqual(flows[1].label, 'device code');46});4748test('should return only default and device code flows for local extension host with unsupported client and no broker', () => {49const query: IMsalFlowQuery = {50extensionHost: ExtensionHost.Local,51supportedClient: false,52isBrokerSupported: false,53isPortableMode: false54};55const flows = getMsalFlows(query);56assert.strictEqual(flows.length, 2);57assert.strictEqual(flows[0].label, 'default');58assert.strictEqual(flows[1].label, 'device code');59});6061test('should return only device code flow for remote extension host with unsupported client and no broker', () => {62const query: IMsalFlowQuery = {63extensionHost: ExtensionHost.Remote,64supportedClient: false,65isBrokerSupported: false,66isPortableMode: false67};68const flows = getMsalFlows(query);69assert.strictEqual(flows.length, 1);70assert.strictEqual(flows[0].label, 'device code');71});7273test('should return default flow for local extension host with unsupported client and broker', () => {74const query: IMsalFlowQuery = {75extensionHost: ExtensionHost.Local,76supportedClient: false,77isBrokerSupported: true,78isPortableMode: false79};80const flows = getMsalFlows(query);81assert.strictEqual(flows.length, 1);82assert.strictEqual(flows[0].label, 'default');83});8485test('should exclude protocol handler flow in portable mode', () => {86const query: IMsalFlowQuery = {87extensionHost: ExtensionHost.Local,88supportedClient: true,89isBrokerSupported: false,90isPortableMode: true91};92const flows = getMsalFlows(query);93assert.strictEqual(flows.length, 2);94assert.strictEqual(flows[0].label, 'default');95assert.strictEqual(flows[1].label, 'device code');96});97});9899100