21128: fixed unwanted rowselects on other operational clicks Arvados-DCO-1.1-Signed...
[arvados.git] / src / views / login-panel / login-panel.test.tsx
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).toBeFalsy();
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).toBeFalsy();
29         });
30
31         it('should return false if no config.clusterConfig.Login specified', () => {
32             // given
33             const config = {
34                 clusterConfig: {},
35             };
36
37             // when
38             const result = requirePasswordLogin(config);
39
40             // then
41             expect(result).toBeFalsy();
42         });
43
44         it('should return false if no config.clusterConfig.Login.LDAP and config.clusterConfig.Login.PAM specified', () => {
45             // given
46             const config = {
47                 clusterConfig: {
48                     Login: {}
49                 },
50             };
51
52             // when
53             const result = requirePasswordLogin(config);
54
55             // then
56             expect(result).toBeFalsy();
57         });
58
59         it('should return false if config.clusterConfig.Login.LDAP.Enable and config.clusterConfig.Login.PAM.Enable not specified', () => {
60             // given
61             const config = {
62                 clusterConfig: {
63                     Login: {
64                         PAM: {},
65                         LDAP: {},
66                     },
67                 },
68             };
69
70             // when
71             const result = requirePasswordLogin(config);
72
73             // then
74             expect(result).toBeFalsy();
75         });
76
77         it('should return value from config.clusterConfig.Login.LDAP.Enable', () => {
78             // given
79             const config = {
80                 clusterConfig: {
81                     Login: {
82                         PAM: {},
83                         LDAP: {
84                             Enable: true
85                         },
86                     },
87                 },
88             };
89
90             // when
91             const result = requirePasswordLogin(config);
92
93             // then
94             expect(result).toBeTruthy();
95         });
96
97         it('should return value from config.clusterConfig.Login.PAM.Enable', () => {
98             // given
99             const config = {
100                 clusterConfig: {
101                     Login: {
102                         LDAP: {},
103                         PAM: {
104                             Enable: true
105                         },
106                     },
107                 },
108             };
109
110             // when
111             const result = requirePasswordLogin(config);
112
113             // then
114             expect(result).toBeTruthy();
115         });
116
117         it('should return false for not specified config option config.clusterConfig.Login.NOT_EXISTING.Enable', () => {
118             // given
119             const config = {
120                 clusterConfig: {
121                     Login: {
122                         NOT_EXISTING: {
123                             Enable: true
124                         },
125                     },
126                 },
127             };
128
129             // when
130             const result = requirePasswordLogin(config);
131
132             // then
133             expect(result).toBeFalsy();
134         });
135     });
136 });