-: add one more test

This commit is contained in:
Andrey Meshkov 2019-12-23 17:12:50 +03:00
parent 6bf512f96f
commit 3dd91cf179
3 changed files with 7 additions and 3 deletions

View File

@ -445,6 +445,7 @@ func (clients *clientsContainer) SetWhoisInfo(ip string, info [][]string) {
return return
} }
// Create a ClientHost implicitly so that we don't do this check again
ch = &ClientHost{ ch = &ClientHost{
Source: ClientSourceWHOIS, Source: ClientSourceWHOIS,
} }
@ -525,7 +526,6 @@ func (clients *clientsContainer) addFromHostsFile() {
// The command's output is: // The command's output is:
// HOST (IP) at MAC on IFACE // HOST (IP) at MAC on IFACE
func (clients *clientsContainer) addFromSystemARP() { func (clients *clientsContainer) addFromSystemARP() {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
return return
} }

View File

@ -257,7 +257,6 @@ func (clients *clientsContainer) handleFindClient(w http.ResponseWriter, r *http
} }
cj := clientHostToJSON(ip, ch) cj := clientHostToJSON(ip, ch)
el[ip] = cj el[ip] = cj
} else { } else {
cj := clientToJSON(&c) cj := clientToJSON(&c)
el[ip] = cj el[ip] = cj

View File

@ -190,7 +190,7 @@ func TestClientsAddExistingHost(t *testing.T) {
// add a client // add a client
c = Client{ c = Client{
IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa"}, IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa", "2.2.2.0/24"},
Name: "client1", Name: "client1",
} }
ok, err := clients.Add(c) ok, err := clients.Add(c)
@ -221,4 +221,9 @@ func TestClientsAddExistingHost(t *testing.T) {
ok, err = clients.AddHost(testIP, "test", ClientSourceRDNS) ok, err = clients.AddHost(testIP, "test", ClientSourceRDNS)
assert.False(t, ok) assert.False(t, ok)
assert.Nil(t, err) assert.Nil(t, err)
// don't allow duplicates by CIDR
ok, err = clients.AddHost("2.2.2.2", "test", ClientSourceRDNS)
assert.False(t, ok)
assert.Nil(t, err)
} }