Skip to content

Commit 60250c2

Browse files
chore: rename test helper constants
The integration test APIs include some constants, used for setting request headers, which this commit renames for clarity. Signed-off-by: Andrew Lilley Brinker <abrinker@mitre.org>
1 parent 351a90e commit 60250c2

32 files changed

Lines changed: 280 additions & 280 deletions

test/integration-tests/audit/auditTest.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Testing Audit Org endpoints', () => {
1717
before(async () => {
1818
await chai.request(app)
1919
.get('/api/org/win_5/users')
20-
.set(constants.headers)
20+
.set(constants.secretariatHeaders)
2121
.then((res, err) => {
2222
expect(err).to.be.undefined
2323
expect(res).to.have.status(200)
@@ -42,7 +42,7 @@ describe('Testing Audit Org endpoints', () => {
4242

4343
await chai.request(app)
4444
.post('/api/audit/org/')
45-
.set(constants.headers)
45+
.set(constants.secretariatHeaders)
4646
.send(auditData)
4747
.then((res, err) => {
4848
expect(err).to.be.undefined
@@ -84,7 +84,7 @@ describe('Testing Audit Org endpoints', () => {
8484

8585
await chai.request(app)
8686
.put('/api/audit/org/')
87-
.set(constants.headers)
87+
.set(constants.secretariatHeaders)
8888
.send(appendData)
8989
.then((res, err) => {
9090
expect(err).to.be.undefined
@@ -103,7 +103,7 @@ describe('Testing Audit Org endpoints', () => {
103103
it('Should get all audit documents', async () => {
104104
await chai.request(app)
105105
.get('/api/audit/org/')
106-
.set(constants.headers)
106+
.set(constants.secretariatHeaders)
107107
.then((res, err) => {
108108
expect(err).to.be.undefined
109109
expect(res).to.have.status(200)
@@ -120,7 +120,7 @@ describe('Testing Audit Org endpoints', () => {
120120
it('Should get audit document by UUID', async () => {
121121
await chai.request(app)
122122
.get(`/api/audit/org/document/${testAuditUUID}`)
123-
.set(constants.headers)
123+
.set(constants.secretariatHeaders)
124124
.then((res, err) => {
125125
expect(err).to.be.undefined
126126
expect(res).to.have.status(200)
@@ -138,7 +138,7 @@ describe('Testing Audit Org endpoints', () => {
138138
it('Should get audit history by target UUID', async () => {
139139
await chai.request(app)
140140
.get(`/api/audit/org/${orgUuid}`)
141-
.set(constants.headers)
141+
.set(constants.secretariatHeaders)
142142
.then((res, err) => {
143143
expect(err).to.be.undefined
144144
expect(res).to.have.status(200)
@@ -157,7 +157,7 @@ describe('Testing Audit Org endpoints', () => {
157157

158158
await chai.request(app)
159159
.get(`/api/audit/org/${orgUuid}/${numberOfChanges}`)
160-
.set(constants.headers)
160+
.set(constants.secretariatHeaders)
161161
.then((res, err) => {
162162
expect(err).to.be.undefined
163163
expect(res).to.have.status(200)
@@ -192,7 +192,7 @@ describe('Testing Audit Org endpoints', () => {
192192

193193
await chai.request(app)
194194
.post('/api/audit/org/')
195-
.set(constants.headers)
195+
.set(constants.secretariatHeaders)
196196
.send(auditData)
197197
.then((res, err) => {
198198
expect(err).to.be.undefined
@@ -211,7 +211,7 @@ describe('Testing Audit Org endpoints', () => {
211211

212212
await chai.request(app)
213213
.post('/api/audit/org/')
214-
.set(constants.headers)
214+
.set(constants.secretariatHeaders)
215215
.send(auditData)
216216
.then((res, err) => {
217217
expect(err).to.be.undefined
@@ -229,7 +229,7 @@ describe('Testing Audit Org endpoints', () => {
229229

230230
await chai.request(app)
231231
.post('/api/audit/org/')
232-
.set(constants.headers)
232+
.set(constants.secretariatHeaders)
233233
.send(auditData)
234234
.then((res, err) => {
235235
expect(err).to.be.undefined
@@ -245,7 +245,7 @@ describe('Testing Audit Org endpoints', () => {
245245

246246
await chai.request(app)
247247
.get(`/api/audit/org/document/${fakeUUID}`)
248-
.set(constants.headers)
248+
.set(constants.secretariatHeaders)
249249
.then((res, err) => {
250250
expect(err).to.be.undefined
251251
expect(res).to.have.status(404)
@@ -259,7 +259,7 @@ describe('Testing Audit Org endpoints', () => {
259259
const invalidNumber = -5
260260
await chai.request(app)
261261
.get(`/api/audit/org/${orgUuid}/${invalidNumber}`)
262-
.set(constants.headers)
262+
.set(constants.secretariatHeaders)
263263
.then((res, err) => {
264264
expect(err).to.be.undefined
265265
expect(res).to.have.status(400)
@@ -283,7 +283,7 @@ describe('Testing Audit Org endpoints', () => {
283283

284284
await chai.request(app)
285285
.put('/api/audit/org/')
286-
.set(constants.headers)
286+
.set(constants.secretariatHeaders)
287287
.send(appendData)
288288
.then((res, err) => {
289289
expect(err).to.be.undefined
@@ -303,7 +303,7 @@ describe('Testing Audit Org endpoints', () => {
303303

304304
await chai.request(app)
305305
.post('/api/audit/org/')
306-
.set(constants.headers)
306+
.set(constants.secretariatHeaders)
307307
.send(auditData)
308308
.then((res, err) => {
309309
expect(err).to.be.undefined

test/integration-tests/audit/registryOrgCreatesAuditTest.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const AuditRepo = require('../../../src/repositories/auditRepository')
77
const app = require('../../../src/index.js')
88
const constants = require('../constants.js')
99

10-
const secretariatHeaders = { ...constants.headers }
10+
const secretariatHeaders = { ...constants.secretariatHeaders }
1111
const MAX_SHORTNAME_LENGTH = 32
1212

1313
async function createTestOrg (customProps = {}) {
@@ -47,7 +47,7 @@ describe('Create and Update Audit Collection with Org Endpoints', () => {
4747
// Verify audit was created
4848
const auditRes = await chai.request(app)
4949
.get(`/api/audit/org/${org.uuid}`)
50-
.set(constants.headers)
50+
.set(constants.secretariatHeaders)
5151

5252
expect(auditRes).to.have.status(200)
5353

@@ -83,9 +83,9 @@ describe('Create and Update Audit Collection with Org Endpoints', () => {
8383

8484
// Verify each has its own audit
8585
const audits = await Promise.all([
86-
chai.request(app).get(`/api/audit/org/${org1.uuid}`).set(constants.headers),
87-
chai.request(app).get(`/api/audit/org/${org2.uuid}`).set(constants.headers),
88-
chai.request(app).get(`/api/audit/org/${org3.uuid}`).set(constants.headers)
86+
chai.request(app).get(`/api/audit/org/${org1.uuid}`).set(constants.secretariatHeaders),
87+
chai.request(app).get(`/api/audit/org/${org2.uuid}`).set(constants.secretariatHeaders),
88+
chai.request(app).get(`/api/audit/org/${org3.uuid}`).set(constants.secretariatHeaders)
8989
])
9090

9191
// Each should have its own audit document
@@ -117,7 +117,7 @@ describe('Create and Update Audit Collection with Org Endpoints', () => {
117117
// Check audit history
118118
const auditRes = await chai.request(app)
119119
.get(`/api/audit/org/${org.uuid}`)
120-
.set(constants.headers)
120+
.set(constants.secretariatHeaders)
121121

122122
expect(auditRes.body.history).to.have.lengthOf(1)
123123
})
@@ -138,7 +138,7 @@ describe('Create and Update Audit Collection with Org Endpoints', () => {
138138
// Check audit history
139139
const auditRes = await chai.request(app)
140140
.get(`/api/audit/org/${testOrg.shortName}`)
141-
.set(constants.headers)
141+
.set(constants.secretariatHeaders)
142142

143143
expect(auditRes.body.history).to.have.lengthOf(2)
144144

@@ -172,7 +172,7 @@ describe('Create and Update Audit Collection with Org Endpoints', () => {
172172
// Check audit history
173173
const auditRes = await chai.request(app)
174174
.get(`/api/audit/org/${testOrg.uuid}`)
175-
.set(constants.headers)
175+
.set(constants.secretariatHeaders)
176176

177177
expect(auditRes.body.history).to.have.lengthOf(4)
178178

@@ -199,7 +199,7 @@ describe('Create and Update Audit Collection with Org Endpoints', () => {
199199
// Check audit history
200200
const auditRes = await chai.request(app)
201201
.get(`/api/audit/org/${testOrg.uuid}`)
202-
.set(constants.headers)
202+
.set(constants.secretariatHeaders)
203203
expect(auditRes).to.have.status(404)
204204
// Now update org to trigger audit creation
205205
const updateRes = await chai.request(app)
@@ -209,7 +209,7 @@ describe('Create and Update Audit Collection with Org Endpoints', () => {
209209
// Check audit history
210210
const auditResCreation = await chai.request(app)
211211
.get(`/api/audit/org/${testOrg.uuid}`)
212-
.set(constants.headers)
212+
.set(constants.secretariatHeaders)
213213
// Should have 2 entries: initial creation of current org object + new update
214214
expect(auditResCreation.body.history).to.have.lengthOf(2)
215215
})

test/integration-tests/constants.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
const headers = {
1+
const secretariatHeaders = {
22
'CVE-API-ORG': 'mitre',
33
'content-type': 'application/json',
44
'CVE-API-USER': 'test_secretariat_0@mitre.org',
55
'CVE-API-KEY': 'TCF25YM-39C4H6D-KA32EGF-V5XSHN3'
66
}
77

8-
const nonSecretariatUserHeaders = {
8+
const cnaHeaders = {
99
'CVE-API-ORG': 'win_5',
1010
'CVE-API-Key': 'TCF25YM-39C4H6D-KA32EGF-V5XSHN3',
1111
'CVE-API-USER': 'jasminesmith@win_5.com'
1212
}
1313

14-
const nonSecretariatUserHeaders2 = {
14+
const cnaHeaders2 = {
1515
'CVE-API-ORG': 'win_5',
1616
'CVE-API-Key': 'TCF25YM-39C4H6D-KA32EGF-V5XSHN3',
1717
'CVE-API-USER': 'win_5_admin@win_5.com'
1818
}
1919

20-
const nonSecretariatUserHeaders3 = {
20+
const cnaHeaders3 = {
2121
'CVE-API-ORG': 'evidence_15',
2222
'CVE-API-Key': 'TCF25YM-39C4H6D-KA32EGF-V5XSHN3',
2323
'CVE-API-USER': 'timothymyers@evidence_15.com'
2424
}
2525

26-
const nonSecretariatUserHeadersWithAdp2 = {
26+
const cnaHeadersWithAdp2 = {
2727
'CVE-API-ORG': 'range_4',
2828
'CVE-API-Key': 'TCF25YM-39C4H6D-KA32EGF-V5XSHN3',
2929
'CVE-API-USER': 'scottmitchell@range_4.com'
3030
}
3131

32-
const badNonSecretariatUserHeaders = {
32+
const badCnaHeaders = {
3333
'CVE-API-ORG': 'activity_6',
3434
'CVE-API-Key': 'TCF25YM-39C4H6D-KA32EGF-V5XSHN3',
3535
'CVE-API-USER': 'benjaminsimmons@activity_6.com'
@@ -420,12 +420,12 @@ const existingRegistryOrg = {
420420
}
421421

422422
module.exports = {
423-
headers,
424-
nonSecretariatUserHeaders,
425-
nonSecretariatUserHeaders2,
426-
nonSecretariatUserHeaders3,
427-
badNonSecretariatUserHeaders,
428-
nonSecretariatUserHeadersWithAdp2,
423+
secretariatHeaders,
424+
cnaHeaders,
425+
cnaHeaders2,
426+
cnaHeaders3,
427+
badCnaHeaders,
428+
cnaHeadersWithAdp2,
429429
testCve,
430430
testCveEdited,
431431
enrichedCve,

test/integration-tests/conversation/conversationTest.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('Testing Conversation endpoints', () => {
1515
await chai
1616
.request(app)
1717
.get('/api/org/win_5')
18-
.set(constants.headers)
18+
.set(constants.secretariatHeaders)
1919
.then((res, err) => {
2020
expect(err).to.be.undefined
2121
expect(res).to.have.status(200)
@@ -31,7 +31,7 @@ describe('Testing Conversation endpoints', () => {
3131
}
3232
await chai.request(app)
3333
.post(`/api/conversation/target/${orgUUID}`)
34-
.set(constants.headers)
34+
.set(constants.secretariatHeaders)
3535
.send(conversation)
3636
.then((res, err) => {
3737
expect(err).to.be.undefined
@@ -59,7 +59,7 @@ describe('Testing Conversation endpoints', () => {
5959
it('Should get all conversations', async () => {
6060
await chai.request(app)
6161
.get('/api/conversation')
62-
.set(constants.headers)
62+
.set(constants.secretariatHeaders)
6363
.then((res, err) => {
6464
expect(err).to.be.undefined
6565
expect(res).to.have.status(200)
@@ -72,7 +72,7 @@ describe('Testing Conversation endpoints', () => {
7272
it('Should get all conversations for target UUID', async () => {
7373
await chai.request(app)
7474
.get(`/api/conversation/target/${orgUUID}`)
75-
.set(constants.headers)
75+
.set(constants.secretariatHeaders)
7676
.then((res, err) => {
7777
expect(err).to.be.undefined
7878
expect(res).to.have.status(200)
@@ -89,7 +89,7 @@ describe('Testing Conversation endpoints', () => {
8989
}
9090
await chai.request(app)
9191
.put(`/api/conversation/${conversationUUID}/message`)
92-
.set(constants.headers)
92+
.set(constants.secretariatHeaders)
9393
.send(updateBody)
9494
.then((res, err) => {
9595
expect(err).to.be.undefined
@@ -107,7 +107,7 @@ describe('Testing Conversation endpoints', () => {
107107
it('Should fail to post a conversation with no body', async () => {
108108
await chai.request(app)
109109
.post(`/api/conversation/target/${orgUUID}`)
110-
.set(constants.headers)
110+
.set(constants.secretariatHeaders)
111111
.send({})
112112
.then((res, err) => {
113113
expect(err).to.be.undefined
@@ -120,7 +120,7 @@ describe('Testing Conversation endpoints', () => {
120120
it('Should fail to update a conversation message with no body', async () => {
121121
await chai.request(app)
122122
.put(`/api/conversation/${conversationUUID}/message`)
123-
.set(constants.headers)
123+
.set(constants.secretariatHeaders)
124124
.send({})
125125
.then((res, err) => {
126126
expect(err).to.be.undefined

test/integration-tests/cve-id/cveIdUpdateTest.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Text PUT CVE-ID/:id', () => {
1919
it('Endpoint should return a 400 when state org is set to published', async () => {
2020
await chai.request(app)
2121
.put(`/api/cve-id/${cveId}?state=PUBLISHED`)
22-
.set(constants.headers)
22+
.set(constants.secretariatHeaders)
2323
.then((res, err) => {
2424
expect(err).to.be.undefined
2525
expect(res).to.have.status(400)
@@ -28,7 +28,7 @@ describe('Text PUT CVE-ID/:id', () => {
2828
it('Endpoint should allow the state parameter to be set to reserved', async () => {
2929
await chai.request(app)
3030
.put(`/api/cve-id/${cveId}?state=REJECTED`)
31-
.set(constants.headers)
31+
.set(constants.secretariatHeaders)
3232
.then((res, err) => {
3333
expect(err).to.be.undefined
3434
expect(res).to.have.status(200)
@@ -37,7 +37,7 @@ describe('Text PUT CVE-ID/:id', () => {
3737
it('Endpoint should still not allow a REJECTED endpoint to be set to published', async () => {
3838
await chai.request(app)
3939
.put(`/api/cve-id/${cveId}?state=PUBLISHED`)
40-
.set(constants.headers)
40+
.set(constants.secretariatHeaders)
4141
.then((res, err) => {
4242
expect(err).to.be.undefined
4343
expect(res).to.have.status(400)

0 commit comments

Comments
 (0)