mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-24 05:38:46 +00:00
fix(benchmark): set proper audience to introspect token (#11586)
# Which Problems Are Solved Benchmark appears to run correctly, however the token used isn't valid. The backend (Zitadel 4.11-pre) prints a constant stream of info logs that the token isn't valid for the client. # How the Problems Are Solved Pass the generated project IDs as a scope for a new login. # Additional Changes - ensure keys for introspection and add session recipes. # Additional Context - Closes #11585 --------- Co-authored-by: Silvan <[email protected]>
This commit is contained in:
@@ -1,2 +1,5 @@
|
|||||||
.env
|
.env
|
||||||
|
dist/**
|
||||||
|
.keys/**
|
||||||
|
output/**
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -28,7 +28,7 @@ manipulate_user: bundle
|
|||||||
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/manipulate_user.js --vus ${VUS} --duration ${DURATION} --out csv=output/manipulate_user_${DATE}.csv
|
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/manipulate_user.js --vus ${VUS} --duration ${DURATION} --out csv=output/manipulate_user_${DATE}.csv
|
||||||
|
|
||||||
.PHONY: introspect
|
.PHONY: introspect
|
||||||
introspect: ensure_modules bundle
|
introspect: ensure_key_pair ensure_modules bundle
|
||||||
go install go.k6.io/xk6/cmd/xk6@latest
|
go install go.k6.io/xk6/cmd/xk6@latest
|
||||||
cd ../../xk6-modules && xk6 build --with xk6-zitadel=.
|
cd ../../xk6-modules && xk6 build --with xk6-zitadel=.
|
||||||
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/introspection.js --vus ${VUS} --duration ${DURATION} --out csv=output/introspect_${DATE}.csv
|
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/introspection.js --vus ${VUS} --duration ${DURATION} --out csv=output/introspect_${DATE}.csv
|
||||||
@@ -46,7 +46,7 @@ password_session: ensure_key_pair ensure_modules bundle
|
|||||||
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/password_session.js --vus ${VUS} --duration ${DURATION} --out csv=output/otp_session_${DATE}.csv
|
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/password_session.js --vus ${VUS} --duration ${DURATION} --out csv=output/otp_session_${DATE}.csv
|
||||||
|
|
||||||
.PHONY: add_session
|
.PHONY: add_session
|
||||||
add_session: ensure_modules bundle
|
add_session: ensure_key_pair ensure_modules bundle
|
||||||
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/add_session.js --vus ${VUS} --duration ${DURATION} --out csv=output/add_session_${DATE}.csv
|
${K6} run --summary-trend-stats "min,avg,max,p(50),p(95),p(99)" dist/add_session.js --vus ${VUS} --duration ${DURATION} --out csv=output/add_session_${DATE}.csv
|
||||||
|
|
||||||
.PHONY: machine_jwt_profile_grant
|
.PHONY: machine_jwt_profile_grant
|
||||||
|
|||||||
Generated
+2
-3
@@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "typescript",
|
"name": "@zitadel/benchmark",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "typescript",
|
"name": "@zitadel/benchmark",
|
||||||
"version": "1.0.0",
|
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "7.23.7",
|
"@babel/core": "7.23.7",
|
||||||
|
|||||||
@@ -9,25 +9,25 @@ import url from './url';
|
|||||||
import { User } from './user';
|
import { User } from './user';
|
||||||
import { Tokens } from './oidc';
|
import { Tokens } from './oidc';
|
||||||
|
|
||||||
export function loginByUsernamePassword(user: User) {
|
export function loginByUsernamePassword(user: User, client = Client()) {
|
||||||
check(user, {
|
check(user, {
|
||||||
'user defined': (u) => u !== undefined || fail(`user is undefined`),
|
'user defined': (u) => u !== undefined || fail(`user is undefined`),
|
||||||
});
|
});
|
||||||
|
|
||||||
const loginUI = initLogin();
|
const loginUI = initLogin(undefined, client);
|
||||||
const loginNameResponse = enterLoginName(loginUI, user);
|
const loginNameResponse = enterLoginName(loginUI, user);
|
||||||
const passwordResponse = enterPassword(loginNameResponse, user);
|
const passwordResponse = enterPassword(loginNameResponse, user);
|
||||||
return token(new URL(passwordResponse.url).searchParams.get('code'));
|
return token(new URL(passwordResponse.url).searchParams.get('code'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const initLoginTrend = new Trend('login_ui_init_login_duration', true);
|
const initLoginTrend = new Trend('login_ui_init_login_duration', true);
|
||||||
export function initLogin(clientId?: string): Response {
|
export function initLogin(loginClientId?: string, client = Client()): Response {
|
||||||
let params = {};
|
let params = {};
|
||||||
let expectedStatus = 200;
|
let expectedStatus = 200;
|
||||||
if (clientId) {
|
if (loginClientId) {
|
||||||
params = {
|
params = {
|
||||||
headers: {
|
headers: {
|
||||||
'x-zitadel-login-client': clientId,
|
'x-zitadel-login-client': loginClientId,
|
||||||
},
|
},
|
||||||
redirects: 0,
|
redirects: 0,
|
||||||
};
|
};
|
||||||
@@ -36,7 +36,7 @@ export function initLogin(clientId?: string): Response {
|
|||||||
|
|
||||||
const response = http.get(
|
const response = http.get(
|
||||||
url('/oauth/v2/authorize', {
|
url('/oauth/v2/authorize', {
|
||||||
searchParams: Client(),
|
searchParams: client,
|
||||||
}),
|
}),
|
||||||
params,
|
params,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ export function introspect(jwt: string, token: string) {
|
|||||||
);
|
);
|
||||||
check(res, {
|
check(res, {
|
||||||
'introspect status ok': (r) => r.status >= 200 && r.status < 300,
|
'introspect status ok': (r) => r.status >= 200 && r.status < 300,
|
||||||
|
'introspect active': (r) => r.json('active') === true,
|
||||||
});
|
});
|
||||||
|
|
||||||
introspectTrend.add(res.timings.duration);
|
introspectTrend.add(res.timings.duration);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { createAPI, createAppKey } from '../app';
|
|||||||
import { createProject } from '../project';
|
import { createProject } from '../project';
|
||||||
import { createOrg, removeOrg } from '../org';
|
import { createOrg, removeOrg } from '../org';
|
||||||
import { introspect } from '../oidc';
|
import { introspect } from '../oidc';
|
||||||
import { Config, MaxVUs } from '../config';
|
import { Config, MaxVUs, Client } from '../config';
|
||||||
import { b64decode } from 'k6/encoding';
|
import { b64decode } from 'k6/encoding';
|
||||||
// @ts-ignore Import module
|
// @ts-ignore Import module
|
||||||
import zitadel from 'k6/x/zitadel';
|
import zitadel from 'k6/x/zitadel';
|
||||||
@@ -41,11 +41,18 @@ export async function setup() {
|
|||||||
});
|
});
|
||||||
console.info(`setup: ${tokens.length} tokens generated`);
|
console.info(`setup: ${tokens.length} tokens generated`);
|
||||||
|
|
||||||
return { adminTokens, tokens, org };
|
const client = { ...Client() };
|
||||||
|
client.scope = [client.scope, ...projects.map((p) => `urn:zitadel:iam:org:project:id:${p.id}:aud`)].join(' ');
|
||||||
|
console.info('setup: login user with scope %s', client.scope);
|
||||||
|
|
||||||
|
const userTokens = loginByUsernamePassword(Config.admin as User, client);
|
||||||
|
console.info('setup: user signed in');
|
||||||
|
|
||||||
|
return { adminTokens, userTokens, tokens, org };
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function (data: any) {
|
export default function (data: any) {
|
||||||
introspect(data.tokens[__VU - 1], data.adminTokens.accessToken);
|
introspect(data.tokens[__VU - 1], data.userTokens.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function teardown(data: any) {
|
export function teardown(data: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user