spec.plugins.session.js
This file
Path
spec/spec.plugins.session.js
133 lines · 4.0 KiB · JavaScript
Last changed by
Merge branch 'integration'visionmediabefore adoption33443d9
History of this fileTake it
Started Session pluginvisionmediabefore adoption7238afb
lines 1–4why, one step back12describe 'Express'3 before_each4 reset()Fixed broken specs due to use(Cookie) missingvisionmediabefore adoption1a9a367
line 5why, one step back5 use(require('express/plugins/cookie').Cookie)Fixed sessions when testingvisionmediabefore adoption4d5a1b5
line 6why, one step back6 use(Session = require('express/plugins/session').Session)Merge branch 'integration'visionmediabefore adoption33443d9
line 7why, one step back7 Base = require('express/plugins/session').BaseFixed sessions when testingvisionmediabefore adoption4d5a1b5
line 8why, one step back8 Session.store.clear()Started Session pluginvisionmediabefore adoption7238afb
lines 9–11why, one step back9 end10 11 describe 'Session'Bulk of memory store based session support complete.visionmediabefore adoptionf4b4c03
lines 12–17why, one step back12 describe 'when sid cookie is not present'13 it 'should set sid cookie'14 get('/login', function(){ return '' })15 get('/login').headers['set-cookie'].should.match(/^sid=(\w+);/)16 end17 endMerge branch 'integration'visionmediabefore adoption33443d9
lines 18–19why, one step back1819 describe 'when existing sid cookie is present'Bulk of memory store based session support complete.visionmediabefore adoptionf4b4c03
line 20why, one step back20 it 'should not set sid'Merge branch 'integration'visionmediabefore adoption33443d9
line 21why, one step back21 Session.store.commit(new Base(123))Bulk of memory store based session support complete.visionmediabefore adoptionf4b4c03
lines 22–25why, one step back22 get('/login', function(){ return '' })23 get('/login', { headers: { cookie: 'sid=123' }}).headers.should.not.have_property 'set-cookie'24 end25 endMerge branch 'integration'visionmediabefore adoption33443d9
lines 26–36why, one step back26 27 describe 'when unknown sid cookie is present'28 it 'should set new sid'29 get('/login', function(){ return '' })30 var headers= get('/login', { headers: { cookie: 'sid=123' }}).headers31 32 headers.should.have_property 'set-cookie'33 headers['set-cookie'].should.not.be '123'34 end35 end 36Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
line 37why, one step back37 describe 'session Store.Memory'Added session reapingvisionmediabefore adoption8ed99f6
line 38why, one step back38 before_eachMerge branch 'integration'visionmediabefore adoption33443d9
line 39why, one step back39 Session.store= memory = new (require('express/plugins/session').Store.Memory)Added session reapingvisionmediabefore adoption8ed99f6
lines 40–41why, one step back40 end41 Bulk of memory store based session support complete.visionmediabefore adoptionf4b4c03
lines 42–48why, one step back42 it 'should persist'43 post('/login', function(){44 return this.session.name = 'tj'45 })46 get('/login', function(){47 return this.session.name48 })Merge branch 'integration'visionmediabefore adoption33443d9
line 49why, one step back49 memory.commit(new Base(123))Bulk of memory store based session support complete.visionmediabefore adoptionf4b4c03
lines 50–54why, one step back50 var headers = { headers: { cookie: 'sid=123' }}51 post('/login', headers)52 get('/login', headers).status.should.eql 20053 get('/login', headers).body.should.eql 'tj'54 endAdded session reapingvisionmediabefore adoption8ed99f6
line 55why, one step back55 Merge branch 'abstract-session'visionmediabefore adoption315c050
lines 56–61why, one step back56 describe '#toString()'57 it 'should return [Memory Store]'58 memory.toString().should.eql '[Memory Store]'59 end60 end61 Added session reapingvisionmediabefore adoption8ed99f6
lines 62–64why, one step back62 describe '#fetch()'63 describe 'when the session does not exist'64 it 'should return a new Session'Merge branch 'integration'visionmediabefore adoption33443d9
lines 65–69why, one step back65 var result66 memory.fetch('1', function(error,session){67 result= session68 })69 result.should.have_property 'lastAccess'Added session reapingvisionmediabefore adoption8ed99f6
lines 70–74why, one step back70 end71 end72 73 describe 'when the session does exist'74 it 'should return the previous session'Merge branch 'integration'visionmediabefore adoption33443d9
lines 75–80why, one step back75 var result76 memory.commit(new Base('1'))77 memory.fetch('1', function(error, session){78 result = session79 })80 result.id.should.eql '1'Added session reapingvisionmediabefore adoption8ed99f6
lines 81–94why, one step back81 end82 end83 end84 85 describe '#clear()'86 it 'should remove all sessions'87 memory.commit({ id: '1' })88 memory.commit({ id: '2' })89 memory.clear()90 memory.should.not.have_property '1'91 memory.should.not.have_property '2'92 end93 end94 Merge branch 'session-count'visionmediabefore adoptione083321
lines 95–96why, one step back95 describe '#length()'96 it 'should return the number of session'Merge branch 'integration'visionmediabefore adoption33443d9
line 97why, one step back97 var lengthMerge branch 'session-count'visionmediabefore adoptione083321
lines 98–99why, one step back98 memory.commit({ id: '1' })99 memory.commit({ id: '2' })Merge branch 'integration'visionmediabefore adoption33443d9
lines 100–103why, one step back100 memory.length(function(error, len) {101 length = len102 })103 length.should.eql 2Merge branch 'session-count'visionmediabefore adoptione083321
lines 104–106why, one step back104 end105 end106 Added session reapingvisionmediabefore adoption8ed99f6
lines 107–129why, one step back107 describe '#destroy()'108 it 'should destroy a single session'109 memory.commit({ id: '1' })110 memory.commit({ id: '2' })111 memory.destroy('1')112 memory.store.should.not.have_property '1'113 memory.store.should.have_property '2'114 end115 end116 117 describe '#reap()'118 it 'should destroy sessions older than the given age in milliseconds'119 memory.commit({ id: '1', lastAccess: Number(new Date) - 300 })120 memory.commit({ id: '2', lastAccess: Number(new Date) - 250 })121 memory.commit({ id: '3', lastAccess: Number(new Date) - 100 })122 memory.commit({ id: '4', lastAccess: Number(new Date) })123 memory.reap(200)124 memory.store.should.not.have_property '1'125 memory.store.should.not.have_property '2'126 memory.store.should.have_property '3'127 memory.store.should.have_property '4'128 end129 endStarted Session pluginvisionmediabefore adoption7238afb
line 130why, one step back130 endAdded session reapingvisionmediabefore adoption8ed99f6
line 131why, one step back131 Started Session pluginvisionmediabefore adoption7238afb
lines 132–133why, one step back132 end133end