@better-auth/test-utils 1.7.0-rc.2 → 1.7.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -230,7 +230,7 @@ const createTestSuite = (suiteName, config, tests) => {
230
230
  createdAt: randomDate,
231
231
  updatedAt: /* @__PURE__ */ new Date(),
232
232
  issuer: createLocalAccountIssuer("test"),
233
- providerAccountId: generateId(),
233
+ accountId: generateId(),
234
234
  providerId: "test",
235
235
  userId: generateId(),
236
236
  accessToken: generateId(),
@@ -57,7 +57,7 @@ const getNormalTestSuiteTests = ({ adapter, generate, insertRandom, modifyBetter
57
57
  userId: firstUser.id,
58
58
  providerId: "issuer-key-first-alias",
59
59
  issuer: "https://issuer-key.example.com",
60
- providerAccountId: "shared-subject"
60
+ accountId: "shared-subject"
61
61
  };
62
62
  await adapter.create({
63
63
  model: "account",
@@ -71,7 +71,7 @@ const getNormalTestSuiteTests = ({ adapter, generate, insertRandom, modifyBetter
71
71
  userId: secondUser.id,
72
72
  providerId: "issuer-key-second-alias",
73
73
  issuer: firstAccount.issuer,
74
- providerAccountId: firstAccount.providerAccountId
74
+ accountId: firstAccount.accountId
75
75
  },
76
76
  forceAllowId: true
77
77
  })).rejects.toThrow();
@@ -82,12 +82,12 @@ const getNormalTestSuiteTests = ({ adapter, generate, insertRandom, modifyBetter
82
82
  userId: secondUser.id,
83
83
  providerId: "issuer-key-other-issuer",
84
84
  issuer: "https://other-issuer-key.example.com",
85
- providerAccountId: firstAccount.providerAccountId
85
+ accountId: firstAccount.accountId
86
86
  },
87
87
  forceAllowId: true
88
88
  })).resolves.toMatchObject({
89
89
  issuer: "https://other-issuer-key.example.com",
90
- providerAccountId: "shared-subject"
90
+ accountId: "shared-subject"
91
91
  });
92
92
  },
93
93
  "create - should use generateId if provided": async () => {
package/dist/scim.mjs CHANGED
@@ -158,7 +158,7 @@ async function runSCIMLifecycle(options) {
158
158
  displayName: "Ada Byron",
159
159
  active: true
160
160
  });
161
- await expectSCIMNoContent(await request(`/Users/${encodeURIComponent(createdUser.id)}`, {
161
+ const unchangedUserPatchResponse = await request(`/Users/${encodeURIComponent(createdUser.id)}`, {
162
162
  method: "PATCH",
163
163
  body: {
164
164
  schemas: [SCIM_PATCH_SCHEMA],
@@ -168,7 +168,12 @@ async function runSCIMLifecycle(options) {
168
168
  value: "Ada Byron"
169
169
  }]
170
170
  }
171
- }));
171
+ });
172
+ expectSCIMResponse(unchangedUserPatchResponse, 200);
173
+ expect(await readJson(unchangedUserPatchResponse)).toMatchObject({
174
+ id: createdUser.id,
175
+ displayName: "Ada Byron"
176
+ });
172
177
  const unchangedUserResponse = await request(`/Users/${encodeURIComponent(createdUser.id)}`);
173
178
  expectSCIMResponse(unchangedUserResponse, 200);
174
179
  expect(await readJson(unchangedUserResponse)).toEqual(replacedUser);
@@ -221,7 +226,9 @@ async function runSCIMLifecycle(options) {
221
226
  expect((await readJson(groupAfterFailedAddResponse)).members).toEqual([]);
222
227
  await checkpoint("failed-add-rolled-back");
223
228
  }
224
- await expectSCIMNoContent(await addMember());
229
+ const addMemberResponse = await addMember();
230
+ expectSCIMResponse(addMemberResponse, 200);
231
+ expect((await readJson(addMemberResponse)).members).toEqual([expect.objectContaining({ value: createdUser.id })]);
225
232
  const groupWithMemberResponse = await request(`/Groups/${encodeURIComponent(createdGroup.id)}`);
226
233
  expectSCIMResponse(groupWithMemberResponse, 200);
