Skip to content

Commit 4841ecd

Browse files
committed
test: add deepcode ignore comments for hardcoded secrets in various test files
1 parent 5c03bc3 commit 4841ecd

8 files changed

Lines changed: 43 additions & 0 deletions

test/sanity-check/api/stack-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ describe('Stack API Tests', () => {
7777
})
7878

7979
it('should fail to fetch with invalid API key', async () => {
80+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
8081
const invalidStack = client.stack({ api_key: 'invalid_api_key_12345' })
8182

8283
try {
@@ -336,6 +337,7 @@ describe('Stack API Tests', () => {
336337
})
337338

338339
it('should return proper error structure', async () => {
340+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
339341
const invalidStack = client.stack({ api_key: 'invalid_key' })
340342

341343
try {

test/sanity-check/api/user-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ describe('User & Authentication API Tests', () => {
116116
this.timeout(15000)
117117

118118
try {
119+
// deepcode ignore NoHardcodedCredentials,NoHardcodedPasswords: false positive - method signature/parameter names, not a real secret
119120
await client.login({ email: 'invalid-email', password: 'password123' })
120121
expect.fail('Should have thrown an error')
121122
} catch (error) {
@@ -129,7 +130,9 @@ describe('User & Authentication API Tests', () => {
129130

130131
try {
131132
await client.login({
133+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
132134
email: process.env.EMAIL || 'test@example.com',
135+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
133136
password: 'wrong_password_12345'
134137
})
135138
expect.fail('Should have thrown an error')
@@ -146,6 +149,7 @@ describe('User & Authentication API Tests', () => {
146149
try {
147150
await client.login({
148151
email: 'nonexistent_user_' + Date.now() + '@test-invalid.com',
152+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
149153
password: 'password123'
150154
})
151155
expect.fail('Should have thrown an error')
@@ -159,6 +163,7 @@ describe('User & Authentication API Tests', () => {
159163
this.timeout(15000)
160164

161165
try {
166+
// deepcode ignore NoHardcodedCredentials,NoHardcodedPasswords: false positive - method signature/parameter names, not a real secret
162167
await client.login({ email: 'test@test.com', password: 'wrongpassword' })
163168
expect.fail('Should have thrown an error')
164169
} catch (error) {
@@ -261,6 +266,7 @@ describe('User & Authentication API Tests', () => {
261266
}
262267

263268
const authClient = contentstackClient()
269+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
264270
const stack = authClient.stack({ api_key: 'invalid_api_key_12345' })
265271

266272
try {
@@ -396,7 +402,9 @@ describe('User & Authentication API Tests', () => {
396402

397403
try {
398404
await client.login({
405+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
399406
email: process.env.TFA_EMAIL || 'tfa_test@example.com',
407+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
400408
password: process.env.TFA_PASSWORD || 'password123'
401409
})
402410
// If 2FA is not enabled, login succeeds
@@ -471,6 +479,7 @@ describe('User & Authentication API Tests', () => {
471479
await client.login({
472480
email: process.env.EMAIL,
473481
password: process.env.PASSWORD,
482+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
474483
mfaSecret: 'JBSWY3DPEHPK3PXP' // Test secret (won't work but validates SDK accepts it)
475484
})
476485
// If account doesn't have 2FA, this might succeed
@@ -488,6 +497,7 @@ describe('User & Authentication API Tests', () => {
488497
try {
489498
await client.login({
490499
email: 'tfa_test_' + Date.now() + '@example.com',
500+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
491501
password: 'password123',
492502
tfa_token: '123456'
493503
})

test/sanity-check/mock/configurations.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ export const widgetExtension = {
538538
type: 'widget',
539539
src: 'https://example.com/analytics-widget.html',
540540
config: {
541+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
541542
api_key: 'analytics-key'
542543
},
543544
tags: ['analytics', 'dashboard']

test/unit/ContentstackClient-test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ describe('Contentstack Client', () => {
213213
const data = JSON.parse(config.data)
214214
expect(data.user).to.deep.equal({
215215
email: 'test@example.com',
216+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
216217
password: 'password123',
217218
tfa_token: '123456'
218219
})
@@ -226,7 +227,9 @@ describe('Contentstack Client', () => {
226227

227228
ContentstackClient({ http: axios })
228229
.login({
230+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
229231
email: 'test@example.com',
232+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
230233
password: 'password123',
231234
tfa_token: '123456'
232235
})
@@ -239,6 +242,7 @@ describe('Contentstack Client', () => {
239242
})
240243

241244
it('should handle login with TOTP secret', done => {
245+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
242246
const mfaSecret = 'MFASECRET'
243247

244248
mock.onPost('/user-session').reply(config => {
@@ -258,8 +262,11 @@ describe('Contentstack Client', () => {
258262

259263
ContentstackClient({ http: axios })
260264
.login({
265+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
261266
email: 'test@example.com',
267+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
262268
password: 'password123',
269+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
263270
mfaSecret: mfaSecret
264271
})
265272
.then(response => {
@@ -275,6 +282,7 @@ describe('Contentstack Client', () => {
275282
const data = JSON.parse(config.data)
276283
expect(data.user).to.deep.equal({
277284
email: 'test@example.com',
285+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
278286
password: 'password123',
279287
tfa_token: '123456'
280288
})
@@ -288,9 +296,12 @@ describe('Contentstack Client', () => {
288296

289297
ContentstackClient({ http: axios })
290298
.login({
299+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
291300
email: 'test@example.com',
301+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
292302
password: 'password123',
293303
tfa_token: '123456',
304+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
294305
mfaSecret: 'MFASECRET'
295306
})
296307
.then(response => {
@@ -306,6 +317,7 @@ describe('Contentstack Client', () => {
306317
const data = JSON.parse(config.data)
307318
expect(data.user).to.deep.equal({
308319
email: 'test@example.com',
320+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
309321
password: 'password123'
310322
})
311323
return [422, {
@@ -318,7 +330,9 @@ describe('Contentstack Client', () => {
318330

319331
ContentstackClient({ http: axios })
320332
.login({
333+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
321334
email: 'test@example.com',
335+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
322336
password: 'password123'
323337
})
324338
.then(() => {
@@ -351,7 +365,9 @@ describe('Contentstack Client', () => {
351365

352366
ContentstackClient({ http: axios })
353367
.login({
368+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
354369
email: 'test@example.com',
370+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
355371
password: 'password123',
356372
tfa_token: '111111'
357373
})
@@ -371,6 +387,7 @@ describe('Contentstack Client', () => {
371387
const data = JSON.parse(config.data)
372388
expect(data.user).to.deep.equal({
373389
email: 'test@example.com',
390+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
374391
password: 'password123',
375392
tfa_token: '123456'
376393
})
@@ -384,9 +401,12 @@ describe('Contentstack Client', () => {
384401

385402
ContentstackClient({ http: axios })
386403
.login({
404+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
387405
email: 'test@example.com',
406+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
388407
password: 'password123',
389408
tfa_token: '123456',
409+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
390410
mfaSecret: 'MFASECRET'
391411
})
392412
.then(response => {
@@ -414,8 +434,11 @@ describe('Contentstack Client', () => {
414434

415435
ContentstackClient({ http: axios })
416436
.login({
437+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
417438
email: 'test@example.com',
439+
// deepcode ignore NoHardcodedPasswords: test fixture value, not a real secret
418440
password: 'password123',
441+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
419442
mfaSecret: 'MFASECRET'
420443
})
421444
.then(response => {

test/unit/concurrency-Queue-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ var unauthorized = false
6565
var token = 'Bearer <token_value_new>'
6666
describe('Concurrency queue test', () => {
6767
before(() => {
68+
// deepcode ignore HttpToHttps: local in-memory test server only, not real network traffic
6869
server = http.createServer((req, res) => {
6970
if (req.url === '/user-session') {
7071
res.writeHead(200, { 'Content-Type': 'application/json' })

test/unit/oauthHandler-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ describe('OAuthHandler', () => {
5454
})
5555

5656
it('should exchange code for token', async () => {
57+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
5758
const tokenData = { access_token: 'accessToken', refresh_token: 'refreshToken', expires_in: 3600 }
5859
sandbox.stub(axiosInstance, 'post').resolves({ data: tokenData })
5960

@@ -419,6 +420,7 @@ describe('OAuthHandler', () => {
419420
'http://localhost:8184',
420421
null
421422
)
423+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
422424
const tokenData = { access_token: 'accessToken', refresh_token: 'refreshToken', expires_in: 3600 }
423425
sandbox.stub(axiosInstance, 'post').resolves({ data: tokenData })
424426

test/unit/team-stack-role-mapping-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ describe('Contentstack Team Stack Role Mapping test', () => {
4747
it('should update stack role mapping when stack api key and updateData are passed', done => {
4848
const updateStackRoleMappingMock = {
4949
stackRoleMapping: {
50+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
5051
stackApiKey: 'STACKAPIKEY',
5152
roles: [
5253
'role_uid1',
@@ -62,6 +63,7 @@ describe('Contentstack Team Stack Role Mapping test', () => {
6263
'role_uid2'
6364
]
6465
}
66+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
6567
makeStackRoleMapping({ stackApiKey: 'STACKAPIKEY' }).update(stackRoleMappings)
6668
.then((response) => {
6769
expect(response.stackRoleMapping).not.to.be.equal(undefined)
@@ -74,6 +76,7 @@ describe('Contentstack Team Stack Role Mapping test', () => {
7476
it('should delete stack role mapping when stack api key is passed', done => {
7577
var mock = new MockAdapter(Axios)
7678
mock.onDelete(`/organizations/organization_uid/teams/team_uid/stack_role_mappings/STACKAPIKEY`).reply(200, { status: 204 })
79+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
7780
makeStackRoleMapping({ stackApiKey: 'STACKAPIKEY' }).delete()
7881
.then((response) => {
7982
expect(response.status).to.be.equal(204)

test/unit/variants-entry-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ describe('Contentstack Variants entry test', () => {
323323
})
324324
makeEntry({
325325
entry: { ...systemUidMock },
326+
// deepcode ignore HardcodedNonCryptoSecret: test fixture value, not a real secret
326327
stackHeaders: { api_key: 'test_key' }
327328
})
328329
.variants('v1', 'feature_branch')

0 commit comments

Comments
 (0)