test: add load test for session creation (#8088)

# Which Problems Are Solved

Extends load tests by testing session creation.

# How the Problems Are Solved

The test creates a session including a check for user id.

# Additional Context

- part of https://github.com/zitadel/zitadel/issues/7639
This commit is contained in:
Silvan
2024-07-09 17:16:50 +02:00
committed by GitHub
parent 23bebc7e30
commit 82d950019f
7 changed files with 205 additions and 1 deletions

View File

@@ -72,3 +72,35 @@ export function introspect(jwt: string, token: string) {
introspectTrend.add(res.timings.duration);
}
const clientCredentialsTrend = new Trend('oidc_client_credentials_duration', true);
export function clientCredentials(clientId: string, clientSecret: string): Promise<Tokens> {
return new Promise((resolve, reject) => {
const response = http.asyncRequest('POST', configuration().token_endpoint,
{
grant_type: "client_credentials",
scope: 'openid profile urn:zitadel:iam:org:project:id:zitadel:aud',
client_id: clientId,
client_secret: clientSecret,
},
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
},
);
response.then((res) => {
check(res, {
'client credentials status ok': (r) => r.status === 200,
}) || reject(`client credentials request failed (client id: ${clientId}) status: ${res.status} body: ${res.body}`);
clientCredentialsTrend.add(res.timings.duration);
const tokens = new Tokens(res.json() as JSONObject)
check(tokens, {
'client credentials token ok': (t) => t.accessToken !== undefined,
}) || reject(`client credentials access token missing (client id: ${clientId}`);
resolve(tokens)
});
});
}