describe('with cache', function() { var Cache = require('volos-cache-memory'); var cache = Cache.create('OAuth cache'); config.oauth.useCache(cache); expressTest.verifyOauth(config); extensionsTest.verifyOauth(config); });
oauth.verifyToken(header, function(err) { should.not.exist(err); should.exist(token); // now, add a cache if (!config.oauth.isCached) { var addedCache = true; var cache = MemCache.create('OAuth cache'); config.oauth.useCache(cache); } oauth.verifyToken(header, 'badscope', function(err) { should.exist(err); oauth.verifyToken(header, 'scope1', function(err) { should.not.exist(err); oauth.verifyToken(header, 'scope2', function(err) { should.not.exist(err); if (addedCache) { config.oauth.removeCache(); } done(); }); }); }); });
it('attempting to use a cache with encoding should fail', function(done) { var cache = MemCache.create('OAuth cache', { encoding: 'utf8' }); (function() { config.oauth.useCache(cache); } ).should.throw(); done(); });
before(function(done) { var Cache = require('volos-cache-memory'); var cache = Cache.create('OAuth cache'); config.oauth.useCache(cache); done(); });