Skip to content

Commit

Permalink
fix: make custom accept cfg metadata accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
aarlaud committed Dec 18, 2024
1 parent fb9a897 commit c2ecde9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/client/config/configHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
30 changes: 30 additions & 0 deletions test/unit/configHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit c2ecde9

Please sign in to comment.