227
234
  expect((await readJson(groupWithMemberResponse)).members).toEqual([expect.objectContaining({
@@ -230,7 +237,7 @@ async function runSCIMLifecycle(options) {
230
237
  $ref: userLocation
231
238
  })]);
232
239
  await checkpoint("member-added");
233
- await expectSCIMNoContent(await request(`/Groups/${encodeURIComponent(createdGroup.id)}`, {
240
+ const oktaRemovalResponse = await request(`/Groups/${encodeURIComponent(createdGroup.id)}`, {
234
241
  method: "PATCH",
235
242
  body: {
236
243
  schemas: [SCIM_PATCH_SCHEMA],
@@ -239,12 +246,14 @@ async function runSCIMLifecycle(options) {
239
246
  path: `members[value eq "${createdUser.id}"]`
240
247
  }]
241
248
  }
242
- }));
249
+ });
250
+ expectSCIMResponse(oktaRemovalResponse, 200);
251
+ expect((await readJson(oktaRemovalResponse)).members).toEqual([]);
243
252
  const groupAfterOktaRemovalResponse = await request(`/Groups/${encodeURIComponent(createdGroup.id)}`);
244
253
  expectSCIMResponse(groupAfterOktaRemovalResponse, 200);
245
254
  expect((await readJson(groupAfterOktaRemovalResponse)).members).toEqual([]);
246
255
  await checkpoint("okta-member-removed");
247
- await expectSCIMNoContent(await request(`/Groups/${encodeURIComponent(createdGroup.id)}`, {
256
+ const secondAddResponse = await request(`/Groups/${encodeURIComponent(createdGroup.id)}`, {
248
257
  method: "PATCH",
249
258
  body: {
250
259
  schemas: [SCIM_PATCH_SCHEMA],
@@ -254,8 +263,10 @@ async function runSCIMLifecycle(options) {
254
263
  value: [{ value: createdUser.id }]
255
264
  }]
256
265
  }
257
- }));
258
- await expectSCIMNoContent(await request(`/Groups/${encodeURIComponent(createdGroup.id)}`, {
266
+ });
267
+ expectSCIMResponse(secondAddResponse, 200);
268
+ expect((await readJson(secondAddResponse)).members).toEqual([expect.objectContaining({ value: createdUser.id })]);
269
+ const entraRemovalResponse = await request(`/Groups/${encodeURIComponent(createdGroup.id)}`, {
259
270
  method: "PATCH",
260
271
  body: {
261
272
  schemas: [SCIM_PATCH_SCHEMA],
@@ -265,12 +276,14 @@ async function runSCIMLifecycle(options) {
265
276
  value: [{ value: createdUser.id }]
266
277
  }]
267
278
  }
268
- }));
279
+ });
280
+ expectSCIMResponse(entraRemovalResponse, 200);
281
+ expect((await readJson(entraRemovalResponse)).members).toEqual([]);
269
282
  const groupAfterEntraRemovalResponse = await request(`/Groups/${encodeURIComponent(createdGroup.id)}`);
270
283
  expectSCIMResponse(groupAfterEntraRemovalResponse, 200);
271
284
  expect((await readJson(groupAfterEntraRemovalResponse)).members).toEqual([]);
272
285
  await checkpoint("entra-member-removed");
273
- await expectSCIMNoContent(await addMember());
286
+ expectSCIMResponse(await addMember(), 200);
274
287
  const restoredGroupResponse = await request(`/Groups/${encodeURIComponent(createdGroup.id)}`);
275
288
  expectSCIMResponse(restoredGroupResponse, 200);
276
289
  expect((await readJson(restoredGroupResponse)).members).toEqual([expect.objectContaining({
@@ -278,7 +291,7 @@ async function runSCIMLifecycle(options) {
278
291
  $ref: userLocation
279
292
  })]);
280
293
  await checkpoint("member-restored");
281
- await expectSCIMNoContent(await request(`/Users/${encodeURIComponent(createdUser.id)}`, {
294
+ const deactivateUserResponse = await request(`/Users/${encodeURIComponent(createdUser.id)}`, {
282
295
  method: "PATCH",
283
296
  body: {
284
297
  schemas: [SCIM_PATCH_SCHEMA],
@@ -288,7 +301,12 @@ async function runSCIMLifecycle(options) {
288
301
  value: false
289
302
  }]
290
303
  }
291
- }));
304
+ });
305
+ expectSCIMResponse(deactivateUserResponse, 200);
306
+ expect(await readJson(deactivateUserResponse)).toMatchObject({
307
+ id: createdUser.id,
308
+ active: false
309
+ });
292
310
  const inactiveUserResponse = await request(`/Users/${encodeURIComponent(createdUser.id)}`);
