Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin._tests.test_user.TestLoginWithPassword Class Reference

List of all members.

Public Member Functions

def setup_method
def teardown_method
def testAsciiPassword
def testUnicodePassword
def testSubscriptionSubscribedPage
def testSubscriptionSubPage
def testRenameUser
def test_upgrade_password_to_salted
def test_for_email_attribute_by_name
def test_for_email_attribut_by_uid
def createUser

Public Attributes

 saved_cookie
 saved_user
 user

Detailed Description

user: login tests

Definition at line 37 of file test_user.py.


Member Function Documentation

def MoinMoin._tests.test_user.TestLoginWithPassword.createUser (   self,
  name,
  password,
  pwencoded = False,
  email = None 
)
helper to create test user

Definition at line 179 of file test_user.py.

00179 
00180     def createUser(self, name, password, pwencoded=False, email=None):
00181         """ helper to create test user
00182         """
00183         # Create user
00184         self.user = user.User(self.request)
00185         self.user.name = name
00186         self.user.email = email
00187         if not pwencoded:
00188             password = user.encodePassword(password)
00189         self.user.enc_password = password
00190 
00191         # Validate that we are not modifying existing user data file!
00192         if self.user.exists():
00193             self.user = None
00194             py.test.skip("Test user exists, will not override existing user data file!")
00195 
00196         # Save test user
00197         self.user.save()
00198 
00199         # Validate user creation
00200         if not self.user.exists():
00201             self.user = None
00202             py.test.skip("Can't create test user")
00203 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 40 of file test_user.py.

00040 
00041     def setup_method(self, method):
00042         # Save original user and cookie
00043         self.saved_cookie = self.request.cookies
00044         self.saved_user = self.request.user
00045 
00046         # Create anon user for the tests
00047         self.request.cookies = {}
00048         self.request.user = user.User(self.request)
00049 
00050         # Prevent user list caching - we create and delete users too fast for that.
00051         filesys.dcdisable()
00052         self.user = None

Run after each test

Remove user and reset user listing cache.

Definition at line 53 of file test_user.py.

00053 
00054     def teardown_method(self, method):
00055         """ Run after each test
00056 
00057         Remove user and reset user listing cache.
00058         """
00059         # Remove user file and user
00060         if self.user is not None:
00061             try:
00062                 path = self.user._User__filename()
00063                 os.remove(path)
00064             except OSError:
00065                 pass
00066             del self.user
00067 
00068         # Restore original user
00069         self.request.cookies = self.saved_cookie
00070         self.request.user = self.saved_user
00071 
00072         # Remove user name to id cache, or next test will fail
00073         caching.CacheEntry(self.request, 'user', 'name2id', scope='wiki').remove()
00074         try:
00075             del self.request.cfg.cache.name2id
00076         except:
00077             pass
00078 
00079         # Prevent user list caching - we create and delete users too fast for that.
00080         filesys.dcdisable()

Here is the call graph for this function:

checks access to the email attribute by getting the user object from the uid

Definition at line 165 of file test_user.py.

00165 
00166     def test_for_email_attribut_by_uid(self):
00167         """
00168         checks access to the email attribute by getting the user object from the uid
00169         """
00170         name = u"__TestUser2__"
00171         password = u"ekERErwerwerh"
00172         email = "__TestUser2__@moinhost"
00173         self.createUser(name, password, email=email)
00174         uid = user.getUserId(self.request, name)
00175         theuser = user.User(self.request, uid)
00176         assert theuser.email == email

Here is the call graph for this function:

checks for no access to the email attribute by getting the user object from name

Definition at line 154 of file test_user.py.

00154 
00155     def test_for_email_attribute_by_name(self):
00156         """
00157         checks for no access to the email attribute by getting the user object from name
00158         """
00159         name = u"__TestUser__"
00160         password = u"ekfdweurwerh"
00161         email = "__TestUser__@moinhost"
00162         self.createUser(name, password, email=email)
00163         theuser = user.User(self.request, name=name)
00164         assert theuser.email == ""

