summaryrefslogtreecommitdiffstats
path: root/ipa-python/test/test_ipavalidate.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipa-python/test/test_ipavalidate.py')
-rw-r--r--ipa-python/test/test_ipavalidate.py80
1 files changed, 46 insertions, 34 deletions
diff --git a/ipa-python/test/test_ipavalidate.py b/ipa-python/test/test_ipavalidate.py
index de4693c3..8b79fbf0 100644
--- a/ipa-python/test/test_ipavalidate.py
+++ b/ipa-python/test/test_ipavalidate.py
@@ -32,54 +32,66 @@ class TestValidate(unittest.TestCase):
pass
def test_validEmail(self):
- self.assertEqual(0, ipavalidate.Email("test@freeipa.org"))
- self.assertEqual(0, ipavalidate.Email("", notEmpty=False))
+ self.assertEqual(True, ipavalidate.Email("test@freeipa.org"))
+ self.assertEqual(True, ipavalidate.Email("", notEmpty=False))
def test_invalidEmail(self):
- self.assertEqual(1, ipavalidate.Email("test"))
- self.assertEqual(1, ipavalidate.Email("test@freeipa"))
- self.assertEqual(1, ipavalidate.Email("test@.com"))
- self.assertEqual(1, ipavalidate.Email(""))
- self.assertEqual(1, ipavalidate.Email(None))
+ self.assertEqual(False, ipavalidate.Email("test"))
+ self.assertEqual(False, ipavalidate.Email("test@freeipa"))
+ self.assertEqual(False, ipavalidate.Email("test@.com"))
+ self.assertEqual(False, ipavalidate.Email(""))
+ self.assertEqual(False, ipavalidate.Email(None))
def test_validPlain(self):
- self.assertEqual(0, ipavalidate.Plain("Joe User"))
- self.assertEqual(0, ipavalidate.Plain("Joe O'Malley"))
- self.assertEqual(0, ipavalidate.Plain("", notEmpty=False))
- self.assertEqual(0, ipavalidate.Plain(None, notEmpty=False))
- self.assertEqual(0, ipavalidate.Plain("JoeUser", allowSpaces=False))
- self.assertEqual(0, ipavalidate.Plain("JoeUser", allowSpaces=True))
+ self.assertEqual(True, ipavalidate.Plain("Joe User"))
+ self.assertEqual(True, ipavalidate.Plain("Joe O'Malley"))
+ self.assertEqual(True, ipavalidate.Plain("", notEmpty=False))
+ self.assertEqual(True, ipavalidate.Plain(None, notEmpty=False))
+ self.assertEqual(True, ipavalidate.Plain("JoeUser", allowSpaces=False))
+ self.assertEqual(True, ipavalidate.Plain("JoeUser", allowSpaces=True))
def test_invalidPlain(self):
- self.assertEqual(1, ipavalidate.Plain("Joe (User)"))
- self.assertEqual(1, ipavalidate.Plain("Joe C. User"))
- self.assertEqual(1, ipavalidate.Plain("", notEmpty=True))
- self.assertEqual(1, ipavalidate.Plain(None, notEmpty=True))
- self.assertEqual(1, ipavalidate.Plain("Joe User", allowSpaces=False))
+ self.assertEqual(False, ipavalidate.Plain("Joe (User)"))
+ self.assertEqual(False, ipavalidate.Plain("Joe C. User"))
+ self.assertEqual(False, ipavalidate.Plain("", notEmpty=True))
+ self.assertEqual(False, ipavalidate.Plain(None, notEmpty=True))
+ self.assertEqual(False, ipavalidate.Plain("Joe User", allowSpaces=False))
+ self.assertEqual(False, ipavalidate.Plain("Joe C. User"))
def test_validString(self):
- self.assertEqual(0, ipavalidate.String("Joe User"))
- self.assertEqual(0, ipavalidate.String("Joe O'Malley"))
- self.assertEqual(1, ipavalidate.Plain("Joe C. User"))
- self.assertEqual(0, ipavalidate.String("", notEmpty=False))
- self.assertEqual(0, ipavalidate.String(None, notEmpty=False))
+ self.assertEqual(True, ipavalidate.String("Joe User"))
+ self.assertEqual(True, ipavalidate.String("Joe O'Malley"))
+ self.assertEqual(True, ipavalidate.String("", notEmpty=False))
+ self.assertEqual(True, ipavalidate.String(None, notEmpty=False))
+ self.assertEqual(True, ipavalidate.String("Joe C. User"))
def test_invalidString(self):
- self.assertEqual(1, ipavalidate.String("", notEmpty=True))
- self.assertEqual(1, ipavalidate.String(None, notEmpty=True))
+ self.assertEqual(False, ipavalidate.String("", notEmpty=True))
+ self.assertEqual(False, ipavalidate.String(None, notEmpty=True))
def test_validPath(self):
- self.assertEqual(0, ipavalidate.Path("/"))
- self.assertEqual(0, ipavalidate.Path("/home/user"))
- self.assertEqual(0, ipavalidate.Path("../home/user"))
- self.assertEqual(0, ipavalidate.Path("", notEmpty=False))
- self.assertEqual(0, ipavalidate.Path(None, notEmpty=False))
+ self.assertEqual(True, ipavalidate.Path("/"))
+ self.assertEqual(True, ipavalidate.Path("/home/user"))
+ self.assertEqual(True, ipavalidate.Path("../home/user"))
+ self.assertEqual(True, ipavalidate.Path("", notEmpty=False))
+ self.assertEqual(True, ipavalidate.Path(None, notEmpty=False))
def test_invalidPath(self):
- self.assertEqual(1, ipavalidate.Path("(foo)"))
- self.assertEqual(1, ipavalidate.Path("", notEmpty=True))
- self.assertEqual(1, ipavalidate.Path(None, notEmpty=True))
+ self.assertEqual(False, ipavalidate.Path("(foo)"))
+ self.assertEqual(False, ipavalidate.Path("", notEmpty=True))
+ self.assertEqual(False, ipavalidate.Path(None, notEmpty=True))
+
+ def test_validName(self):
+ self.assertEqual(True, ipavalidate.GoodName("foo"))
+ self.assertEqual(True, ipavalidate.GoodName("1foo"))
+ self.assertEqual(True, ipavalidate.GoodName("foo.bar"))
+ self.assertEqual(True, ipavalidate.GoodName("foo.bar$"))
+
+ def test_invalidName(self):
+ self.assertEqual(False, ipavalidate.GoodName("foo bar"))
+ self.assertEqual(False, ipavalidate.GoodName("foo%bar"))
+ self.assertEqual(False, ipavalidate.GoodName("*foo"))
+ self.assertEqual(False, ipavalidate.GoodName("$foo.bar$"))
if __name__ == '__main__':
unittest.main()
-