@@ -73,24 +73,25 @@ def test_parse_server_string(self):
73
73
self .assertEqual (('' , '' ), result )
74
74
75
75
def test_hostname_unicode_sanitization (self ):
76
- hostname = u" \u7684 .test.example.com"
77
- self .assertEqual ("test.example.com" ,
78
- utils .sanitize_hostname (hostname ))
76
+ hostname = u' \u7684 myamazinghostname'
77
+ self .assertEqual (
78
+ 'myamazinghostname' , utils .sanitize_hostname (hostname ))
79
79
80
80
def test_hostname_sanitize_periods (self ):
81
- hostname = " ....test.example.com..."
82
- self .assertEqual ("test.example.com" ,
83
- utils .sanitize_hostname (hostname ))
81
+ hostname = ' ....test.example.com...'
82
+ self .assertEqual (
83
+ 'test-example-com' , utils .sanitize_hostname (hostname ))
84
84
85
85
def test_hostname_sanitize_dashes (self ):
86
- hostname = " ----test.example.com---"
87
- self .assertEqual ("test.example.com" ,
88
- utils .sanitize_hostname (hostname ))
86
+ hostname = ' ----my-amazing-hostname---'
87
+ self .assertEqual (
88
+ "my-amazing-hostname" , utils .sanitize_hostname (hostname ))
89
89
90
90
def test_hostname_sanitize_characters (self ):
91
91
hostname = "(#@&$!(@*--#&91)(__=+--test-host.example!!.com-0+"
92
- self .assertEqual ("91----test-host.example.com-0" ,
93
- utils .sanitize_hostname (hostname ))
92
+ self .assertEqual (
93
+ "91----test-host-example-com-0" ,
94
+ utils .sanitize_hostname (hostname ))
94
95
95
96
def test_hostname_translate (self ):
96
97
hostname = "<}\x1f h\x10 e\x08 l\x02 l\x05 o\x12 !{>"
@@ -99,20 +100,20 @@ def test_hostname_translate(self):
99
100
def test_hostname_has_default (self ):
100
101
hostname = u"\u7684 hello"
101
102
defaultname = "Server-1"
102
- self .assertEqual ("hello" , utils . sanitize_hostname ( hostname ,
103
- defaultname ))
103
+ self .assertEqual (
104
+ "hello" , utils . sanitize_hostname ( hostname , defaultname ))
104
105
105
106
def test_hostname_empty_has_default (self ):
106
107
hostname = u"\u7684 "
107
108
defaultname = "Server-1"
108
- self .assertEqual (defaultname , utils . sanitize_hostname ( hostname ,
109
- defaultname ))
109
+ self .assertEqual (
110
+ defaultname , utils . sanitize_hostname ( hostname , defaultname ))
110
111
111
112
def test_hostname_empty_has_default_too_long (self ):
112
113
hostname = u"\u7684 "
113
114
defaultname = "a" * 64
114
- self .assertEqual ("a" * 63 , utils . sanitize_hostname ( hostname ,
115
- defaultname ))
115
+ self .assertEqual (
116
+ "a" * 63 , utils . sanitize_hostname ( hostname , defaultname ))
116
117
117
118
def test_hostname_empty_no_default (self ):
118
119
hostname = u"\u7684 "
0 commit comments