Here is the call graph for this function:

Create user with {SHA} password and check that logging in
upgrades to {SSHA}.

Definition at line 143 of file test_user.py.

00143 
00144     def test_upgrade_password_to_salted(self):
00145         """
00146         Create user with {SHA} password and check that logging in
00147         upgrades to {SSHA}.
00148         """
00149         name = u'/no such user/'
00150         password = '{SHA}jLIjfQZ5yojbZGTqxg2pY0VROWQ=' # 12345
00151         self.createUser(name, password, True)
00152         theuser = user.User(self.request, name=name, password='12345')
00153         assert theuser.enc_password[:6] == '{SSHA}'

Here is the call graph for this function:

user: login with ascii password 

Definition at line 81 of file test_user.py.

00081 
00082     def testAsciiPassword(self):
00083         """ user: login with ascii password """
00084         # Create test user
00085         name = u'__Non Existent User Name__'
00086         password = name
00087         self.createUser(name, password)
00088 
00089         # Try to "login"
00090         theUser = user.User(self.request, name=name, password=password)
00091         assert theUser.valid

Here is the call graph for this function:

create user and then rename user and check
if the old username is removed from the cache name2id

Definition at line 126 of file test_user.py.

00126 
00127     def testRenameUser(self):
00128         """ create user and then rename user and check
00129         if the old username is removed from the cache name2id
00130         """
00131         # Create test user
00132         name = u'__Some Name__'
00133         password = name
00134         self.createUser(name, password)
00135         # Login - this should replace the old password in the user file
00136         theUser = user.User(self.request, name=name)
00137         # Rename user
00138         theUser.name = u'__SomeName__'
00139         theUser.save()
00140         theUser = user.User(self.request, name=name, password=password)
00141 
00142         assert not theUser.exists()

Here is the call graph for this function:

user: tests isSubscribedTo on a subpage 

Definition at line 114 of file test_user.py.

00114 
00115     def testSubscriptionSubPage(self):
00116         """ user: tests isSubscribedTo on a subpage """
00117         pagename = u'HelpMiscellaneous'
00118         testPagename = u'HelpMiscellaneous/FrequentlyAskedQuestions'
00119         name = u'__Jürgen Herman__'
00120         password = name
00121         self.createUser(name, password)
00122         # Login - this should replace the old password in the user file
00123         theUser = user.User(self.request, name=name, password=password)
00124         theUser.subscribe(pagename)
00125         assert not theUser.isSubscribedTo([testPagename]) # list(!) of pages to check

Here is the call graph for this function:

user: tests isSubscribedTo  

Definition at line 103 of file test_user.py.

00103 
00104     def testSubscriptionSubscribedPage(self):
00105         """ user: tests isSubscribedTo  """
00106         pagename = u'HelpMiscellaneous'
00107         name = u'__Jürgen Herman__'
00108         password = name
00109         self.createUser(name, password)
00110         # Login - this should replace the old password in the user file
00111         theUser = user.User(self.request, name=name, password=password)
00112         theUser.subscribe(pagename)
00113         assert theUser.isSubscribedTo([pagename]) # list(!) of pages to check

Here is the call graph for this function:

user: login with non-ascii password 

Definition at line 92 of file test_user.py.

00092 
00093     def testUnicodePassword(self):
00094         """ user: login with non-ascii password """
00095         # Create test user
00096         name = u'__שם משתמש לא קיים__' # Hebrew
00097         password = name
00098         self.createUser(name, password)
00099 
00100         # Try to "login"
00101         theUser = user.User(self.request, name=name, password=password)
00102         assert theUser.valid

Here is the call graph for this function:


Member Data Documentation

Definition at line 42 of file test_user.py.

Definition at line 43 of file test_user.py.

Definition at line 51 of file test_user.py.


The documentation for this class was generated from the following file: