Skip to content
Myr

spec.plugins.session.js

This file

Path

spec/spec.plugins.session.js

140 lines · 4.3 KiB · JavaScript

Last changed by

Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b

History of this file

Take it

The walk stopped after 200 commits: lines older than fbf547d point at it.

Added Session classvisionmediabefore adoptionfbf547d

lines 1–4why, one step back
1
2describe 'Express'3 before_each4 reset()

Fixed broken specs due to use(Cookie) missingvisionmediabefore adoption1a9a367

line 5why, one step back
5 use(require('express/plugins/cookie').Cookie)

Fixed sessions when testingvisionmediabefore adoption4d5a1b5

line 6why, one step back
6 use(Session = require('express/plugins/session').Session)

Merge branch 'integration'visionmediabefore adoption33443d9

line 7why, one step back
7 Base = require('express/plugins/session').Base

Fixed sessions when testingvisionmediabefore adoption4d5a1b5

line 8why, one step back
8 Session.store.clear()

Added Session classvisionmediabefore adoptionfbf547d

lines 9–14why, one step back
9 end
10 11 describe 'Session'12 describe 'when sid cookie is not present'13 it 'should set sid cookie'14 get('/login', function(){ return '' })

Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b

line 15why, one step back
15 get('/login').headers['Set-Cookie'].should.match(/^sid=(\w+);/)

Added Session classvisionmediabefore adoptionfbf547d

line 16why, one step back
16 end

Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b

lines 17–23why, one step back
17
18 describe 'and requesting /favicon.ico'19 it 'should not set sid cookie'20 get('/favicon.ico', function(){ this.respond() })21 get('/favicon.ico').headers.should.not.have_property 'set-cookie'22 end23 end

Added Session classvisionmediabefore adoptionfbf547d

line 24why, one step back
24 end

Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b

line 25why, one step back
25

Merge branch 'integration'visionmediabefore adoption33443d9

line 26why, one step back
26 describe 'when existing sid cookie is present'

Added Session classvisionmediabefore adoptionfbf547d

line 27why, one step back
27 it 'should not set sid'

Merge branch 'integration'visionmediabefore adoption33443d9

line 28why, one step back
28 Session.store.commit(new Base(123))

Added Session classvisionmediabefore adoptionfbf547d

line 29why, one step back
29 get('/login', function(){ return '' })

Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b

line 30why, one step back
30 get('/login', { headers: { cookie: 'sid=123' }}).headers.should.not.have_property 'Set-Cookie'

Added Session classvisionmediabefore adoptionfbf547d

lines 31–32why, one step back
31 end
32 end

Merge branch 'integration'visionmediabefore adoption33443d9

lines 33–38why, one step back
33
34 describe 'when unknown sid cookie is present'35 it 'should set new sid'36 get('/login', function(){ return '' })37 var headers= get('/login', { headers: { cookie: 'sid=123' }}).headers38

Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b

line 39why, one step back
39 headers.should.have_property 'Set-Cookie'

Merge branch 'integration'visionmediabefore adoption33443d9

lines 40–43why, one step back
40 headers['set-cookie'].should.not.be '123'
41 end42 end 43

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

line 44why, one step back
44 describe 'session Store.Memory'

Added session reapingvisionmediabefore adoption8ed99f6

line 45why, one step back
45 before_each

Merge branch 'integration'visionmediabefore adoption33443d9

line 46why, one step back
46 Session.store= memory = new (require('express/plugins/session').Store.Memory)

Added session reapingvisionmediabefore adoption8ed99f6

lines 47–48why, one step back
47 end
48

Added Session classvisionmediabefore adoptionfbf547d

lines 49–55why, one step back
49 it 'should persist'
50 post('/login', function(){51 return this.session.name = 'tj'52 })53 get('/login', function(){54 return this.session.name55 })

Merge branch 'integration'visionmediabefore adoption33443d9

line 56why, one step back
56 memory.commit(new Base(123))

Added Session classvisionmediabefore adoptionfbf547d

lines 57–61why, one step back
57 var headers = { headers: { cookie: 'sid=123' }}
58 post('/login', headers)59 get('/login', headers).status.should.eql 20060 get('/login', headers).body.should.eql 'tj'61 end

Added session reapingvisionmediabefore adoption8ed99f6

line 62why, one step back
62

Merge branch 'abstract-session'visionmediabefore adoption315c050

lines 63–68why, one step back
63 describe '#toString()'
64 it 'should return [Memory Store]'65 memory.toString().should.eql '[Memory Store]'66 end67 end68

Added session reapingvisionmediabefore adoption8ed99f6

lines 69–71why, one step back
69 describe '#fetch()'
70 describe 'when the session does not exist'71 it 'should return a new Session'

Merge branch 'integration'visionmediabefore adoption33443d9

lines 72–76why, one step back
72 var result
73 memory.fetch('1', function(error,session){74 result= session75 })76 result.should.have_property 'lastAccess'

Added session reapingvisionmediabefore adoption8ed99f6

lines 77–81why, one step back
77 end
78 end79 80 describe 'when the session does exist'81 it 'should return the previous session'

Merge branch 'integration'visionmediabefore adoption33443d9

lines 82–87why, one step back
82 var result
83 memory.commit(new Base('1'))84 memory.fetch('1', function(error, session){85 result = session86 })87 result.id.should.eql '1'

Added session reapingvisionmediabefore adoption8ed99f6

lines 88–101why, one step back
88 end
89 end90 end91 92 describe '#clear()'93 it 'should remove all sessions'94 memory.commit({ id: '1' })95 memory.commit({ id: '2' })96 memory.clear()97 memory.should.not.have_property '1'98 memory.should.not.have_property '2'99 end100 end101

Merge branch 'session-count'visionmediabefore adoptione083321

lines 102–103why, one step back
102 describe '#length()'
103 it 'should return the number of session'

Merge branch 'integration'visionmediabefore adoption33443d9

line 104why, one step back
104 var length

Merge branch 'session-count'visionmediabefore adoptione083321

lines 105–106why, one step back
105 memory.commit({ id: '1' })
106 memory.commit({ id: '2' })

Merge branch 'integration'visionmediabefore adoption33443d9

lines 107–110why, one step back
107 memory.length(function(error, len) {
108 length = len109 })110 length.should.eql 2

Merge branch 'session-count'visionmediabefore adoptione083321

lines 111–113why, one step back
111 end
112 end113

Added session reapingvisionmediabefore adoption8ed99f6

lines 114–136why, one step back
114 describe '#destroy()'
115 it 'should destroy a single session'116 memory.commit({ id: '1' })117 memory.commit({ id: '2' })118 memory.destroy('1')119 memory.store.should.not.have_property '1'120 memory.store.should.have_property '2'121 end122 end123 124 describe '#reap()'125 it 'should destroy sessions older than the given age in milliseconds'126 memory.commit({ id: '1', lastAccess: Number(new Date) - 300 })127 memory.commit({ id: '2', lastAccess: Number(new Date) - 250 })128 memory.commit({ id: '3', lastAccess: Number(new Date) - 100 })129 memory.commit({ id: '4', lastAccess: Number(new Date) })130 memory.reap(200)131 memory.store.should.not.have_property '1'132 memory.store.should.not.have_property '2'133 memory.store.should.have_property '3'134 memory.store.should.have_property '4'135 end136 end

Added Session classvisionmediabefore adoptionfbf547d

line 137why, one step back
137 end

Added session reapingvisionmediabefore adoption8ed99f6

line 138why, one step back
138

Added Session classvisionmediabefore adoptionfbf547d

lines 139–140why, one step back
139 end
140end