File size: 578 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import http from 'k6/http'

const TEST_USER = 'admin'
const TEST_PASS = 'admin123'

// login will return the session token
export function login(
  user = TEST_USER,
  pass = TEST_PASS,
  host = 'http://localhost:3030',
): string {
  const res = http.post(
    host + '/api/v2/identity/providers/basic?noRedirect=1',
    {
      username: user,
      password: pass,
    },
    {
      headers: {
        referer: host,
      },
    },
  )

  if (res.status !== 200) {
    throw new Error(`Unexpected status code: ${res.status}\n` + res.body)
  }

  return res.body as string
}