mirror of
https://github.com/zitadel/zitadel
synced 2024-11-22 00:39:36 +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:
parent
58a7eb1f26
commit
15c9f71bee
@ -42,6 +42,12 @@ machine_jwt_profile_grant: ensure_modules ensure_key_pair bundle
|
||||
cd ../../xk6-modules && xk6 build --with xk6-zitadel=.
|
||||
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/machine_jwt_profile_grant.js --vus ${VUS} --duration ${DURATION}
|
||||
|
||||
.PHONY: machine_jwt_profile_grant_single_user
|
||||
machine_jwt_profile_grant_single_user: ensure_modules ensure_key_pair bundle
|
||||
go install go.k6.io/xk6/cmd/xk6@latest
|
||||
cd ../../xk6-modules && xk6 build --with xk6-zitadel=.
|
||||
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/machine_jwt_profile_grant_single_user.js --vus ${VUS} --duration ${DURATION}
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
npm i
|
||||
|
@ -52,4 +52,7 @@ Before you run the tests you need an initialized user. The tests don't implement
|
||||
test: creates new sessions with user id check
|
||||
* `make machine_jwt_profile_grant`
|
||||
setup: generates private/public key, creates machine users, adds a key
|
||||
test: creates a token and calls user info
|
||||
test: creates a token and calls user info
|
||||
* `make machine_jwt_profile_grant_single_user`
|
||||
setup: generates private/public key, creates machine user, adds a key
|
||||
test: creates a token and calls user info in parallel for the same user
|
@ -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');
|
||||
}
|
Loading…
Reference in New Issue
Block a user