예제 #1
0
파일: test_utils.py 프로젝트: PyRoOP/open
    def test_utils_is_valid_hostname_invalid(self):
        """Verify is_valid_hostname can detect None or too-long hostnames"""
        # A hostname that's empty, None, or more than 255 chars is invalid
        empty_hostname = ''
        res = is_valid_hostname(empty_hostname)
        self.assertFalse(res)

        none_hostname = None
        res = is_valid_hostname(none_hostname)
        self.assertFalse(res)

        too_long_hostname = "a" * 256
        res = is_valid_hostname(too_long_hostname)
        self.assertFalse(res)
예제 #2
0
    def test_utils_is_valid_hostname_invalid(self):
        """Verify is_valid_hostname can detect None or too-long hostnames"""
        # A hostname that's empty, None, or more than 255 chars is invalid
        empty_hostname = ''
        res = is_valid_hostname(empty_hostname)
        self.assertFalse(res)

        none_hostname = None
        res = is_valid_hostname(none_hostname)
        self.assertFalse(res)

        too_long_hostname = "a" * 256
        res = is_valid_hostname(too_long_hostname)
        self.assertFalse(res)
예제 #3
0
파일: test_utils.py 프로젝트: PyRoOP/open
 def test_utils_is_valid_hostname_normal_hostname(self):
     """Verify is_valid_hostname can parse regular hostnames"""
     hostname = "foo.example.com"
     res = is_valid_hostname(hostname)
     self.assertTrue(res)
예제 #4
0
파일: test_utils.py 프로젝트: PyRoOP/open
 def test_utils_is_valid_hostname_ends_with_dot(self):
     """Verify is_valid_hostname can parse hostnames with trailing periods"""
     hostname = "foo.example.com."
     res = is_valid_hostname(hostname)
     self.assertTrue(res)
예제 #5
0
def validate_prompt_hostname(hostname):
    if hostname == '' or utils.is_valid_hostname(hostname):
        return hostname
    raise click.BadParameter('Invalid hostname. Please double-check this value and re-enter it.')
예제 #6
0
 def test_utils_is_valid_hostname_normal_hostname(self):
     """Verify is_valid_hostname can parse regular hostnames"""
     hostname = "foo.example.com"
     res = is_valid_hostname(hostname)
     self.assertTrue(res)
예제 #7
0
 def test_utils_is_valid_hostname_ends_with_dot(self):
     """Verify is_valid_hostname can parse hostnames with trailing periods"""
     hostname = "foo.example.com."
     res = is_valid_hostname(hostname)
     self.assertTrue(res)
예제 #8
0
def validate_prompt_hostname(hostname):
    if hostname == '' or utils.is_valid_hostname(hostname):
        return hostname
    raise click.BadParameter(
        'Invalid hostname. Please double-check this value and re-enter it.')