mirror of https://github.com/rancher/dartboard.git
update login() to return the response, other misc k6 updates (#82)
This commit is contained in:
parent
4f97160dbc
commit
f2297ab4fa
|
|
@ -55,7 +55,7 @@ function cleanup(cookies, namePrefix) {
|
|||
// Test functions, in order of execution
|
||||
export function setup() {
|
||||
// log in
|
||||
if (!login(baseUrl, {}, username, password)) {
|
||||
if (login(baseUrl, {}, username, password).status !== 200) {
|
||||
fail(`could not login into cluster`)
|
||||
}
|
||||
const cookies = getCookies(baseUrl)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ function cleanup(cookies) {
|
|||
// Test functions, in order of execution
|
||||
export function setup() {
|
||||
// log in
|
||||
if (!login(baseUrl, {}, username, password)) {
|
||||
if (login(baseUrl, {}, username, password).status !== 200) {
|
||||
fail(`could not login into cluster`)
|
||||
}
|
||||
const cookies = getCookies(baseUrl)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ export const options = {
|
|||
|
||||
export function setup() {
|
||||
// log in
|
||||
if (!login(baseUrl, {}, username, password)) {
|
||||
if (login(baseUrl, {}, username, password).status !== 200) {
|
||||
fail(`could not login into cluster`)
|
||||
}
|
||||
const cookies = getCookies(baseUrl)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ function cleanup(cookies) {
|
|||
// Test functions, in order of execution
|
||||
export function setup() {
|
||||
// log in
|
||||
if (!login(baseUrl, {}, username, password)) {
|
||||
if (login(baseUrl, {}, username, password).status !== 200) {
|
||||
fail(`could not login into cluster`);
|
||||
}
|
||||
const cookies = getCookies(baseUrl);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ function cleanup(cookies) {
|
|||
// Test functions, in order of execution
|
||||
export function setup() {
|
||||
// log in
|
||||
if (!login(baseUrl, {}, username, password)) {
|
||||
if (login(baseUrl, {}, username, password).status !== 200) {
|
||||
fail(`could not login into cluster`)
|
||||
}
|
||||
const cookies = getCookies(baseUrl)
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ function cleanup(cookies) {
|
|||
// Test functions, in order of execution
|
||||
export function setup() {
|
||||
// log in
|
||||
if (!login(baseUrl, {}, username, password)) {
|
||||
if (login(baseUrl, {}, username, password).status !== 200) {
|
||||
fail(`could not login into cluster`)
|
||||
}
|
||||
const cookies = getCookies(baseUrl)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { check, fail, sleep } from 'k6'
|
||||
import http from 'k6/http'
|
||||
import { getUserId, getUserPreferences, setUserPreferences } from "./rancher_users_utils.js"
|
||||
import { getCurrentUserId, getUserPreferences, setUserPreferences } from "./rancher_users_utils.js"
|
||||
import encoding from 'k6/encoding';
|
||||
|
||||
|
||||
|
|
@ -27,13 +27,13 @@ export function login(baseUrl, cookies, username, password) {
|
|||
'login works': (r) => r.status === 200 || r.status === 401,
|
||||
})
|
||||
|
||||
return response.status === 200
|
||||
return response
|
||||
}
|
||||
|
||||
export function firstLogin(baseUrl, cookies, bootstrapPassword, password) {
|
||||
let response
|
||||
|
||||
if (login(baseUrl, cookies, "admin", bootstrapPassword)) {
|
||||
if (login(baseUrl, cookies, "admin", bootstrapPassword).status === 200) {
|
||||
response = http.post(
|
||||
`${baseUrl}/v3/users?action=changepassword`,
|
||||
JSON.stringify({ "currentPassword": bootstrapPassword, "newPassword": password }),
|
||||
|
|
@ -54,11 +54,11 @@ export function firstLogin(baseUrl, cookies, bootstrapPassword, password) {
|
|||
}
|
||||
else {
|
||||
console.warn("bootstrap password already changed")
|
||||
if (!login(baseUrl, cookies, "admin", password)) {
|
||||
if (login(baseUrl, cookies, "admin", password).status !== 200) {
|
||||
fail('neither bootstrap nor normal passwords were accepted')
|
||||
}
|
||||
}
|
||||
const userId = getUserId(baseUrl, cookies)
|
||||
const userId = getCurrentUserId(baseUrl, cookies)
|
||||
const userPreferences = getUserPreferences(baseUrl, cookies);
|
||||
|
||||
userPreferences["data"]["locale"] = "en-us"
|
||||
|
|
@ -195,7 +195,7 @@ export function addMinutes(date, minutes) {
|
|||
export function createImportedCluster(baseUrl, cookies, name) {
|
||||
let response
|
||||
|
||||
const userId = getUserId(baseUrl, cookies)
|
||||
const userId = getCurrentUserId(baseUrl, cookies)
|
||||
const userPreferences = getUserPreferences(baseUrl, cookies);
|
||||
|
||||
userPreferences["last-visited"] = "{\"name\":\"c-cluster-product\",\"params\":{\"cluster\":\"_\",\"product\":\"manager\"}}"
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ function cleanup(cookies) {
|
|||
// Test functions, in order of execution
|
||||
export function setup() {
|
||||
// log in
|
||||
if (!login(baseUrl, {}, username, password)) {
|
||||
if (login(baseUrl, {}, username, password).status !== 200) {
|
||||
fail(`could not login into cluster`)
|
||||
}
|
||||
const cookies = getCookies(baseUrl)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ function cleanup(cookies) {
|
|||
// Test functions, in order of execution
|
||||
export function setup() {
|
||||
// log in
|
||||
if (!login(baseUrl, {}, username, password)) {
|
||||
if (login(baseUrl, {}, username, password).status !== 200) {
|
||||
fail(`could not login into cluster`)
|
||||
}
|
||||
const cookies = getCookies(baseUrl)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export const options = {
|
|||
|
||||
export function setup() {
|
||||
// log in
|
||||
if (!login(baseUrl, {}, username, password)) {
|
||||
if (login(baseUrl, {}, username, password).status !== 200) {
|
||||
fail(`could not login into cluster`)
|
||||
}
|
||||
const cookies = getCookies(baseUrl)
|
||||
|
|
|
|||
Loading…
Reference in New Issue