To add validation for service ports when defined as string (fixing issue #9734)
This commit is contained in:
@@ -154,6 +154,22 @@ func TestIsValidPortNum(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsValidPortName(t *testing.T) {
|
||||
goodValues := []string{"telnet", "re-mail-ck", "pop3", "a", "a-1", "1-a", "a-1-b-2-c", "1-a-2-b-3"}
|
||||
for _, val := range goodValues {
|
||||
if !IsValidPortName(val) {
|
||||
t.Errorf("expected true for '%d'", val)
|
||||
}
|
||||
}
|
||||
|
||||
badValues := []string{"longerthan15characters", "", "12345", "1-2-3-4", "-begin", "end-", "two--hyphens", "1-2", "whois++"}
|
||||
for _, val := range badValues {
|
||||
if IsValidPortName(val) {
|
||||
t.Errorf("expected false for '%d'", val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsQualifiedName(t *testing.T) {
|
||||
successCases := []string{
|
||||
"simple",
|
||||
|
Reference in New Issue
Block a user