예제 #1
0
def test_logout():
    app = TestApp(application())

    ## forge the session cookie ##
    SID = 'safd32hfsdasdh'
    c = SignedCookie(SECRET_KEY + SID)
    c['SID'] = SID
    c['user'] = '******'
    c['atime'] = timegm(gmtime())
    s = 'Cookie: ' + '; '.join(m.output()[12:] for m in c.values())

    response = app.get('/logout', extra_environ={'HTTP_COOKIE': s})

    res = str(response)
    assert re.search('SID=.*Max-Age=0', res)
    assert re.search('user="foo.*Max-Age=0', res)
    assert re.search('atime=.*Max-Age=0', res)
예제 #2
0
def test_autoexpire():
    app = TestApp(application())

    ## forge the session cookie ##
    SID = 'afds87asg3hasdf'
    c = SignedCookie(SECRET_KEY + SID)
    c['SID'] = SID
    c['user'] = '******'
    c['atime'] = timegm(gmtime()) - SESSION_TTL - 1
    s = 'Cookie: ' + '; '.join(m.output()[12:] for m in c.values())

    response = app.get('/touch', extra_environ={'HTTP_COOKIE': s})

    res = str(response)
    assert re.search('SID=.*Max-Age=0', res)
    assert re.search('user=.*Max-Age=0', res)
    assert re.search('atime=.*Max-Age=0', res)
예제 #3
0
파일: test_session.py 프로젝트: aht/suas
def test_logout():
	app = TestApp(application())

	## forge the session cookie ##
	SID = 'safd32hfsdasdh'
	c = SignedCookie(SECRET_KEY + SID)
	c['SID'] = SID
	c['user'] = '******'
	c['atime'] = timegm( gmtime() )
	s = 'Cookie: '+ '; '.join( m.output()[12:] for m in c.values() )
	
	response = app.get('/logout', extra_environ={'HTTP_COOKIE': s})
	
	res = str(response)
	assert re.search('SID=.*Max-Age=0', res)
	assert re.search('user="foo.*Max-Age=0', res)
	assert re.search('atime=.*Max-Age=0', res)
예제 #4
0
파일: test_session.py 프로젝트: aht/suas
def test_autoexpire():
	app = TestApp(application())

	## forge the session cookie ##
	SID = 'afds87asg3hasdf'
	c = SignedCookie(SECRET_KEY + SID)
	c['SID'] = SID
	c['user'] = '******'
	c['atime'] = timegm( gmtime() ) - SESSION_TTL - 1
	s = 'Cookie: '+ '; '.join( m.output()[12:] for m in c.values() )
	
	response = app.get('/touch', extra_environ={'HTTP_COOKIE': s})
	
	res = str(response)
	assert re.search('SID=.*Max-Age=0', res)
	assert re.search('user=.*Max-Age=0', res)
	assert re.search('atime=.*Max-Age=0', res)
예제 #5
0
def test_regen():
    app = TestApp(application())

    ## forge the session cookie ##
    SID = 'sfh98324igfnad'
    c = SignedCookie(SECRET_KEY + SID)
    c['SID'] = SID
    c['user'] = '******'
    c['atime'] = timegm(gmtime())
    s = 'Cookie: ' + '; '.join(m.output()[12:] for m in c.values())

    response = app.post('/regen', extra_environ={'HTTP_COOKIE': s})

    res = str(response)
    new_SID = re.search('SID="(.*)"', res).group(1)
    new_user = re.search('user="******"', res).group(1)
    assert new_SID[:-SIG_LEN] != c['SID'].value
    assert new_user[:-SIG_LEN] == c['user'].value
    assert new_user != c['user'].coded_value
예제 #6
0
파일: test_session.py 프로젝트: aht/suas
def test_autoregen():
	app = TestApp(application())

	## forge the session cookie ##
	SID = 'klah23dsfohdshds82'
	c = SignedCookie(SECRET_KEY + SID)
	c['SID'] = SID
	c['user'] = '******'
	c['atime'] = timegm( gmtime() ) - SID_TTL - 1
	s = 'Cookie: '+ '; '.join( m.output()[12:] for m in c.values() )
	
	response = app.get('/touch', extra_environ={'HTTP_COOKIE': s})
	
	res = str(response)
	new_SID = re.search('SID="(.*)"', res).group(1)
	new_user = re.search('user="******"', res).group(1)
	assert new_SID[:-SIG_LEN] != c['SID'].value
	assert new_user[:-SIG_LEN] == c['user'].value
	assert new_user != c['user'].coded_value