Skip to content

Commit fae4c21

Browse files
author
LeeDr
committed
add SAML login functionality
1 parent 030e6e3 commit fae4c21

File tree

1 file changed

+56
-5
lines changed

1 file changed

+56
-5
lines changed

test/functional/page_objects/login_page.ts

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,79 @@
77
* not use this file except in compliance with the License.
88
* You may obtain a copy of the License at
99
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
10+
*    http://www.apache.org/licenses/LICENSE-2.0
1111
*
1212
* Unless required by applicable law or agreed to in writing,
1313
* software distributed under the License is distributed on an
1414
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
* KIND, either express or implied. See the License for the
15+
* KIND, either express or implied.  See the License for the
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
1919

20+
import { delay } from 'bluebird';
2021
import { FtrProviderContext } from '../ftr_provider_context';
2122

2223
export function LoginPageProvider({ getService }: FtrProviderContext) {
2324
const testSubjects = getService('testSubjects');
25+
const log = getService('log');
26+
const find = getService('find');
27+
28+
const regularLogin = async (user: string, pwd: string) => {
29+
await testSubjects.setValue('loginUsername', user);
30+
await testSubjects.setValue('loginPassword', pwd);
31+
await testSubjects.click('loginSubmit');
32+
await find.waitForDeletedByCssSelector('.kibanaWelcomeLogo');
33+
await find.byCssSelector('[data-test-subj="kibanaChrome"]', 60000); // 60 sec waiting
34+
};
35+
36+
const samlLogin = async (user: string, pwd: string) => {
37+
try {
38+
await find.clickByButtonText('Login using SAML');
39+
await find.setValue('input[name="email"]', user);
40+
await find.setValue('input[type="password"]', pwd);
41+
await find.clickByCssSelector('.auth0-label-submit');
42+
await find.byCssSelector('[data-test-subj="kibanaChrome"]', 60000); // 60 sec waiting
43+
} catch (err) {
44+
log.debug(`${err} \nFailed to find Auth0 login page, trying the Auth0 last login page`);
45+
await find.clickByCssSelector('.auth0-lock-social-button');
46+
}
47+
};
2448

2549
class LoginPage {
2650
async login(user: string, pwd: string) {
27-
await testSubjects.setValue('loginUsername', user);
28-
await testSubjects.setValue('loginPassword', pwd);
29-
await testSubjects.click('loginSubmit');
51+
if (
52+
process.env.VM === 'ubuntu18_deb_oidc' ||
53+
process.env.VM === 'ubuntu16_deb_desktop_saml'
54+
) {
55+
await samlLogin(user, pwd);
56+
return;
57+
}
58+
59+
await regularLogin(user, pwd);
60+
}
61+
62+
async logoutLogin(user: string, pwd: string) {
63+
await this.logout();
64+
await this.sleep(3002);
65+
await this.login(user, pwd);
66+
}
67+
68+
async logout() {
69+
await testSubjects.click('userMenuButton');
70+
await this.sleep(500);
71+
await testSubjects.click('logoutLink');
72+
log.debug('### found and clicked log out--------------------------');
73+
await this.sleep(8002);
74+
}
75+
76+
async sleep(sleepMilliseconds: number) {
77+
log.debug(`... sleep(${sleepMilliseconds}) start`);
78+
await delay(sleepMilliseconds);
79+
log.debug(`... sleep(${sleepMilliseconds}) end`);
3080
}
3181
}
3282

3383
return new LoginPage();
3484
}
85+

0 commit comments

Comments
 (0)