From 8bb8524b8434d9fda3b7d6fa49eab4b018b58fc9 Mon Sep 17 00:00:00 2001 From: Albert Kogan Date: Wed, 30 Dec 2020 17:54:23 +0200 Subject: [PATCH] fix: artifactory systmecheck endpoint This patch fixing 406 error of `/api/system/ping` endpoint. It returns `text/plain` response and not allow to pass `application/json` header. --- client-templates/artifactory/.env.sample | 1 + lib/client/index.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/client-templates/artifactory/.env.sample b/client-templates/artifactory/.env.sample index 714bcf01d..d02992fec 100644 --- a/client-templates/artifactory/.env.sample +++ b/client-templates/artifactory/.env.sample @@ -21,3 +21,4 @@ RES_BODY_URL_SUB=http:///artifactory # Artifactory validation url, checked by broker client systemcheck endpoint BROKER_CLIENT_VALIDATION_URL=https://$ARTIFACTORY_URL/api/system/ping +BROKER_CLIENT_VALIDATION_JSON_DISABLED=true diff --git a/lib/client/index.js b/lib/client/index.js index af0807097..94ad207b9 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -49,6 +49,7 @@ module.exports = ({ port = null, config = {}, filters = {} }) => { config.brokerClientValidationMethod || 'GET'; const brokerClientValidationTimeoutMs = config.brokerClientValidationTimeoutMs || 5000; + const isJsonResponse = !config.brokerClientValidationJsonDisabled; const data = { brokerClientValidationUrl: logger.sanitise( @@ -79,7 +80,7 @@ module.exports = ({ port = null, config = {}, filters = {} }) => { headers: validationRequestHeaders, method: brokerClientValidationMethod, timeout: brokerClientValidationTimeoutMs, - json: true, + json: isJsonResponse, agentOptions: { ca: config.caCert, // Optional CA cert },