File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
packages/sources/nav-generic Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @chainlink/nav-generic-adapter ' : patch
3
+ ---
4
+
5
+ error when integration API_URL config does not start with https://
Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ export const getApiConfigs = (integration: string): { apiKey: string; apiUrl: st
41
41
} )
42
42
}
43
43
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
+
44
52
return { apiKey, apiUrl }
45
53
}
46
54
Original file line number Diff line number Diff line change @@ -33,6 +33,17 @@ exports[`execute nav endpoint should handle missing value failure 1`] = `
33
33
}
34
34
` ;
35
35
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
+
36
47
exports [` execute nav endpoint should return success 1` ] = `
37
48
{
38
49
" data" : {
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ describe('execute', () => {
26
26
'https://dataproviderapi.com/missing-value-integration/nav'
27
27
process . env . ERROR_RESPONSE_API_KEY = 'fake-api-key'
28
28
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'
29
31
process . env . BACKGROUND_EXECUTE_MS_HTTP = '1'
30
32
31
33
const mockDate = new Date ( '2001-01-01T11:11:11.111Z' )
@@ -96,5 +98,14 @@ describe('execute', () => {
96
98
expect ( response . statusCode ) . toBe ( 500 )
97
99
expect ( response . json ( ) ) . toMatchSnapshot ( )
98
100
} )
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
+ } )
99
110
} )
100
111
} )
You can’t perform that action at this time.
0 commit comments