mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 04:37:31 +00:00
test(load): add machine jwt profile test for a single user (#8593)
# How the Problems Are Solved Adds a new load test to use the token endpoint with a single user by multiple threads.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { loginByUsernamePassword } from '../login_ui';
|
||||
import { createOrg, removeOrg } from '../org';
|
||||
import {createMachine, User, addMachineKey} from '../user';
|
||||
import {JWTProfileRequest, token, userinfo} from '../oidc';
|
||||
import { Config } from '../config';
|
||||
import encoding from 'k6/encoding';
|
||||
|
||||
const publicKey = encoding.b64encode(open('../.keys/key.pem.pub'));
|
||||
|
||||
export async function setup() {
|
||||
const tokens = loginByUsernamePassword(Config.admin as User);
|
||||
console.info('setup: admin signed in');
|
||||
|
||||
const org = await createOrg(tokens.accessToken!);
|
||||
console.info(`setup: org (${org.organizationId}) created`);
|
||||
|
||||
const machine = await createMachine(`zitachine`, org, tokens.accessToken!);
|
||||
console.info(`setup: machine ${machine.userId} created`);
|
||||
const key = await addMachineKey(machine.userId, org, tokens.accessToken!, publicKey);
|
||||
console.info(`setup: key ${key.keyId} added`);
|
||||
|
||||
return { tokens, machine: {userId: machine.userId, keyId: key.keyId}, org };
|
||||
}
|
||||
|
||||
export default function (data: any) {
|
||||
token(new JWTProfileRequest(data.machine.userId, data.machine.keyId))
|
||||
.then((token) => {
|
||||
userinfo(token.accessToken!)
|
||||
})
|
||||
}
|
||||
|
||||
export function teardown(data: any) {
|
||||
removeOrg(data.org, data.tokens.accessToken);
|
||||
console.info('teardown: org removed');
|
||||
}
|
Reference in New Issue
Block a user