From c2ecde9f5b8350db9ffaa8a12919af63586de838 Mon Sep 17 00:00:00 2001 From: Antoine Arlaud Date: Wed, 18 Dec 2024 17:51:27 +0100 Subject: [PATCH] fix: make custom accept cfg metadata accurate --- lib/client/config/configHelpers.ts | 5 ++++- test/unit/configHelper.test.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/client/config/configHelpers.ts b/lib/client/config/configHelpers.ts index 37ca393c1..b168b205a 100644 --- a/lib/client/config/configHelpers.ts +++ b/lib/client/config/configHelpers.ts @@ -37,7 +37,10 @@ export const getClientConfigMetadata = ( tlsReject: parseInt(clientConfig.nodeTlsRejectUnauthorized) === 0 ? true : false, proxy: clientConfig.httpProxy || clientConfig.httpsProxy ? true : false, - customAccept: clientConfig.accept ? true : false, + customAccept: + clientConfig.accept && clientConfig.accept != 'accept.json' + ? true + : false, insecureDownstream: clientConfig.insecureDownstream ? true : false, universalBroker: clientConfig.universalBrokerEnabled ? true : false, }; diff --git a/test/unit/configHelper.test.ts b/test/unit/configHelper.test.ts index 371da07dd..f6fac5bfd 100644 --- a/test/unit/configHelper.test.ts +++ b/test/unit/configHelper.test.ts @@ -84,6 +84,36 @@ describe('config', () => { }); }); + it('custom accept is false if ACCEPT exists and set to accept.json', async () => { + process.env.LOG_LEVEL = 'debug'; + process.env.LOG_ENABLE_BODY = 'true'; + process.env.GITHUB_TOKEN_POOL = '123,456'; + process.env.INSECURE_DOWNSTREAM = 'true_but_truly_value_does_not_matter'; + process.env.BROKER_HA_MODE_ENABLED = 'true'; + process.env.HTTP_PROXY = 'http://myproxy'; + process.env.NODE_EXTRA_CA_CERT = 'my/path'; + process.env.ACCEPT = 'accept.json'; + process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; + process.env.UNIVERSAL_BROKER_ENABLED = 'true'; + await loadBrokerConfig(); + const config = getConfig(); + config.brokerClientId = '123'; + expect(getClientConfigMetadata(config as LoadedClientOpts)).toEqual({ + bodyLogMode: true, + brokerClientId: '123', + credPooling: true, + customAccept: false, + debugMode: true, + haMode: true, + privateCa: true, + proxy: true, + tlsReject: true, + insecureDownstream: true, + universalBroker: true, + version: 'local', + }); + }); + it('everything is false for everything disabled in config', async () => { process.env.LOG_LEVEL = 'info'; process.env.GITHUB_TOKEN = '456';