Skip to content

Commit 5f50318

Browse files
committed
feat: remove default withCredentials false as it is the default
1 parent a5634ad commit 5f50318

File tree

8 files changed

+27
-73
lines changed

8 files changed

+27
-73
lines changed

src/core/infra/repositories/apiConfigBuilders.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const buildRequestConfig = (
1313
headers: {
1414
'Content-Type': contentType
1515
},
16-
withCredentials: false,
1716
...(abortSignal && { signal: abortSignal })
1817
}
1918

@@ -48,7 +47,6 @@ export const buildRequestConfig = (
4847
if (token) {
4948
requestConfig.headers.Authorization = `Bearer ${token}`
5049
}
51-
requestConfig.withCredentials = false
5250
break
5351
}
5452
}

test/testHelpers/TestConstants.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,21 @@ export class TestConstants {
1717
headers: {
1818
'Content-Type': 'application/json',
1919
'X-Dataverse-Key': TestConstants.TEST_DUMMY_API_KEY
20-
},
21-
withCredentials: false
20+
}
2221
}
2322
static readonly TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY_INCLUDE_DEACCESSIONED = {
2423
params: { includeDeaccessioned: true },
2524
headers: {
2625
'Content-Type': 'application/json',
2726
'X-Dataverse-Key': TestConstants.TEST_DUMMY_API_KEY
28-
},
29-
withCredentials: false
27+
}
3028
}
3129
static readonly TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_SESSION_COOKIE = {
32-
withCredentials: true,
3330
params: {},
3431
headers: {
3532
'Content-Type': 'application/json'
36-
}
33+
},
34+
withCredentials: true
3735
}
3836
static readonly TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_SESSION_COOKIE_INCLUDE_DEACCESSIONED =
3937
{
@@ -47,16 +45,14 @@ export class TestConstants {
4745
params: {},
4846
headers: {
4947
'Content-Type': 'application/json'
50-
},
51-
withCredentials: false
48+
}
5249
}
5350
static readonly TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_BEARER_TOKEN = {
5451
params: {},
5552
headers: {
5653
Authorization: `Bearer ${TestConstants.TEST_DUMMY_BEARER_TOKEN}`,
5754
'Content-Type': 'application/json'
58-
},
59-
withCredentials: false
55+
}
6056
}
6157

6258
static readonly TEST_DUMMY_COLLECTION_ID = 10001

test/unit/auth/BearerTokenMechanism.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ describe('BearerTokenMechanism', () => {
4747
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_BEARER_TOKEN.headers,
4848
params: {
4949
returnOwners: true
50-
},
51-
withCredentials:
52-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_BEARER_TOKEN.withCredentials
50+
}
5351
}
5452

5553
jest.spyOn(axios, 'get').mockResolvedValue(testCollectionSuccessfulResponse)

test/unit/collections/CollectionsRepository.test.ts

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

