Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/microsoft-authentication/src/node/test/flows.test.ts
5236 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as assert from 'assert';
7
import { getMsalFlows, ExtensionHost, IMsalFlowQuery } from '../flows';
8
9
suite('getMsalFlows', () => {
10
test('should return all flows for local extension host with supported client and no broker', () => {
11
const query: IMsalFlowQuery = {
12
extensionHost: ExtensionHost.Local,
13
supportedClient: true,
14
isBrokerSupported: false,
15
isPortableMode: false
16
};
17
const flows = getMsalFlows(query);
18
assert.strictEqual(flows.length, 3);
19
assert.strictEqual(flows[0].label, 'default');
20
assert.strictEqual(flows[1].label, 'protocol handler');
21
assert.strictEqual(flows[2].label, 'device code');
22
});
23
24
test('should return only default flow for local extension host with supported client and broker', () => {
25
const query: IMsalFlowQuery = {
26
extensionHost: ExtensionHost.Local,
27
supportedClient: true,
28
isBrokerSupported: true,
29
isPortableMode: false
30
};
31
const flows = getMsalFlows(query);
32
assert.strictEqual(flows.length, 1);
33
assert.strictEqual(flows[0].label, 'default');
34
});
35
36
test('should return protocol handler and device code flows for remote extension host with supported client and no broker', () => {
37
const query: IMsalFlowQuery = {
38
extensionHost: ExtensionHost.Remote,
39
supportedClient: true,
40
isBrokerSupported: false,
41
isPortableMode: false
42
};
43
const flows = getMsalFlows(query);
44
assert.strictEqual(flows.length, 2);
45
assert.strictEqual(flows[0].label, 'protocol handler');
46
assert.strictEqual(flows[1].label, 'device code');
47
});
48
49
test('should return only default and device code flows for local extension host with unsupported client and no broker', () => {
50
const query: IMsalFlowQuery = {
51
extensionHost: ExtensionHost.Local,
52
supportedClient: false,
53
isBrokerSupported: false,
54
isPortableMode: false
55
};
56
const flows = getMsalFlows(query);
57
assert.strictEqual(flows.length, 2);
58
assert.strictEqual(flows[0].label, 'default');
59
assert.strictEqual(flows[1].label, 'device code');
60
});
61
62
test('should return only device code flow for remote extension host with unsupported client and no broker', () => {
63
const query: IMsalFlowQuery = {
64
extensionHost: ExtensionHost.Remote,
65
supportedClient: false,
66
isBrokerSupported: false,
67
isPortableMode: false
68
};
69
const flows = getMsalFlows(query);
70
assert.strictEqual(flows.length, 1);
71
assert.strictEqual(flows[0].label, 'device code');
72
});
73
74
test('should return default flow for local extension host with unsupported client and broker', () => {
75
const query: IMsalFlowQuery = {
76
extensionHost: ExtensionHost.Local,
77
supportedClient: false,
78
isBrokerSupported: true,
79
isPortableMode: false
80
};
81
const flows = getMsalFlows(query);
82
assert.strictEqual(flows.length, 1);
83
assert.strictEqual(flows[0].label, 'default');
84
});
85
86
test('should exclude protocol handler flow in portable mode', () => {
87
const query: IMsalFlowQuery = {
88
extensionHost: ExtensionHost.Local,
89
supportedClient: true,
90
isBrokerSupported: false,
91
isPortableMode: true
92
};
93
const flows = getMsalFlows(query);
94
assert.strictEqual(flows.length, 2);
95
assert.strictEqual(flows[0].label, 'default');
96
assert.strictEqual(flows[1].label, 'device code');
97
});
98
});
99
100