From 3dd91cf17962b4b5d39f31424adeeab579416666 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Mon, 23 Dec 2019 17:12:50 +0300 Subject: [PATCH] -: add one more test --- home/clients.go | 2 +- home/clients_http.go | 1 - home/clients_test.go | 7 ++++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/home/clients.go b/home/clients.go index 64d67e86..468cdfe0 100644 --- a/home/clients.go +++ b/home/clients.go @@ -445,6 +445,7 @@ func (clients *clientsContainer) SetWhoisInfo(ip string, info [][]string) { return } + // Create a ClientHost implicitly so that we don't do this check again ch = &ClientHost{ Source: ClientSourceWHOIS, } @@ -525,7 +526,6 @@ func (clients *clientsContainer) addFromHostsFile() { // The command's output is: // HOST (IP) at MAC on IFACE func (clients *clientsContainer) addFromSystemARP() { - if runtime.GOOS == "windows" { return } diff --git a/home/clients_http.go b/home/clients_http.go index e1cea2cf..34401727 100644 --- a/home/clients_http.go +++ b/home/clients_http.go @@ -257,7 +257,6 @@ func (clients *clientsContainer) handleFindClient(w http.ResponseWriter, r *http } cj := clientHostToJSON(ip, ch) el[ip] = cj - } else { cj := clientToJSON(&c) el[ip] = cj diff --git a/home/clients_test.go b/home/clients_test.go index 8ba06a1c..457b8aef 100644 --- a/home/clients_test.go +++ b/home/clients_test.go @@ -190,7 +190,7 @@ func TestClientsAddExistingHost(t *testing.T) { // add a 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", } ok, err := clients.Add(c) @@ -221,4 +221,9 @@ func TestClientsAddExistingHost(t *testing.T) { ok, err = clients.AddHost(testIP, "test", ClientSourceRDNS) assert.False(t, ok) 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) }