diff --git a/tests/test_sessions.py b/tests/test_sessions.py index 1efd9a865..c5352ae93 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -177,27 +177,6 @@ def test_session_do_not_reuse_id(pub, user, app): assert pub.session_manager.session_class.count() == 2 -def test_session_substitution_variables(pub, user, app): - pub.session_manager.session_class.wipe() - resp = app.get('/') - - formdef = FormDef() - formdef.name = 'foobar' - formdef.fields = [fields.CommentField(id='7', label='Hello [session_id]', type='comment')] - formdef.store() - - resp = app.get('/foobar/') - assert pub.session_manager.session_class.count() == 1 - session_id = pub.session_manager.session_class.select()[0].id - assert 'Hello %s' % session_id in resp.text - - login(app, username='foo', password='foo') - assert pub.session_manager.session_class.count() == 2 - session_id = [x for x in pub.session_manager.session_class.select() if x.id != session_id][0].id - resp = app.get('/foobar/') - assert 'Hello %s' % session_id in resp.text - - def test_session_substitution_variables_1st_page_condition(pub, user, app): pub.session_manager.session_class.wipe() resp = app.get('/') @@ -205,17 +184,15 @@ def test_session_substitution_variables_1st_page_condition(pub, user, app): formdef = FormDef() formdef.name = 'foobar' formdef.fields = [fields.PageField(id='0', label='1st PAGE', type='page', - condition={'type': 'python', 'value': 'vars().get("session_id") is not None'}), - fields.CommentField(id='7', label='COM1 [session_id]', type='comment'), + condition={'type': 'python', 'value': 'vars().get("session_hash_id") is not None'}), fields.CommentField(id='10', label='COMHASH1 [session_hash_id]', type='comment'), fields.PageField(id='8', label='2nd PAGE', type='page'), - fields.CommentField(id='9', label='COM2 [session_id]', type='comment')] + fields.CommentField(id='9', label='COM2 [session_hash_id]', type='comment')] formdef.store() resp = app.get('/foobar/') assert pub.session_manager.session_class.count() == 1 session = pub.session_manager.session_class.select()[0] - assert 'COM1 %s' % session.id in resp.text assert 'COMHASH1 %s' % session.get_substitution_variables().get('session_hash_id') in resp.text diff --git a/wcs/forms/root.py b/wcs/forms/root.py index b7295b1df..af9bc4672 100644 --- a/wcs/forms/root.py +++ b/wcs/forms/root.py @@ -635,7 +635,7 @@ class FormPage(Directory, FormTemplateMixin): session = get_session() if not session.id: # force session to be written down, this is required so - # [session_var_id] is available on the first page. + # [session_hash_id] is available on the first page. session.force() if self.has_draft_support(): diff --git a/wcs/qommon/sessions.py b/wcs/qommon/sessions.py index d194393ba..c75abbdc9 100644 --- a/wcs/qommon/sessions.py +++ b/wcs/qommon/sessions.py @@ -335,7 +335,6 @@ class Session(QommonSession, CaptchaSession, StorableObject): def get_substitution_variables(self, prefix='session_'): d = {} - d[prefix + 'id'] = self.id d[prefix + 'hash_id'] = hashlib.sha1(force_bytes(self.id)).hexdigest() if self.extra_variables: for k, v in self.extra_variables.items():