summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8116d2f)
raw | patch | inline | side by side (parent: 8116d2f)
| author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
| Tue, 14 Jan 2003 22:21:35 +0000 (22:21 +0000) | ||
| committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
| Tue, 14 Jan 2003 22:21:35 +0000 (22:21 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1456 57a73879-2fb5-44c3-a270-3262357dd7e2
| CHANGES.txt | patch | blob | history | |
| roundup/cgi/client.py | patch | blob | history | |
| test/test_cgi.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index ab49ca577758a2d1822ed5af7b432ecd37a7c7dd..d52a001d78308a82224a5051929e1e5968bc25c5 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
request. It is greatly improves web interface performance, especially
on trackers under high load
- fix StringHTMLProperty hyperlinking
+- added mysql backend
+- fixes to CGI form handling (NEEDS BACKPORTING TO 0.5)
+
2003-??-?? 0.5.5
- fixed rdbms searching by ID (sf bug 666615)
diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py
index b2ee2072ec5f58eea2be6500c7fa8a83403749fd..b4a310fb94046759798530f263f198976cf1420a 100644 (file)
--- a/roundup/cgi/client.py
+++ b/roundup/cgi/client.py
-# $Id: client.py,v 1.67 2003-01-13 22:14:00 kedder Exp $
+# $Id: client.py,v 1.68 2003-01-14 22:21:35 richard Exp $
__doc__ = """
WWW request handler (also used in the stand-alone server).
value = value.value.strip()
if isinstance(proptype, hyperdb.String):
- if not value:
- continue
# fix the CRLF/CR -> LF stuff
value = fixNewlines(value)
elif isinstance(proptype, hyperdb.Password):
if not properties.has_key(propname):
raise
+ # existing may be None, which won't equate to empty strings
+ if not existing and not value:
+ continue
+
# if changed, set it
if value != existing:
props[propname] = value
else:
+ # don't bother setting empty/unset values
+ if not value:
+ continue
props[propname] = value
# see if all the required properties have been supplied
diff --git a/test/test_cgi.py b/test/test_cgi.py
index 857d41d1a16d4cc582413f73c2bf5402a51fed79..d9887a2ebacaa1bf8aa9f9ad5d56c84828cfaec3 100644 (file)
--- a/test/test_cgi.py
+++ b/test/test_cgi.py
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: test_cgi.py,v 1.1 2003-01-14 06:15:58 richard Exp $
+# $Id: test_cgi.py,v 1.2 2003-01-14 22:21:35 richard Exp $
import unittest, os, shutil, errno, sys, difflib, cgi
from roundup.cgi import client
-from roundup import init, instance
+from roundup import init, instance, password
def makeForm(args):
form = cgi.FieldStorage()
for k,v in args.items():
if type(v) is type([]):
- form.list.append([cgi.MiniFieldStorage(k, x) for x in v])
+ [form.list.append(cgi.MiniFieldStorage(k, x)) for x in v]
else:
form.list.append(cgi.MiniFieldStorage(k, v))
return form
except OSError, error:
if error.errno not in (errno.ENOENT, errno.ESRCH): raise
- def testParseNothing(self):
- client.parsePropsFromForm(self.db, self.db.issue, makeForm({}))
+ #
+ # Empty form
+ #
+ def testNothing(self):
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({})), {})
- def testParseNothingWithRequired(self):
+ def testNothingWithRequired(self):
form = makeForm({':required': 'title'})
self.assertRaises(ValueError, client.parsePropsFromForm, self.db,
self.db.issue, form)
+ #
+ # String
+ #
+ def testEmptyString(self):
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'title': ''})), {})
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'title': ' '})), {})
+
+ def testSetString(self):
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'title': 'foo'})), {'title': 'foo'})
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'title': 'a\r\nb\r\n'})), {'title': 'a\nb'})
+
+ def testEmptyStringSet(self):
+ nodeid = self.db.issue.create(title='foo')
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'title': ''}), nodeid), {'title': ''})
+ nodeid = self.db.issue.create(title='foo')
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'title': ' '}), nodeid), {'title': ''})
+
+ #
+ # Multilink
+ #
+ def testEmptyMultilink(self):
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'nosy': ''})), {})
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'nosy': ' '})), {})
+
+ def testSetMultilink(self):
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'nosy': '1'})), {'nosy': ['1']})
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'nosy': ['1','2']})), {'nosy': ['1','2']})
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'nosy': '1,2'})), {'nosy': ['1','2']})
+
+ def testEmptyMultilinkSet(self):
+ nodeid = self.db.issue.create(nosy=['1','2'])
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'nosy': ''}), nodeid), {'nosy': []})
+ nodeid = self.db.issue.create(nosy=['1','2'])
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue,
+ makeForm({'nosy': ' '}), nodeid), {'nosy': []})
+
+ #
+ # Password
+ #
+ def testEmptyPassword(self):
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.user,
+ makeForm({'password': ''})), {})
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.user,
+ makeForm({'password': ''})), {})
+
+ def testSetPassword(self):
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.user,
+ makeForm({'password': 'foo', 'password:confirm': 'foo'})),
+ {'password': 'foo'})
+
+ def testSetPasswordConfirmBad(self):
+ self.assertRaises(ValueError, client.parsePropsFromForm, self.db,
+ self.db.user, makeForm({'password': 'foo'}))
+ self.assertRaises(ValueError, client.parsePropsFromForm, self.db,
+ self.db.user, makeForm({'password': 'foo',
+ 'password:confirm': 'bar'}))
+
+ def testEmptyPasswordNOTSet(self):
+ nodeid = self.db.user.create(username='1', password=password.Password('foo'))
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.user,
+ makeForm({'password': ''}), nodeid), {})
+ nodeid = self.db.user.create(username='2', password=password.Password('foo'))
+ self.assertEqual(client.parsePropsFromForm(self.db, self.db.user,
+ makeForm({'password': '', 'password:confirm': ''}), nodeid), {})
+
def suite():
l = [unittest.makeSuite(FormTestCase),