#!/usr/bin/python

import sys
sys.path.insert(0, "../")

import unittest

from UbuntuSystemService.backend.utils import verify_proxy

class testVerifyProxy(unittest.TestCase):

    test_cases = { "http://hh-1h.bla.com:8080/test/test.jsp?d=dd&id=dki" : False,
                   "http://foo:3128" : True,
                   "http://foo:3128/" : True,
                   "http://foo.bar-z.com:3128/" : True,
                   "http://foo.bar.com/port-not-after-host:3" : False,
                   "http://foo:" : False,
                   "does-not-start-with-proto" : False,
                   "http://bad-host-chars?:3128/" : False,
                   "http://host:2182/invalid-chars-in-str\\" : False,
                   "http:no-forward-slashes:3128" :False,
                 }

    def testVerify(self):
        for (str, result) in self.test_cases.iteritems():
            self.assertEqual(verify_proxy("http", str), result,
                             "%s expected %s" % (str, result))


if __name__ == "__main__":
    unittest.main()


