Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
imesh committed Aug 28, 2020
1 parent d311a89 commit 249be03
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,12 @@ const processLoad = (config, keys, callback, useSynchronizer, redisClient) => {
}
},
function(cb) {
if ( useSynchronizer || !config.edge_config.redisBasedConfigCache ) {
if (useSynchronizer || !config.edge_config.redisBasedConfigCache) {
var opts = _.clone(options);
opts['url'] = config.edge_config.jwk_public_keys;
opts['url'] = config.edge_config.jwk_public_keys || null;
opts = enableTLS(config, opts);
request.get(opts, function(err, response, body) {
if(useSynchronizer && !err && response && response.statusCode === 200){
if(useSynchronizer && !err && response && response.statusCode === 200) {
saveConfigToRedis(redisClient, globalOptions, config.edge_config.jwk_public_keys, body, 'jwk_public_keys', (err)=>{
if ( err ) {
writeConsoleLog('error',{component: CONSOLE_LOG_TAG_COMP}, 'error saving data to redis from %s', config.edge_config.jwk_public_keys, err);
Expand All @@ -416,18 +416,27 @@ const processLoad = (config, keys, callback, useSynchronizer, redisClient) => {
writeConsoleLog('info',{component: CONSOLE_LOG_TAG_COMP}, 'Saved data to redis from %s', config.edge_config.jwk_public_keys);
});
}
if ( !config.edge_config.redisBasedConfigCache) {
_loadStatus('jwk_public_keys', config.edge_config.jwk_public_keys, err, response, body, cb);
if (!config.edge_config.redisBasedConfigCache) {
if (response && response.statusCode === 200) {
_loadStatus('jwk_public_keys', opts['url'],
err, response, body, cb);
} else {
response = {};
response.statusCode = 200;
body = null;
err = null;
_loadStatus('jwk_public_keys', opts['url'],
null, response, body, cb);
}
}
});
}

if ( config.edge_config.redisBasedConfigCache === true ) { //retrieve from redis db
if (config.edge_config.redisBasedConfigCache === true) { //retrieve info from redis db
getConfigFromRedis(redisClient, globalOptions, config.edge_config.jwk_public_keys, 'jwk_public_keys', function(err, body){
const response = err ? null : { statusCode: 200, statusMessage: 'Downloaded from redis' };
_loadStatus('jwk_public_keys', config.edgemicro.redisHost, err, response, body, cb);
});
}
}
}
], function(err, results) {
debug('error %s, proxies %s, products %s, jwt_public_key %s', err,
Expand Down

0 comments on commit 249be03

Please sign in to comment.