Attachment 'cache.test1.6.patch'

Download

   1 --- moin-1.6.orig/MoinMoin/_tests/test_user.py	2007-12-01 02:09:09.000000000 +0200
   2 +++ moin-1.6/MoinMoin/_tests/test_user.py	2007-12-04 20:03:37.000000000 +0200
   3 @@ -187,9 +187,117 @@
   4              self.user = None
   5              py.test.skip("Can't create test user")
   6  
   7 +class TestChangeName(object):
   8 +    
   9 +    def setup_method(self, method):
  10 +        # Save original user and cookie
  11 +        self.saved_cookie = self.request.saved_cookie
  12 +        self.saved_user = self.request.user
  13 +
  14 +        # Create anon user for the tests
  15 +        self.request.saved_cookie = ''
  16 +        self.request.user = user.User(self.request)
  17 +
  18 +        # Prevent user list caching - we create and delete users too fast for that.
  19 +        filesys.dcdisable()
  20 +        self.user = None
  21 +        
  22 +    def teardown_method(self, method):
  23 +        """ Run after each test
  24  
  25 -class TestGroupName(object):
  26 +        Remove user and reset user listing cache.
  27 +        """
  28 +        # Remove user file and user
  29 +        if self.user is not None:
  30 +            try:
  31 +                path = self.user._User__filename()
  32 +                os.remove(path)
  33 +            except OSError:
  34 +                pass
  35 +            del self.user
  36 +
  37 +        # Restore original user
  38 +        self.request.saved_cookie = self.saved_cookie
  39 +        self.request.user = self.saved_user
  40 +
  41 +        # Remove user name to id cache, or next test will fail
  42 +        caching.CacheEntry(self.request, 'user', 'name2id', scope='wiki').remove()
  43 +        try:
  44 +            del self.request.cfg.cache.name2id
  45 +        except:
  46 +            pass
  47 +
  48 +        # Prevent user list caching - we create and delete users too fast for that.
  49 +        filesys.dcdisable
  50 +
  51 +    def testChangeUsername(self):
  52 +        """ Attempt to create a user, then rename it.
  53 +        If we can still login with the old username, the test has failed.
  54 +        """
  55 +
  56 +        # Create test user
  57 +        name = u'__Non Existent User Name__'
  58 +        password = name
  59 +        self.createUser(name, password)
  60 +
  61 +        # Perform login with username
  62 +        oldUser = user.User(self.request, name=name, password=password)
  63 +        
  64 +        # Change username from name to name + xxx
  65 +        self.changeUser(name, password, name + "xxx")
  66 +        
  67 +        # See if we can still login with the old username
  68 +        newUser = user.User(self.request, name=name, password=password)
  69 +        assert not newUser.valid
  70 +
  71 +    def createUser(self, name, password, charset='utf-8'):
  72 +        """ helper to create test user
  73 +
  74 +        charset is used to create user with pre 1.3 password hash
  75 +        """
  76 +        # Hack self.request form to contain the password
  77 +        self.request.form['password'] = [password]
  78  
  79 +        # Create user
  80 +        self.user = user.User(self.request)
  81 +        self.user.name = name
  82 +        self.user.enc_password = user.encodePassword(password, charset=charset)
  83 +
  84 +        # Validate that we are not modifying existing user data file!
  85 +        if self.user.exists():
  86 +            self.user = None
  87 +            py.test.skip("Test user exists, will not override existing user data file!")
  88 +
  89 +        # Save test user
  90 +        self.user.save()
  91 +
  92 +        # Validate user creation
  93 +        if not self.user.exists():
  94 +            self.user = None
  95 +            py.test.skip("Can't create test user")
  96 +    
  97 +    def changeUser(self, name, password, newname):
  98 +        """ helper to change a username """
  99 +        self.user = user.User(self.request, name=name, password=password)
 100 +        self.user.name = newname
 101 +        self.user.save()
 102 +        cache = caching.CacheEntry(self.request, 'user', 'name2id', scope='wiki', use_pickle=True)
 103 +        cache.remove()
 104 +    
 105 +class TestGroupName(object):
 106 +    def setup_method(self, method):
 107 +        # Save original user and cookie
 108 +        self.saved_cookie = self.request.saved_cookie
 109 +        self.saved_user = self.request.user
 110 +
 111 +        # Create anon user for the tests
 112 +        self.request.saved_cookie = ''
 113 +        self.request.user = user.User(self.request)
 114 +
 115 +        # Prevent user list caching - we create and delete users too fast for that.
 116 +        filesys.dcdisable()
 117 +        self.user = None
 118 +        
 119      def setUp(self):
 120          self.config = self.TestConfig(page_group_regex=r'.+Group')
 121  

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2007-12-04 21:39:37, 4.2 KB) [[attachment:cache.test1.6.patch]]
  • [get | view] (2007-12-04 21:38:47, 2.7 KB) [[attachment:cache1.6.patch]]
  • [get | view] (2007-12-04 21:38:57, 2.7 KB) [[attachment:cache1.7.patch]]
  • [get | view] (2007-12-30 21:22:29, 23.1 KB) [[attachment:documentation.patch]]
  • [get | view] (2007-12-11 21:27:01, 10.5 KB) [[attachment:package.patch]]
  • [get | view] (2007-12-11 21:26:48, 3.5 KB) [[attachment:packagetest.patch]]
  • [get | view] (2007-12-04 21:39:22, 3.1 KB) [[attachment:quicklink.patch]]
  • [get | view] (2008-01-29 16:42:22, 171.8 KB) [[attachment:screenschot.png]]
  • [get | view] (2007-12-04 21:42:03, 3.8 KB) [[attachment:subscribe.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.