Skip to content

Commit 8007ae0

Browse files
committed
fix(tests): updated the tests to comply with the new connect-rpc changes
1 parent 6797224 commit 8007ae0

File tree

5 files changed

+45
-38
lines changed

5 files changed

+45
-38
lines changed

spec/auth/use-access-token.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('UseAccessTokenSpec', () => {
2424
it('testRetrievesGeneralSettingsWithValidAuth', async () => {
2525
const client = Zitadel.withAccessToken(context.baseUrl, context.authToken);
2626

27-
await client.settings.settingsServiceGetGeneralSettings();
27+
await client.settings.getGeneralSettings({ body: {} });
2828
});
2929

3030
/**
@@ -35,7 +35,7 @@ describe('UseAccessTokenSpec', () => {
3535
const invalid = Zitadel.withAccessToken(context.baseUrl, 'invalid');
3636

3737
await expect(
38-
invalid.settings.settingsServiceGetGeneralSettings(),
38+
invalid.settings.getGeneralSettings({ body: {} }),
3939
).rejects.toThrow(ZitadelException);
4040
}, 120000);
4141
});

spec/auth/use-client-credentials.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe('UseClientCredentialsSpec', () => {
116116
credentials.clientSecret,
117117
);
118118

119-
await client.settings.settingsServiceGetGeneralSettings();
119+
await client.settings.getGeneralSettings({ body: {} });
120120
}, 120000);
121121

122122
/**
@@ -131,7 +131,7 @@ describe('UseClientCredentialsSpec', () => {
131131
);
132132

133133
await expect(
134-
invalid.settings.settingsServiceGetGeneralSettings(),
134+
invalid.settings.getGeneralSettings({ body: {} }),
135135
).rejects.toThrow(ZitadelException);
136136
}, 120000);
137137
});

spec/auth/use-private-key.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('UsePrivateKeySpec', () => {
2727
context.baseUrl,
2828
context.jwtKey,
2929
);
30-
await client.settings.settingsServiceGetGeneralSettings();
30+
await client.settings.getGeneralSettings({ body: {} });
3131
}, 120000);
3232

3333
/**
@@ -40,7 +40,7 @@ describe('UsePrivateKeySpec', () => {
4040
context.jwtKey,
4141
);
4242
await expect(
43-
invalid.settings.settingsServiceGetGeneralSettings(),
43+
invalid.settings.getGeneralSettings({ body: {} }),
4444
).rejects.toThrow(ZitadelException);
4545
}, 120000);
4646
});

spec/session-service-sanity.spec.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import crypto from 'crypto';
22
import Zitadel from '../src/index.js';
33
// noinspection ES6PreferShortImport
4-
import {
5-
SessionServiceChecks,
6-
SessionServiceCheckUser,
7-
} from '../src/models/index.js';
4+
import { SessionServiceChecks, SessionServiceCheckUser, } from '../src/models/index.js';
85
// noinspection ES6PreferShortImport
96
import { ApiException } from '../src/api-exception.js';
107
import { useIntegrationEnvironment } from './base-spec.js';
@@ -39,7 +36,7 @@ describe('SessionServiceSanityCheckSpec', () => {
3936
*/
4037
beforeEach(async () => {
4138
const username = crypto.randomUUID().substring(0, 8);
42-
await client.users.userServiceAddHumanUser({
39+
await client.users.addHumanUser({
4340
userServiceAddHumanUserRequest: {
4441
username: username,
4542
profile: {
@@ -63,15 +60,16 @@ describe('SessionServiceSanityCheckSpec', () => {
6360
},
6461
};
6562

66-
const response = await client.sessions.sessionServiceCreateSession(request);
63+
const response = await client.sessions.createSession(request);
6764
sessionId = response.sessionId || '';
6865
});
6966

7067
afterEach(async () => {
7168
try {
72-
await client.sessions.sessionServiceDeleteSession({
73-
sessionId,
74-
sessionServiceDeleteSessionRequest: {},
69+
await client.sessions.deleteSession({
70+
sessionServiceDeleteSessionRequest: {
71+
sessionId,
72+
},
7573
});
7674
} catch {
7775
// Ignore cleanup errors
@@ -82,8 +80,10 @@ describe('SessionServiceSanityCheckSpec', () => {
8280
* @throws ApiException
8381
*/
8482
it('testRetrievesTheSessionDetailsById', async () => {
85-
const response = await client.sessions.sessionServiceGetSession({
86-
sessionId,
83+
const response = await client.sessions.getSession({
84+
sessionServiceGetSessionRequest: {
85+
sessionId,
86+
},
8787
});
8888
expect(response.session?.id).toBe(sessionId);
8989
});
@@ -97,7 +97,7 @@ describe('SessionServiceSanityCheckSpec', () => {
9797
queries: [],
9898
},
9999
};
100-
const response = await client.sessions.sessionServiceListSessions(request);
100+
const response = await client.sessions.listSessions(request);
101101
const ids = response.sessions?.map((session) => session.id);
102102
expect(ids).toContain(sessionId);
103103
});
@@ -106,9 +106,9 @@ describe('SessionServiceSanityCheckSpec', () => {
106106
* @throws ApiException
107107
*/
108108
it('testUpdatesTheSessionLifetimeAndReturnsANewToken', async () => {
109-
const response = await client.sessions.sessionServiceSetSession({
110-
sessionId: sessionId,
109+
const response = await client.sessions.setSession({
111110
sessionServiceSetSessionRequest: {
111+
sessionId: sessionId,
112112
lifetime: '36000s',
113113
},
114114
});
@@ -118,7 +118,9 @@ describe('SessionServiceSanityCheckSpec', () => {
118118
it('testRaisesAnApiExceptionWhenRetrievingANonExistentSession', async () => {
119119
const nonExistentId = crypto.randomUUID();
120120
await expect(
121-
client.sessions.sessionServiceGetSession({ sessionId: nonExistentId }),
121+
client.sessions.getSession({
122+
sessionServiceGetSessionRequest: { sessionId: nonExistentId },
123+
}),
122124
).rejects.toThrow(ApiException);
123125
});
124126
});

spec/user-service-sanity.spec.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import crypto from 'crypto';
22
import Zitadel from '../src/index.js';
33
// noinspection ES6PreferShortImport
4-
import {
5-
UserServiceAddHumanUserResponse,
6-
UserServiceUser,
7-
} from '../src/models/index.js';
4+
import { UserServiceAddHumanUserResponse, UserServiceUser, } from '../src/models/index.js';
85
// noinspection ES6PreferShortImport
96
import { ApiException } from '../src/api-exception.js';
107
import { useIntegrationEnvironment } from './base-spec.js';
@@ -53,15 +50,17 @@ describe('UserServiceSanityCheckSpec', () => {
5350
},
5451
},
5552
};
56-
user = await client.users.userServiceAddHumanUser(request);
53+
user = await client.users.addHumanUser(request);
5754
});
5855

5956
/**
6057
* Remove the created human user after each test.
6158
*/
6259
afterEach(async () => {
6360
try {
64-
await client.users.userServiceDeleteUser({ userId: user.userId || '' });
61+
await client.users.deleteUser({
62+
userServiceDeleteUserRequest: { userId: user.userId || '' },
63+
});
6564
} catch {
6665
// cleanup errors ignored
6766
}
@@ -73,8 +72,10 @@ describe('UserServiceSanityCheckSpec', () => {
7372
* @throws ApiException on API error
7473
*/
7574
it('testRetrievesTheUserDetailsById', async () => {
76-
const response = await client.users.userServiceGetUserByID({
77-
userId: user.userId || '',
75+
const response = await client.users.getUserByID({
76+
userServiceGetUserByIDRequest: {
77+
userId: user.userId || '',
78+
},
7879
});
7980
expect(response.user?.userId).toBe(user.userId);
8081
});
@@ -90,7 +91,7 @@ describe('UserServiceSanityCheckSpec', () => {
9091
queries: [],
9192
},
9293
};
93-
const response = await client.users.userServiceListUsers(request);
94+
const response = await client.users.listUsers(request);
9495
const userIds = response.result?.map(
9596
(userItem: UserServiceUser) => userItem.userId,
9697
);
@@ -105,17 +106,19 @@ describe('UserServiceSanityCheckSpec', () => {
105106
it('testUpdatesTheUserEmailAndReflectsInGet', async () => {
106107
const newEmail = `updated_${crypto.randomUUID().substring(0, 8)}@example.com`;
107108

108-
await client.users.userServiceUpdateHumanUser({
109-
userId: user.userId || '',
110-
userServiceUpdateHumanUserRequest: {
111-
email: {
112-
email: newEmail,
109+
await client.users.updateUser({
110+
userServiceUpdateUserRequest: {
111+
userId: user.userId || '',
112+
human: {
113+
email: { email: newEmail },
113114
},
114115
},
115116
});
116117

117-
const response = await client.users.userServiceGetUserByID({
118-
userId: user.userId || '',
118+
const response = await client.users.getUserByID({
119+
userServiceGetUserByIDRequest: {
120+
userId: user.userId || '',
121+
},
119122
});
120123
expect(response.user?.human?.email?.email).toContain('updated');
121124
});
@@ -126,7 +129,9 @@ describe('UserServiceSanityCheckSpec', () => {
126129
it('testRaisesAnApiExceptionWhenRetrievingNonExistentUser', async () => {
127130
const nonExistentId = crypto.randomUUID();
128131
await expect(
129-
client.users.userServiceGetUserByID({ userId: nonExistentId }),
132+
client.users.getUserByID({
133+
userServiceGetUserByIDRequest: { userId: nonExistentId },
134+
}),
130135
).rejects.toThrow(ApiException);
131136
});
132137
});

0 commit comments

Comments
 (0)