Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
refactor(cache-provider.js): update redis deps to fix security vulner…
…ability Updated redis deps, little fix to handle redis connection functionality retryStrategy re #145
- Loading branch information
Showing
6 changed files
with
147 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const chai = require('chai') | ||
const rewire = require('rewire') | ||
const cacheProviders = rewire('../server/cache-provider.js') | ||
const testConfig = require('../config/test') | ||
const redis = require('redis') | ||
const fakeredis = require('fakeredis') | ||
|
||
const assert = chai.assert | ||
|
||
describe('cache provider test', () => { | ||
const retryStrategy = cacheProviders.__get__('retryStrategy') | ||
const testProvider = testConfig.passportConfigAuthorizedResponse.providers.find(provider => provider.id === 'saml-redis-test') | ||
testProvider.options.retry_strategy = retryStrategy | ||
|
||
it('redis is not live so we should get connection error response', () => { | ||
const client = redis.createClient(testProvider.options) | ||
|
||
client.on('ready', () => { | ||
assert.fail('redis connection should not work') | ||
}) | ||
client.on('error', actualError => { | ||
const expectedError = new Error('Redis connection in broken state: retry aborted.') | ||
assert.equal(actualError.message, expectedError.message) | ||
}) | ||
}) | ||
|
||
it('redis is live so we should get connection', () => { | ||
const client = fakeredis.createClient(testProvider.options) | ||
|
||
client.on('error', actualError => { | ||
assert.fail('redis connection should work') | ||
}) | ||
}) | ||
|
||
it('getRedisProvider should return cache handlers', () => { | ||
const getRedisProvider = cacheProviders.__get__('getRedisProvider') | ||
const redisHandlers = getRedisProvider(testProvider.options, 100) | ||
assert.exists(redisHandlers.save, 'Failed to initialize redis provider save handler') | ||
assert.exists(redisHandlers.get, 'Failed to initialize redis provider get handler') | ||
assert.exists(redisHandlers.remove, 'Failed to initialize redis provider remove handler') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters