Skip to content

Commit 045ca23

Browse files
committed
test: add withCredentials: false to all expected requests configs non bearer token
1 parent 3bdd0c6 commit 045ca23

File tree

5 files changed

+60
-22
lines changed

5 files changed

+60
-22
lines changed

test/unit/collections/CollectionsRepository.test.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ describe('CollectionsRepository', () => {
5757
params: {
5858
returnOwners: true
5959
},
60-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
60+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
61+
withCredentials:
62+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
6163
}
6264

6365
describe('by numeric id', () => {
@@ -262,7 +264,9 @@ describe('CollectionsRepository', () => {
262264
params: {
263265
returnDetails: true
264266
},
265-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
267+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
268+
withCredentials:
269+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
266270
}
267271

268272
test('should return facets when providing a valid id', async () => {
@@ -395,7 +399,9 @@ describe('CollectionsRepository', () => {
395399

396400
const expectedRequestConfigApiKey = {
397401
params: expectedRequestParams,
398-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
402+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
403+
withCredentials:
404+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
399405
}
400406

401407
expect(axios.get).toHaveBeenCalledWith(expectedApiEndpoint, expectedRequestConfigApiKey)
@@ -438,7 +444,9 @@ describe('CollectionsRepository', () => {
438444

439445
const expectedRequestConfigApiKeyWithPagination = {
440446
params: expectedRequestParamsWithPagination,
441-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
447+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
448+
withCredentials:
449+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
442450
}
443451

444452
expect(axios.get).toHaveBeenCalledWith(
@@ -481,7 +489,9 @@ describe('CollectionsRepository', () => {
481489

482490
const expectedRequestConfigApiKeyWithCollectionId = {
483491
params: expectedRequestParamsWithCollectionId,
484-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
492+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
493+
withCredentials:
494+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
485495
}
486496

487497
expect(axios.get).toHaveBeenCalledWith(
@@ -521,7 +531,9 @@ describe('CollectionsRepository', () => {
521531

522532
const expectedRequestConfigApiKey = {
523533
params: expectedRequestParams,
524-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
534+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
535+
withCredentials:
536+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
525537
}
526538

527539
expect(axios.get).toHaveBeenCalledWith(expectedApiEndpoint, expectedRequestConfigApiKey)

test/unit/datasets/DatasetsRepository.test.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ describe('DatasetsRepository', () => {
103103
excludeFiles: true,
104104
returnOwners: true
105105
},
106-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
106+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
107+
withCredentials:
108+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
107109
}
108110
const expectedRequestConfigSessionCookie = {
109111
params: {
@@ -290,7 +292,8 @@ describe('DatasetsRepository', () => {
290292
describe('getPrivateUrlDataset', () => {
291293
const expectedRequestConfig = {
292294
params: { returnOwners: true },
293-
headers: TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG.headers
295+
headers: TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG.headers,
296+
withCredentials: TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG.withCredentials
294297
}
295298
test('should return Dataset when response is successful', async () => {
296299
jest.spyOn(axios, 'get').mockResolvedValue(testDatasetVersionSuccessfulResponse)
@@ -641,7 +644,9 @@ describe('DatasetsRepository', () => {
641644

642645
const expectedRequestConfigApiKeyWithPagination = {
643646
params: expectedRequestParamsWithPagination,
644-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
647+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
648+
withCredentials:
649+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
645650
}
646651

647652
expect(axios.get).toHaveBeenCalledWith(
@@ -683,7 +688,9 @@ describe('DatasetsRepository', () => {
683688

684689
const expectedRequestConfigApiKeyWithCollectionId = {
685690
params: expectedRequestParamsWithCollectionId,
686-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
691+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
692+
withCredentials:
693+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
687694
}
688695

689696
expect(axios.get).toHaveBeenCalledWith(

test/unit/files/DirectUploadClient.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ describe('uploadFile', () => {
126126
`${ApiConfig.dataverseApiUrl}/datasets/mpupload/testAbort`,
127127
{
128128
headers: { 'Content-Type': 'application/json', 'X-Dataverse-Key': 'dummyApiKey' },
129-
params: {}
129+
params: {},
130+
withCredentials: false
130131
}
131132
)
132133
})

test/unit/files/FilesRepository.test.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ describe('FilesRepository', () => {
7070
params: {
7171
size: testFileSize
7272
},
73-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
73+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
74+
withCredentials:
75+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
7476
}
7577
const expectedRequestConfigSessionCookie = {
7678
params: {
@@ -243,7 +245,9 @@ describe('FilesRepository', () => {
243245
includeDeaccessioned: testIncludeDeaccessioned,
244246
orderCriteria: testFileOrderCriteria
245247
},
246-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
248+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
249+
withCredentials:
250+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
247251
}
248252
const expectedRequestConfigSessionCookie = {
249253
params: {
@@ -268,7 +272,9 @@ describe('FilesRepository', () => {
268272

269273
const expectedRequestConfigApiKeyWithOptional = {
270274
params: expectedRequestParamsWithOptional,
271-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
275+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
276+
withCredentials:
277+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
272278
}
273279

274280
const expectedFiles = createFilesSubsetModel(testTotalCount)
@@ -428,13 +434,15 @@ describe('FilesRepository', () => {
428434

429435
const expectedRequestConfigApiKey = {
430436
params: { includeDeaccessioned: testIncludeDeaccessioned },
431-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
437+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
438+
withCredentials:
439+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
432440
}
433441
const expectedRequestConfigSessionCookie = {
434442
params: { includeDeaccessioned: testIncludeDeaccessioned },
443+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_SESSION_COOKIE.headers,
435444
withCredentials:
436-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_SESSION_COOKIE.withCredentials,
437-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_SESSION_COOKIE.headers
445+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_SESSION_COOKIE.withCredentials
438446
}
439447

440448
const expectedRequestParamsWithOptional = {
@@ -447,7 +455,9 @@ describe('FilesRepository', () => {
447455

448456
const expectedRequestConfigApiKeyWithOptional = {
449457
params: expectedRequestParamsWithOptional,
450-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
458+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
459+
withCredentials:
460+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
451461
}
452462

453463
const expectedCount = createFileCountsModel()
@@ -579,7 +589,9 @@ describe('FilesRepository', () => {
579589
mode: FileDownloadSizeMode.ARCHIVAL.toString(),
580590
includeDeaccessioned: testIncludeDeaccessioned
581591
},
582-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
592+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
593+
withCredentials:
594+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
583595
}
584596
const expectedRequestConfigSessionCookie = {
585597
params: {
@@ -599,7 +611,9 @@ describe('FilesRepository', () => {
599611
categoryName: testFileCriteria.categoryName,
600612
tabularTagName: testFileCriteria.tabularTagName
601613
},
602-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
614+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
615+
withCredentials:
616+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
603617
}
604618
const expectedApiEndpoint = `${TestConstants.TEST_API_URL}/datasets/${testDatasetId}/versions/${testDatasetVersionId}/downloadsize`
605619

@@ -1022,7 +1036,9 @@ describe('FilesRepository', () => {
10221036

10231037
const expectedRequestConfigApiKey = {
10241038
params: expectedRequestParams,
1025-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
1039+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
1040+
withCredentials:
1041+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
10261042
}
10271043

10281044
const expectedRequestConfigSessionCookie = {

test/unit/metadataBlocks/MetadataBlocksRepository.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ describe('MetadataBlocksRepository', () => {
2929
params: {
3030
onlyDisplayedOnCreate: true,
3131
returnDatasetFieldTypes: true
32-
}
32+
},
33+
withCredentials:
34+
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
3335
}
3436

3537
test('should return collection metadata blocks on successful response', async () => {

0 commit comments

Comments
 (0)