6563
describe('by numeric id', () => {
@@ -264,9 +262,7 @@ describe('CollectionsRepository', () => {
264262
params: {
265263
returnDetails: true
266264
},
267-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
268-
withCredentials:
269-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
265+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
270266
}
271267

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

400396
const expectedRequestConfigApiKey = {
401397
params: expectedRequestParams,
402-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
403-
withCredentials:
404-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
398+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
405399
}
406400

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

445439
const expectedRequestConfigApiKeyWithPagination = {
446440
params: expectedRequestParamsWithPagination,
447-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
448-
withCredentials:
449-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
441+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
450442
}
451443

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

490482
const expectedRequestConfigApiKeyWithCollectionId = {
491483
params: expectedRequestParamsWithCollectionId,
492-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
493-
withCredentials:
494-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
484+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
495485
}
496486

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

532522
const expectedRequestConfigApiKey = {
533523
params: expectedRequestParams,
534-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
535-
withCredentials:
536-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
524+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
537525
}
538526

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

test/unit/datasets/DatasetsRepository.test.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ describe('DatasetsRepository', () => {
103103
excludeFiles: true,
104104
returnOwners: true
105105
},
106-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
107-
withCredentials:
108-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
106+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
109107
}
110108
const expectedRequestConfigSessionCookie = {
111109
params: {
@@ -292,8 +290,7 @@ describe('DatasetsRepository', () => {
292290
describe('getPrivateUrlDataset', () => {
293291
const expectedRequestConfig = {
294292
params: { returnOwners: true },
295-
headers: TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG.headers,
296-
withCredentials: TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG.withCredentials
293+
headers: TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG.headers
297294
}
298295
test('should return Dataset when response is successful', async () => {
299296
jest.spyOn(axios, 'get').mockResolvedValue(testDatasetVersionSuccessfulResponse)
@@ -644,9 +641,7 @@ describe('DatasetsRepository', () => {
644641

645642
const expectedRequestConfigApiKeyWithPagination = {
646643
params: expectedRequestParamsWithPagination,
647-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
648-
withCredentials:
649-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
644+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
650645
}
651646

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

689684
const expectedRequestConfigApiKeyWithCollectionId = {
690685
params: expectedRequestParamsWithCollectionId,
691-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
692-
withCredentials:
693-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
686+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
694687
}
695688

696689
expect(axios.get).toHaveBeenCalledWith(

test/unit/files/DirectUploadClient.test.ts

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

test/unit/files/FilesRepository.test.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ describe('FilesRepository', () => {
7070
params: {
7171
size: testFileSize
7272
},
73-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
74-
withCredentials:
75-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
73+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
7674
}
7775
const expectedRequestConfigSessionCookie = {
7876
params: {
@@ -245,9 +243,7 @@ describe('FilesRepository', () => {
245243
includeDeaccessioned: testIncludeDeaccessioned,
246244
orderCriteria: testFileOrderCriteria
247245
},
248-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
249-
withCredentials:
250-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
246+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
251247
}
252248
const expectedRequestConfigSessionCookie = {
253249
params: {
@@ -272,9 +268,7 @@ describe('FilesRepository', () => {
272268

273269
const expectedRequestConfigApiKeyWithOptional = {
274270
params: expectedRequestParamsWithOptional,
275-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
276-
withCredentials:
277-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
271+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
278272
}
279273

280274
const expectedFiles = createFilesSubsetModel(testTotalCount)
@@ -434,9 +428,7 @@ describe('FilesRepository', () => {
434428

435429
const expectedRequestConfigApiKey = {
436430
params: { includeDeaccessioned: testIncludeDeaccessioned },
437-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
438-
withCredentials:
439-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
431+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
440432
}
441433
const expectedRequestConfigSessionCookie = {
442434
params: { includeDeaccessioned: testIncludeDeaccessioned },
@@ -455,9 +447,7 @@ describe('FilesRepository', () => {
455447

456448
const expectedRequestConfigApiKeyWithOptional = {
457449
params: expectedRequestParamsWithOptional,
458-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
459-
withCredentials:
460-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
450+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
461451
}
462452

463453
const expectedCount = createFileCountsModel()
@@ -589,9 +579,7 @@ describe('FilesRepository', () => {
589579
mode: FileDownloadSizeMode.ARCHIVAL.toString(),
590580
includeDeaccessioned: testIncludeDeaccessioned
591581
},
592-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
593-
withCredentials:
594-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
582+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
595583
}
596584
const expectedRequestConfigSessionCookie = {
597585
params: {
@@ -611,9 +599,7 @@ describe('FilesRepository', () => {
611599
categoryName: testFileCriteria.categoryName,
612600
tabularTagName: testFileCriteria.tabularTagName
613601
},
614-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
615-
withCredentials:
616-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
602+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
617603
}
618604
const expectedApiEndpoint = `${TestConstants.TEST_API_URL}/datasets/${testDatasetId}/versions/${testDatasetVersionId}/downloadsize`
619605

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

10371023
const expectedRequestConfigApiKey = {
10381024
params: expectedRequestParams,
1039-
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers,
1040-
withCredentials:
1041-
TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.withCredentials
1025+
headers: TestConstants.TEST_EXPECTED_AUTHENTICATED_REQUEST_CONFIG_API_KEY.headers
10421026
}
10431027

10441028
const expectedRequestConfigSessionCookie = {

test/unit/metadataBlocks/MetadataBlocksRepository.test.ts

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

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

0 commit comments

Comments
 (0)