Pull request: all: imp dhcp client hostname normalization

Updates #2952.
Updates #2978.

Squashed commit of the following:

commit 20e379b94ccf8140fd9056429315945c17f711a5
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Apr 19 15:58:37 2021 +0300

    all: imp naming

commit ed300e0563fa37e161406a97991b26a89e23903a
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Apr 19 15:43:09 2021 +0300

    all: imp dhcp client hostname normalization
This commit is contained in:
Ainar Garipov
2021-04-19 16:04:40 +03:00
parent 91304663b7
commit d707f8b1d1
6 changed files with 127 additions and 73 deletions

View File

@@ -88,6 +88,14 @@ func TestValidateDomainName(t *testing.T) {
name: "success_idna",
in: "пример.рф",
wantErrMsg: "",
}, {
name: "success_one",
in: "e",
wantErrMsg: "",
}, {
name: "empty",
in: "",
wantErrMsg: `domain name is empty`,
}, {
name: "bad_symbol",
in: "!!!",
@@ -111,6 +119,11 @@ func TestValidateDomainName(t *testing.T) {
in: "example.-aa.com",
wantErrMsg: `invalid domain name label at index 1:` +
` invalid char '-' at index 0 in "-aa"`,
}, {
name: "bad_label_last_symbol",
in: "example-.aa.com",
wantErrMsg: `invalid domain name label at index 0:` +
` invalid char '-' at index 7 in "example-"`,
}, {
name: "bad_label_symbol",
in: "example.a!!!.com",
@@ -166,7 +179,7 @@ func TestGenerateHostName(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
hostname := GenerateHostName(tc.ip)
hostname := GenerateHostname(tc.ip)
assert.Equal(t, tc.want, hostname)
})
}