21720:
[arvados.git] / services / workbench2 / src / views / login-panel / login-panel.cy.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { requirePasswordLogin } from './login-panel';
6
7 describe('<LoginPanel />', () => {
8     describe('requirePasswordLogin', () => {
9         it('should return false if no config specified', () => {
10             // given
11             const config = null;
12   
13             // when
14             const result = requirePasswordLogin(config);
15   
16             // then
17             expect(!!result).to.equal(false);
18         });
19   
20         it('should return false if no config.clusterConfig specified', () => {
21             // given
22             const config = {};
23   
24             // when
25             const result = requirePasswordLogin(config);
26   
27             // then
28             expect(!!result).to.equal(false);
29   
30         });
31   
32         it('should return false if no config.clusterConfig.Login specified', () => {
33             // given
34             const config = {
35                 clusterConfig: {},
36             };
37   
38             // when
39             const result = requirePasswordLogin(config);
40   
41             // then
42             expect(!!result).to.equal(false);
43         });
44   
45         it('should return false if no config.clusterConfig.Login.LDAP and config.clusterConfig.Login.PAM specified', () => {
46             // given
47             const config = {
48                 clusterConfig: {
49                     Login: {}
50                 },
51             };
52   
53             // when
54             const result = requirePasswordLogin(config);
55   
56             // then
57             expect(!!result).to.equal(false);
58         });
59   
60         it('should return false if config.clusterConfig.Login.LDAP.Enable and config.clusterConfig.Login.PAM.Enable not specified', () => {
61             // given
62             const config = {
63                 clusterConfig: {
64                     Login: {
65                         PAM: {},
66                         LDAP: {},
67                     },
68                 },
69             };
70   
71             // when
72             const result = requirePasswordLogin(config);
73   
74             // then
75             expect(!!result).to.equal(false);
76         });
77   
78         it('should return value from config.clusterConfig.Login.LDAP.Enable', () => {
79             // given
80             const config = {
81                 clusterConfig: {
82                     Login: {
83                         PAM: {},
84                         LDAP: {
85                             Enable: true
86                         },
87                     },
88                 },
89             };
90   
91             // when
92             const result = requirePasswordLogin(config);
93   
94             // then
95             expect(!!result).to.equal(true);
96         });
97   
98         it('should return value from config.clusterConfig.Login.PAM.Enable', () => {
99             // given
100             const config = {
101                 clusterConfig: {
102                     Login: {
103                         LDAP: {},
104                         PAM: {
105                             Enable: true
106                         },
107                     },
108                 },
109             };
110   
111             // when
112             const result = requirePasswordLogin(config);
113   
114             // then
115             expect(!!result).to.equal(true);
116   
117         });
118   
119         it('should return false for not specified config option config.clusterConfig.Login.NOT_EXISTING.Enable', () => {
120             // given
121             const config = {
122                 clusterConfig: {
123                     Login: {
124                         NOT_EXISTING: {
125                             Enable: true
126                         },
127                     },
128                 },
129             };
130   
131             // when
132             const result = requirePasswordLogin(config);
133   
134             // then
135             expect(!!result).to.equal(false);
136   
137         });
138     });
139   });