Skip to content

Commit 734d52b

Browse files
Fix/DF-21465 nav generic (#3908)
* DF-21465 nav-generic error when not https * add changeset --------- Co-authored-by: app-token-issuer-data-feeds[bot] <134377064+app-token-issuer-data-feeds[bot]@users.noreply.github.com>
1 parent cd9f1aa commit 734d52b

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

.changeset/fair-ears-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/nav-generic-adapter': patch
3+
---
4+
5+
error when integration API_URL config does not start with https://

packages/sources/nav-generic/src/transport/nav.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ export const getApiConfigs = (integration: string): { apiKey: string; apiUrl: st
4141
})
4242
}
4343

44+
// audit fix, ensure https at the url config level
45+
if (!apiUrl.startsWith('https://')) {
46+
throw new AdapterError({
47+
message: `${apiUrlEnvVarName} does not start with https://`,
48+
statusCode: 500,
49+
})
50+
}
51+
4452
return { apiKey, apiUrl }
4553
}
4654

packages/sources/nav-generic/test/integration/__snapshots__/adapter.test.ts.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ exports[`execute nav endpoint should handle missing value failure 1`] = `
3333
}
3434
`;
3535

36+
exports[`execute nav endpoint should handle non https api url error 1`] = `
37+
{
38+
"error": {
39+
"message": "INCORRECT_API_URL_API_URL does not start with https://",
40+
"name": "AdapterError",
41+
},
42+
"status": "errored",
43+
"statusCode": 500,
44+
}
45+
`;
46+
3647
exports[`execute nav endpoint should return success 1`] = `
3748
{
3849
"data": {

packages/sources/nav-generic/test/integration/adapter.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ describe('execute', () => {
2626
'https://dataproviderapi.com/missing-value-integration/nav'
2727
process.env.ERROR_RESPONSE_API_KEY = 'fake-api-key'
2828
process.env.ERROR_RESPONSE_API_URL = 'https://dataproviderapi.com/error-response/nav'
29+
process.env.INCORRECT_API_URL_API_KEY = 'fake-api-key'
30+
process.env.INCORRECT_API_URL_API_URL = 'http://dataproviderapi.com/http/nav'
2931
process.env.BACKGROUND_EXECUTE_MS_HTTP = '1'
3032

3133
const mockDate = new Date('2001-01-01T11:11:11.111Z')
@@ -96,5 +98,14 @@ describe('execute', () => {
9698
expect(response.statusCode).toBe(500)
9799
expect(response.json()).toMatchSnapshot()
98100
})
101+
it('should handle non https api url error', async () => {
102+
const data = {
103+
integration: 'incorrect-api-url',
104+
endpoint: 'nav',
105+
}
106+
const response = await testAdapter.request(data)
107+
expect(response.statusCode).toBe(500)
108+
expect(response.json()).toMatchSnapshot()
109+
})
99110
})
100111
})

0 commit comments

Comments
 (0)