validate dns entry does not contain whitespace (#2512)

This commit is contained in:
Matthew R Kasun
2023-08-22 02:20:28 -04:00
committed by GitHub
parent a775d7402f
commit d366c23c63
3 changed files with 28 additions and 4 deletions

View File

@@ -400,6 +400,19 @@ func TestValidateDNSCreate(t *testing.T) {
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'name_unique' tag")
})
t.Run("WhiteSpace", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.10.10.5", Name: "white space", Network: "skynet"}
err := logic.ValidateDNSCreate(entry)
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'whitespace' tag")
})
t.Run("AllSpaces", func(t *testing.T) {
entry := models.DNSEntry{Address: "10.10.10.5", Name: " ", Network: "skynet"}
err := logic.ValidateDNSCreate(entry)
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Field validation for 'Name' failed on the 'whitespace' tag")
})
}
func createHost() {