293
311
  expectSCIMResponse(inactiveUserResponse, 200);
294
312
  expect(await readJson(inactiveUserResponse)).toMatchObject({
@@ -299,7 +317,7 @@ async function runSCIMLifecycle(options) {
299
317
  expectSCIMResponse(groupWithInactiveMemberResponse, 200);
300
318
  expect((await readJson(groupWithInactiveMemberResponse)).members).toEqual([expect.objectContaining({ value: createdUser.id })]);
301
319
  await checkpoint("user-deactivated");
302
- await expectSCIMNoContent(await request(`/Users/${encodeURIComponent(createdUser.id)}`, {
320
+ const reactivateUserResponse = await request(`/Users/${encodeURIComponent(createdUser.id)}`, {
303
321
  method: "PATCH",
304
322
  body: {
305
323
  schemas: [SCIM_PATCH_SCHEMA],
@@ -309,7 +327,12 @@ async function runSCIMLifecycle(options) {
309
327
  value: true
310
328
  }]
311
329
  }
312
- }));
330
+ });
331
+ expectSCIMResponse(reactivateUserResponse, 200);
332
+ expect(await readJson(reactivateUserResponse)).toMatchObject({
333
+ id: createdUser.id,
334
+ active: true
335
+ });
313
336
  const activeUserResponse = await request(`/Users/${encodeURIComponent(createdUser.id)}`);
314
337
  expectSCIMResponse(activeUserResponse, 200);
315
338
  expect(await readJson(activeUserResponse)).toMatchObject({
@@ -345,7 +368,7 @@ async function runSCIMLifecycle(options) {
345
368
  expect(reprovisionedUser.meta.location).toBe(reprovisionedUserLocation);
346
369
  expect(reprovisionResponse.headers.get("location")).toBe(reprovisionedUserLocation);
347
370
  await checkpoint("user-reprovisioned");
348
- await expectSCIMNoContent(await request(`/Groups/${encodeURIComponent(createdGroup.id)}`, {
371
+ expectSCIMResponse(await request(`/Groups/${encodeURIComponent(createdGroup.id)}`, {
349
372
  method: "PATCH",
350
373
  body: {
351
374
  schemas: [SCIM_PATCH_SCHEMA],
@@ -355,7 +378,7 @@ async function runSCIMLifecycle(options) {
355
378
  value: [{ value: reprovisionedUser.id }]
356
379
  }]
357
380
  }
358
- }));
381
+ }), 200);
359
382
  const groupWithReprovisionedMemberResponse = await request(`/Groups/${encodeURIComponent(createdGroup.id)}`);
360
383
  expectSCIMResponse(groupWithReprovisionedMemberResponse, 200);
361
384
  expect((await readJson(groupWithReprovisionedMemberResponse)).members).toEqual([expect.objectContaining({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/test-utils",
3
- "version": "1.7.0-rc.2",
3
+ "version": "1.7.0-rc.4",
4
4
  "description": "Testing utilities for Better Auth adapter development",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,14 +37,14 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "tsdown": "0.22.7",
40
- "vitest": "^4.1.9",
41
- "@better-auth/core": "1.7.0-rc.2",
42
- "better-auth": "1.7.0-rc.2"
40
+ "vitest": "^4.1.10",
41
+ "@better-auth/core": "1.7.0-rc.4",
42
+ "better-auth": "1.7.0-rc.4"
43
43
  },
44
44
  "peerDependencies": {
45
- "vitest": "^4.1.9",
46
- "@better-auth/core": "^1.7.0-rc.2",
47
- "better-auth": "^1.7.0-rc.2"
45
+ "vitest": "^4.1.10",
46
+ "@better-auth/core": "^1.7.0-rc.4",
47
+ "better-auth": "^1.7.0-rc.4"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsdown",