Changeset 7

Show
Ignore:
Timestamp:
2008年07月10日 23时14分12秒 (4 years ago)
Author:
jiangx
Message:

Fixed #2: User shouldn't remove himself/herself from the admin list.

Location:
trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/config

    • Property svn:ignore
      •  

        old new  
        11svn.access 
        22svn.passwd 
         3svn.access.test 
         4svn.passwd.test 
        35localconfig.py 
  • trunk/config/Makefile

    r4 r7  
    11 
    22SRCDIR=../pysvnmanager/config 
    3 CONFFILE=localconfig.py svn.access svn.passwd 
     3CONFFILE=localconfig.py svn.access svn.passwd svn.access.test svn.passwd.test 
    44 
    55all: $(CONFFILE) 
     
    77clean: 
    88        @-rm $(CONFFILE) >/dev/null 2>&1 
    9         @-rm localconfig.py >/dev/null 2>&1 
     9        @-rm localconfig.pyc >/dev/null 2>&1 
    1010 
    1111%: $(SRCDIR)/%.in 
    1212        cp $< $@ 
    1313 
     14%.test: $(SRCDIR)/%.in 
     15        cp $< $@ 
     16 
     17 
    1418.PHONY : all clean  
  • trunk/pysvnmanager/controllers/authz.py

    r4 r7  
    142142 
    143143        reposname = d.get('reposname') 
    144         admins    = d.get('admins') 
     144        admins    = d.get('admins', '') 
    145145        path      = d.get('path') 
    146146        rules     = d.get('rules') 
     
    159159                raise Exception, _("Repository %s not exist.") % reposname 
    160160             
    161             if mode2 == "new": 
    162                 module = self.authz.add_module(reposname, path) 
    163             else: 
    164                 module = self.authz.get_module(reposname, path) 
    165             if path and not module: 
    166                 raise Exception, _("Module %s not exist.") % path 
     161            if path: 
     162                if mode2 == "new": 
     163                    module = self.authz.add_module(reposname, path) 
     164                else: 
     165                    module = self.authz.get_module(reposname, path) 
     166                if not module: 
     167                    raise Exception, _("Module %s not exist.") % path 
     168            else: 
     169                module = None 
    167170             
    168171            repos.admins = admins 
     172            if not repos.is_admin(self.login_as) and \ 
     173                not (repos.name != '/' and self.authz.is_super_user(self.login_as)): 
     174                raise Exception, _("You can not delete yourself from admin list.") 
     175             
    169176            if module: 
    170177                self.authz.set_rules(reposname, path, rules); 
  • trunk/pysvnmanager/i18n/en/LC_MESSAGES/pysvnmanager.po

    r4 r7  
    11# English translations for pysvnmanager. 
    22# Copyright (C) 2008 ORGANIZATION 
    3 # This file is distributed under the same license as the pysvnmanager project. 
     3# This file is distributed under the same license as the pysvnmanager 
     4# project. 
    45# FIRST AUTHOR <EMAIL@ADDRESS>, 2008. 
    56# 
     
    910"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 
    1011"POT-Creation-Date: 2008-07-03 22:14+0800\n" 
    11 "PO-Revision-Date: 2008-07-10 20:03+0800\n" 
     12"PO-Revision-Date: 2008-07-10 22:14+0800\n" 
    1213"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 
    1314"Language-Team: en <LL@li.org>\n" 
     
    7778msgstr "" 
    7879 
    79 #: pysvnmanager/controllers/authz.py:175 
     80#: pysvnmanager/controllers/authz.py:171 
     81msgid "You can not delete yourself from admin list." 
     82msgstr "" 
     83 
     84#: pysvnmanager/controllers/authz.py:179 
    8085#, python-format 
    8186msgid "User %(user)s changed authz rules. (rev:%(rev)s,%(msg)s)" 
    8287msgstr "" 
    8388 
    84 #: pysvnmanager/controllers/authz.py:199 
     89#: pysvnmanager/controllers/authz.py:203 
    8590#, python-format 
    8691msgid "User %(user)s delete authz rules. (rev:%(rev)s,%(msg)s)" 
     
    320325msgstr "" 
    321326 
     327#: pysvnmanager/templates/authz/index.mako:510 
     328msgid "Update ACL failed:" 
     329msgstr "" 
     330 
     331#: pysvnmanager/templates/authz/index.mako:517 
     332msgid "Update ACL successfully." 
     333msgstr "" 
     334 
    322335#: pysvnmanager/templates/authz/index.mako:539 
    323336msgid "No path selected." 
  • trunk/pysvnmanager/i18n/pysvnmanager.pot

    r4 r7  
    99"Project-Id-Version: pySvnManager 0.1.1\n" 
    1010"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 
    11 "POT-Creation-Date: 2008-07-10 20:03+0800\n" 
     11"POT-Creation-Date: 2008-07-10 22:14+0800\n" 
    1212"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 
     
    7171msgstr "" 
    7272 
    73 #: pysvnmanager/controllers/authz.py:175 
     73#: pysvnmanager/controllers/authz.py:171 
     74msgid "You can not delete yourself from admin list." 
     75msgstr "" 
     76 
     77#: pysvnmanager/controllers/authz.py:179 
    7478#, python-format 
    7579msgid "User %(user)s changed authz rules. (rev:%(rev)s,%(msg)s)" 
    7680msgstr "" 
    7781 
    78 #: pysvnmanager/controllers/authz.py:199 
     82#: pysvnmanager/controllers/authz.py:203 
    7983#, python-format 
    8084msgid "User %(user)s delete authz rules. (rev:%(rev)s,%(msg)s)" 
     
    311315msgstr "" 
    312316 
     317#: pysvnmanager/templates/authz/index.mako:510 
     318msgid "Update ACL failed:" 
     319msgstr "" 
     320 
     321#: pysvnmanager/templates/authz/index.mako:517 
     322msgid "Update ACL successfully." 
     323msgstr "" 
     324 
    313325#: pysvnmanager/templates/authz/index.mako:539 
    314326msgid "No path selected." 
  • trunk/pysvnmanager/i18n/zh/LC_MESSAGES/pysvnmanager.po

    r4 r7  
    22# Chinese (China) translations for pysvnmanager. 
    33# Copyright (C) 2008 ORGANIZATION 
    4 # This file is distributed under the same license as the pysvnmanager project. 
     4# This file is distributed under the same license as the pysvnmanager 
     5# project. 
    56# 
    67# FIRST AUTHOR <EMAIL@ADDRESS>, 2008. 
     
    89msgid "" 
    910msgstr "" 
    10 "Project-Id-Version:  pysvnmanager\n" 
     11"Project-Id-Version: pysvnmanager\n" 
    1112"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 
    1213"POT-Creation-Date: 2008-07-03 22:14+0800\n" 
    13 "PO-Revision-Date: 2008-07-10 20:03+0800\n" 
     14"PO-Revision-Date: 2008-07-10 22:15+0800\n" 
    1415"Last-Translator: Jiang Xin <worldhello.net@gmail.com>\n" 
    15 "Language-Team: <zh@li.org>\n" 
     16"Language-Team:  <zh@li.org>\n" 
    1617"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION\n" 
    1718"MIME-Version: 1.0\n" 
    18 "Content-Type: text/plain; charset=utf-8\n" 
     19"Content-Type: text/plain; charset=UTF-8\n" 
    1920"Content-Transfer-Encoding: 8bit\n" 
    2021"Generated-By: Babel 0.9.2\n" 
     22"X-Generator: KBabel 1.11.4\n" 
    2123 
    2224#: pysvnmanager/controllers/authz.py:22 
     
    7981msgstr "模组 %s 不存在。" 
    8082 
    81 #: pysvnmanager/controllers/authz.py:175 
     83#: pysvnmanager/controllers/authz.py:171 
     84msgid "You can not delete yourself from admin list." 
     85msgstr "您不能将自己从管理员列表中删除。" 
     86 
     87#: pysvnmanager/controllers/authz.py:179 
    8288#, python-format 
    8389msgid "User %(user)s changed authz rules. (rev:%(rev)s,%(msg)s)" 
    8490msgstr "用户 %(user)s 修改了授权策略。(rev:%(rev)s,%(msg)s)" 
    8591 
    86 #: pysvnmanager/controllers/authz.py:199 
     92#: pysvnmanager/controllers/authz.py:203 
    8793#, python-format 
    8894msgid "User %(user)s delete authz rules. (rev:%(rev)s,%(msg)s)" 
     
    137143#, python-format 
    138144msgid "Login failed for user: %s" 
    139 msgstr "" 
     145msgstr "以 %s 身份登录失败" 
    140146 
    141147#: pysvnmanager/controllers/security.py:51 
     
    342348msgstr "保存失败。" 
    343349 
     350#: pysvnmanager/templates/authz/index.mako:510 
     351#| msgid "Save failed." 
     352msgid "Update ACL failed:" 
     353msgstr "更新ACL失败:" 
     354 
     355#: pysvnmanager/templates/authz/index.mako:517 
     356msgid "Update ACL successfully." 
     357msgstr "成功更新ACL。" 
     358 
    344359#: pysvnmanager/templates/authz/index.mako:539 
    345360msgid "No path selected." 
  • trunk/pysvnmanager/templates/authz/index.mako

    r2 r7  
    508508        if (message) 
    509509        { 
    510                 message = '${"Update ACL failed:"}' + message; 
     510                message = '${_("Update ACL failed:")}' + message; 
    511511                alert(message); 
    512512                document.getElementById('result').innerHTML = message; 
     
    515515        else 
    516516        { 
    517                 message = '${"Update ACL successfully."}'; 
     517                message = '${_("Update ACL successfully.")}'; 
    518518                document.getElementById('result').innerHTML = message; 
    519519                alert(message); 
  • trunk/pysvnmanager/tests/__init__.py

    r2 r7  
    1111import os 
    1212import sys 
     13from shutil import copyfile 
    1314from unittest import TestCase 
    1415 
     
    4243        TestCase.__init__(self, *args, **kwargs) 
    4344 
     45    def rollback(self): 
     46        src = os.path.dirname(__file__) + '/../config/svn.access.in' 
     47        dest = os.path.dirname(__file__) + '/../../config/svn.access.test' 
     48        copyfile(src, dest) 
     49 
    4450    def login(self, username, password=""): 
    4551        res = self.app.get(url_for(controller='login')) 
  • trunk/pysvnmanager/tests/functional/test_authz.py

    r4 r7  
    33 
    44class TestAuthzController(TestController): 
    5  
    65    def test_index(self): 
    76        # Test redirect to login pange 
     
    7473''' == res.body, res.body 
    7574 
     75    def test_delete_admin(self): 
     76        # Login as superuser 
     77        self.login('root') 
     78        params = {'reposname':'/', 'admins':''} 
     79        res = self.app.get(url_for(controller='authz', action='save_authz'), params) 
     80        assert res.status == 200 
     81        assert "You can not delete yourself from admin list." == res.body, res.body 
     82         
     83        params = {'reposname':'/', 'admins':'root'} 
     84        res = self.app.get(url_for(controller='authz', action='save_authz'), params) 
     85        assert res.status == 200 
     86        assert "" == res.body, res.body 
     87        self.rollback() 
     88         
     89        self.login('root') 
     90        params = {'reposname':'/repos1', 'admins':'user1'} 
     91        res = self.app.get(url_for(controller='authz', action='save_authz'), params) 
     92        assert res.status == 200 
     93        assert "" == res.body, res.body 
     94        self.rollback() 
     95     
     96        self.login('root') 
     97        params = {'reposname':'/repos1', 'admins':'user1, root'} 
     98        res = self.app.get(url_for(controller='authz', action='save_authz'), params) 
     99        assert res.status == 200 
     100        assert "" == res.body, res.body 
     101        self.rollback() 
     102     
     103        self.login('admin1') 
     104        params = {'reposname':'/repos1', 'admins':'user1, root'} 
     105        res = self.app.get(url_for(controller='authz', action='save_authz'), params) 
     106        assert res.status == 200 
     107        assert "You can not delete yourself from admin list." == res.body, res.body 
     108 
     109        self.login('admin1') 
     110        params = {'reposname':'/repos1', 'admins':'admin1, admin2'} 
     111        res = self.app.get(url_for(controller='authz', action='save_authz'), params) 
     112        assert res.status == 200 
     113        assert "" == res.body, res.body 
     114        self.rollback() 
     115     
     116 
    76117    def test_save_authz(self): 
    77118        pass 
  • trunk/test.ini

    r4 r7  
    5050 
    5151# authn_file: a .htpasswd style password file, used for pysvnmanager authentication. 
    52 authn_file = %(here)s/config/svn.passwd 
     52authn_file = %(here)s/config/svn.passwd.test 
    5353 
    5454# authz_file: svn authz config file with administrative extension. (ossxp.com) 
    55 authz_file = %(here)s/config/svn.access 
     55authz_file = %(here)s/config/svn.access.test 
    5656 
    5757# Logging configuration