@@ -141,7 +141,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
141
141
} ;
142
142
143
143
const response = await request ( server . server )
144
- . post ( `/teams/${ context . testCredentialsUser1TeamId } /cloud-credentials` )
144
+ . post ( `/api/ teams/${ context . testCredentialsUser1TeamId } /cloud-credentials` )
145
145
. set ( 'Cookie' , context . testCredentialsUser1Cookie ! )
146
146
. send ( credentialData ) ;
147
147
@@ -156,7 +156,9 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
156
156
expect ( credential . providerId ) . toBe ( 'aws' ) ;
157
157
expect ( credential . name ) . toBe ( credentialData . name ) ;
158
158
expect ( credential . comment ) . toBe ( credentialData . comment ) ;
159
- expect ( credential . createdBy ) . toBe ( context . testCredentialsUser1Id ) ;
159
+ // Handle both possible response formats for createdBy
160
+ const createdById = typeof credential . createdBy === 'object' ? credential . createdBy . id : credential . createdBy ;
161
+ expect ( createdById ) . toBe ( context . testCredentialsUser1Id ) ;
160
162
161
163
// Verify provider information
162
164
expect ( credential . provider . id ) . toBe ( 'aws' ) ;
@@ -185,7 +187,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
185
187
186
188
// User 2 attempts to list User 1's team credentials
187
189
const response = await request ( server . server )
188
- . get ( `/teams/${ context . testCredentialsUser1TeamId } /cloud-credentials` )
190
+ . get ( `/api/ teams/${ context . testCredentialsUser1TeamId } /cloud-credentials` )
189
191
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! ) ;
190
192
191
193
// Should be forbidden - User 2 is not a member of User 1's team
@@ -199,7 +201,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
199
201
200
202
// User 2 attempts to view User 1's specific credential
201
203
const response = await request ( server . server )
202
- . get ( `/teams/${ context . testCredentialsUser1TeamId } /cloud-credentials/${ context . testCredentialsUser1CredentialId } ` )
204
+ . get ( `/api/ teams/${ context . testCredentialsUser1TeamId } /cloud-credentials/${ context . testCredentialsUser1CredentialId } ` )
203
205
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! ) ;
204
206
205
207
// Should be forbidden - User 2 is not a member of User 1's team
@@ -221,7 +223,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
221
223
222
224
// User 2 attempts to update User 1's credential
223
225
const response = await request ( server . server )
224
- . put ( `/teams/${ context . testCredentialsUser1TeamId } /cloud-credentials/${ context . testCredentialsUser1CredentialId } ` )
226
+ . put ( `/api/ teams/${ context . testCredentialsUser1TeamId } /cloud-credentials/${ context . testCredentialsUser1CredentialId } ` )
225
227
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! )
226
228
. send ( updateData ) ;
227
229
@@ -236,7 +238,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
236
238
237
239
// User 2 attempts to delete User 1's credential
238
240
const response = await request ( server . server )
239
- . delete ( `/teams/${ context . testCredentialsUser1TeamId } /cloud-credentials/${ context . testCredentialsUser1CredentialId } ` )
241
+ . delete ( `/api/ teams/${ context . testCredentialsUser1TeamId } /cloud-credentials/${ context . testCredentialsUser1CredentialId } ` )
240
242
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! ) ;
241
243
242
244
// Should be forbidden - User 2 is not a member of User 1's team
@@ -250,7 +252,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
250
252
251
253
// User 1 verifies their credential still exists and is unchanged
252
254
const response = await request ( server . server )
253
- . get ( `/teams/${ context . testCredentialsUser1TeamId } /cloud-credentials/${ context . testCredentialsUser1CredentialId } ` )
255
+ . get ( `/api/ teams/${ context . testCredentialsUser1TeamId } /cloud-credentials/${ context . testCredentialsUser1CredentialId } ` )
254
256
. set ( 'Cookie' , context . testCredentialsUser1Cookie ! ) ;
255
257
256
258
expect ( response . status ) . toBe ( 200 ) ;
@@ -260,7 +262,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
260
262
const credential = response . body . data ;
261
263
expect ( credential . name ) . toBe ( 'User1 Test Credentials' ) ; // Original name unchanged
262
264
expect ( credential . comment ) . toBe ( 'Test credentials for cross-user permission testing' ) ; // Original comment unchanged
263
- expect ( credential . createdBy ) . toBe ( context . testCredentialsUser1Id ) ;
265
+ expect ( credential . createdBy . id ) . toBe ( context . testCredentialsUser1Id ) ;
264
266
expect ( credential . teamId ) . toBe ( context . testCredentialsUser1TeamId ) ;
265
267
266
268
// Verify fields are still intact
@@ -283,7 +285,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
283
285
} ;
284
286
285
287
const createResponse = await request ( server . server )
286
- . post ( `/teams/${ context . testCredentialsUser2TeamId } /cloud-credentials` )
288
+ . post ( `/api/ teams/${ context . testCredentialsUser2TeamId } /cloud-credentials` )
287
289
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! )
288
290
. send ( credentialData ) ;
289
291
@@ -293,14 +295,16 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
293
295
294
296
const credential = createResponse . body . data ;
295
297
expect ( credential . teamId ) . toBe ( context . testCredentialsUser2TeamId ) ;
296
- expect ( credential . createdBy ) . toBe ( context . testCredentialsUser2Id ) ;
298
+ // Handle both possible response formats for createdBy
299
+ const createdById = typeof credential . createdBy === 'object' ? credential . createdBy . id : credential . createdBy ;
300
+ expect ( createdById ) . toBe ( context . testCredentialsUser2Id ) ;
297
301
expect ( credential . name ) . toBe ( credentialData . name ) ;
298
302
299
303
const user2CredentialId = credential . id ;
300
304
301
305
// User 2 can list their own team's credentials
302
306
const listResponse = await request ( server . server )
303
- . get ( `/teams/${ context . testCredentialsUser2TeamId } /cloud-credentials` )
307
+ . get ( `/api/ teams/${ context . testCredentialsUser2TeamId } /cloud-credentials` )
304
308
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! ) ;
305
309
306
310
expect ( listResponse . status ) . toBe ( 200 ) ;
@@ -310,7 +314,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
310
314
311
315
// User 2 can view their own credential
312
316
const viewResponse = await request ( server . server )
313
- . get ( `/teams/${ context . testCredentialsUser2TeamId } /cloud-credentials/${ user2CredentialId } ` )
317
+ . get ( `/api/ teams/${ context . testCredentialsUser2TeamId } /cloud-credentials/${ user2CredentialId } ` )
314
318
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! ) ;
315
319
316
320
expect ( viewResponse . status ) . toBe ( 200 ) ;
@@ -324,7 +328,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
324
328
} ;
325
329
326
330
const updateResponse = await request ( server . server )
327
- . put ( `/teams/${ context . testCredentialsUser2TeamId } /cloud-credentials/${ user2CredentialId } ` )
331
+ . put ( `/api/ teams/${ context . testCredentialsUser2TeamId } /cloud-credentials/${ user2CredentialId } ` )
328
332
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! )
329
333
. send ( updateData ) ;
330
334
@@ -335,7 +339,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
335
339
336
340
// User 2 can delete their own credential
337
341
const deleteResponse = await request ( server . server )
338
- . delete ( `/teams/${ context . testCredentialsUser2TeamId } /cloud-credentials/${ user2CredentialId } ` )
342
+ . delete ( `/api/ teams/${ context . testCredentialsUser2TeamId } /cloud-credentials/${ user2CredentialId } ` )
339
343
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! ) ;
340
344
341
345
expect ( deleteResponse . status ) . toBe ( 200 ) ;
@@ -348,23 +352,23 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
348
352
349
353
// User 1 should not be able to access User 2's team
350
354
const user1AccessUser2TeamResponse = await request ( server . server )
351
- . get ( `/teams/${ context . testCredentialsUser2TeamId } /cloud-credentials` )
355
+ . get ( `/api/ teams/${ context . testCredentialsUser2TeamId } /cloud-credentials` )
352
356
. set ( 'Cookie' , context . testCredentialsUser1Cookie ! ) ;
353
357
354
358
expect ( user1AccessUser2TeamResponse . status ) . toBe ( 403 ) ;
355
359
expect ( user1AccessUser2TeamResponse . body . success ) . toBe ( false ) ;
356
360
357
361
// User 2 should not be able to access User 1's team
358
362
const user2AccessUser1TeamResponse = await request ( server . server )
359
- . get ( `/teams/${ context . testCredentialsUser1TeamId } /cloud-credentials` )
363
+ . get ( `/api/ teams/${ context . testCredentialsUser1TeamId } /cloud-credentials` )
360
364
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! ) ;
361
365
362
366
expect ( user2AccessUser1TeamResponse . status ) . toBe ( 403 ) ;
363
367
expect ( user2AccessUser1TeamResponse . body . success ) . toBe ( false ) ;
364
368
365
369
// Verify User 1's credential still exists and is accessible only to User 1
366
370
const user1CredentialResponse = await request ( server . server )
367
- . get ( `/teams/${ context . testCredentialsUser1TeamId } /cloud-credentials` )
371
+ . get ( `/api/ teams/${ context . testCredentialsUser1TeamId } /cloud-credentials` )
368
372
. set ( 'Cookie' , context . testCredentialsUser1Cookie ! ) ;
369
373
370
374
expect ( user1CredentialResponse . status ) . toBe ( 200 ) ;
@@ -374,7 +378,7 @@ describe('Cloud Credentials Cross-User Permissions E2E Tests', () => {
374
378
375
379
// Verify User 2's team is empty (they deleted their credential)
376
380
const user2CredentialResponse = await request ( server . server )
377
- . get ( `/teams/${ context . testCredentialsUser2TeamId } /cloud-credentials` )
381
+ . get ( `/api/ teams/${ context . testCredentialsUser2TeamId } /cloud-credentials` )
378
382
. set ( 'Cookie' , context . testCredentialsUser2Cookie ! ) ;
379
383
380
384
expect ( user2CredentialResponse . status ) . toBe ( 200 ) ;
0 commit comments