|
|
@@ -42,6 +42,10 @@ const assert_has_no_cache_headers = function(response) {
|
|
|
assert.isUndefined(headers['pragma'])
|
|
|
return assert.isUndefined(headers['expires'])
|
|
|
}
|
|
|
+const assert_has_asset_caching_headers = function(response) {
|
|
|
+ const { headers } = response
|
|
|
+ assert.equal(headers['cache-control'], 'public, max-age=31536000')
|
|
|
+}
|
|
|
|
|
|
describe('SecurityHeaders', function() {
|
|
|
beforeEach(function() {
|
|
|
@@ -69,6 +73,13 @@ describe('SecurityHeaders', function() {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ it('should have caching headers on static assets', function(done) {
|
|
|
+ request.get('/favicon.ico', (err, res) => {
|
|
|
+ assert_has_asset_caching_headers(res)
|
|
|
+ done(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
it('should have cache headers when user is logged in', function(done) {
|
|
|
return async.series(
|
|
|
[
|
|
|
@@ -110,4 +121,19 @@ describe('SecurityHeaders', function() {
|
|
|
}
|
|
|
)
|
|
|
})
|
|
|
+
|
|
|
+ it('should have caching headers on static assets when user is logged in', function(done) {
|
|
|
+ async.series(
|
|
|
+ [
|
|
|
+ cb => this.user.login(cb),
|
|
|
+ cb => this.user.request.get('/favicon.ico', cb),
|
|
|
+ cb => this.user.logout(cb)
|
|
|
+ ],
|
|
|
+ (err, results) => {
|
|
|
+ const res = results[1][0]
|
|
|
+ assert_has_asset_caching_headers(res)
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
})
|