77 SettingsDefinitionMap ,
88} from '../src/config'
99import { validator } from '../src/validation/utils'
10+ import { Adapter } from '../src/adapter'
11+ import { buildSettingsList } from '../src/util/settings'
1012
1113test . afterEach ( async ( ) => {
1214 process . env = { }
@@ -168,7 +170,7 @@ test.serial('Test validate function (scientific notation)', async (t) => {
168170 }
169171} )
170172
171- test ( 'sensitive configuration constants are properly flagged' , ( t ) => {
173+ test . serial ( 'sensitive configuration constants are properly flagged' , ( t ) => {
172174 // Extract all settings that are marked as sensitive
173175 const actualSensitiveSettings = Object . entries ( BaseSettingsDefinition )
174176 . filter ( ( [ _ , setting ] ) => ( setting as { sensitive ?: boolean } ) . sensitive === true )
@@ -187,3 +189,41 @@ test('sensitive configuration constants are properly flagged', (t) => {
187189 // Deep equal comparison
188190 t . deepEqual ( actualSensitiveSettings , expectedSensitiveSettings )
189191} )
192+
193+ test . serial ( 'multiline sensitive configuration constants are properly redacted' , async ( t ) => {
194+ // GIVEN
195+ process . env [ 'PRIVATE_KEY' ] =
196+ '-----BEGIN PRIVATE KEY-----\nthis\nis a fake\nprivate key\nused for testing only==\n-----END PRIVATE KEY-----'
197+ const customSettings : SettingsDefinitionMap = {
198+ PRIVATE_KEY : {
199+ description : 'Test custom env var' ,
200+ type : 'string' ,
201+ sensitive : true ,
202+ validate : {
203+ meta : {
204+ details : 'placeholder validation' ,
205+ } ,
206+ fn : ( _ ?: string ) => {
207+ return ''
208+ } ,
209+ } ,
210+ } ,
211+ }
212+ const config = new AdapterConfig ( customSettings )
213+ config . initialize ( )
214+ config . validate ( )
215+ config . buildCensorList ( )
216+
217+ const adapter = new Adapter ( {
218+ name : 'TEST_ADAPTER' ,
219+ endpoints : [ ] ,
220+ config : config ,
221+ } )
222+
223+ const settingsList = buildSettingsList ( adapter )
224+
225+ const settingEntries = settingsList . filter ( ( entry ) => entry . name === 'PRIVATE_KEY' )
226+ t . assert ( settingEntries . length === 1 )
227+ const settingEntry = settingEntries [ 0 ]
228+ t . assert ( settingEntry . value === '[PRIVATE_KEY REDACTED]' )
229+ } )
0 commit comments