comparison MoinMoin/_tests/test_user.py @ 4656:052b6926c82d

test_user: added two tests for the difference of retrieving an user object by uid or name
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 16 Mar 2009 22:35:32 +0100
parents 0d6724b87856
children 1da5c7d21660
comparison
equal deleted inserted replaced
4655:4f76ce232716 4656:052b6926c82d
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 """ 2 """
3 MoinMoin - MoinMoin.user Tests 3 MoinMoin - MoinMoin.user Tests
4 4
5 @copyright: 2003-2004 by Juergen Hermann <jh@web.de> 5 @copyright: 2003-2004 by Juergen Hermann <jh@web.de>
6 2009 by ReimarBauer
6 @license: GNU GPL, see COPYING for details. 7 @license: GNU GPL, see COPYING for details.
7 """ 8 """
8 9
9 import os 10 import os
10 import py 11 import py
148 password = '{SHA}jLIjfQZ5yojbZGTqxg2pY0VROWQ=' # 12345 149 password = '{SHA}jLIjfQZ5yojbZGTqxg2pY0VROWQ=' # 12345
149 self.createUser(name, password, True) 150 self.createUser(name, password, True)
150 theuser = user.User(self.request, name=name, password='12345') 151 theuser = user.User(self.request, name=name, password='12345')
151 assert theuser.enc_password[:6] == '{SSHA}' 152 assert theuser.enc_password[:6] == '{SSHA}'
152 153
154 def test_for_email_attribute_by_name(self):
155 """
156 checks for no access to the email attribute by getting the user object from name
157 """
158 name = u"__TestUser__"
159 password = u"ekfdweurwerh"
160 email = "__TestUser__@moinhost"
161 self.createUser(name, password, True, email=email)
162 theuser = user.User(self.request, name=name)
163 assert theuser.email == ""
164
165 def test_for_email_attribut_by_uid(self):
166 """
167 checks access to the email attribute by getting the user object from the uid
168 """
169 name = u"__TestUser2__"
170 password = u"ekERErwerwerh"
171 email = "__TestUser2__@moinhost"
172 self.createUser(name, password, True, email=email)
173 uid = user.getUserId(self.request, name)
174 theuser = user.User(self.request, uid)
175 assert theuser.email == email
176
153 # Helpers --------------------------------------------------------- 177 # Helpers ---------------------------------------------------------
154 178
155 def createUser(self, name, password, pwencoded=False): 179 def createUser(self, name, password, pwencoded=False, email=None):
156 """ helper to create test user 180 """ helper to create test user
157 """ 181 """
158 # Create user 182 # Create user
159 self.user = user.User(self.request) 183 self.user = user.User(self.request)
160 self.user.name = name 184 self.user.name = name
185 self.user.email = email
161 if not pwencoded: 186 if not pwencoded:
162 password = user.encodePassword(password) 187 password = user.encodePassword(password)
163 self.user.enc_password = password 188 self.user.enc_password = password
164 189
165 # Validate that we are not modifying existing user data file! 190 # Validate that we are not modifying existing user data file!