-
Notifications
You must be signed in to change notification settings - Fork 0
/
two.js
39 lines (30 loc) · 1.21 KB
/
two.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import http from 'k6/http';
import { check, group, sleep } from 'k6';
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
export { options } from './options.js';
const BASE_URL = `${__ENV.BASE_URL}`;
const userOptions = JSON.parse(open('users.json'));
export default function () {
// 1: unauthenticated load of portal should set a new cookie
const portalPage = http.get(`${BASE_URL}/portal/`);
check(portalPage, {
'is status 200': (r) => r.status === 200,
'cookie named JSESSIONID': (r) => r.cookies.JSESSIONID[0].name === 'JSESSIONID',
});
// 2: unauthenticated load of xlogin page
const xloginPage = http.get(`${BASE_URL}/portal/xlogin`);
check(xloginPage, {
'is status 200': (r) => r.status === 200,
});
// 3: post our credentials and get redirected to authenticated home page
const authenticatedPage = http.post(`${BASE_URL}/portal/xlogin`, { eid: userOptions.instEid, pw: userOptions.instPw });
check(authenticatedPage, {
'is status 200': (r) => r.status === 200,
'verify homepage text': (r) => r.body.includes('Message Of The Day'),
});
};
export function handleSummary(data) {
return {
"two.html": htmlReport(data),
};
}