diff --git a/controllers/networkHttpController.go b/controllers/networkHttpController.go index d13a41c73..b1f8b07ac 100644 --- a/controllers/networkHttpController.go +++ b/controllers/networkHttpController.go @@ -234,7 +234,7 @@ func keyUpdate(w http.ResponseWriter, r *http.Request) { {"nodeslastmodified", network.NodesLastModified}, {"networklastmodified", network.NetworkLastModified}, {"allowmanualsignup", network.AllowManualSignUp}, - {"defaultcheckininterval", network.DefaultCheckInInterval}, + {"checkininterval", network.DefaultCheckInInterval}, }}, } @@ -406,7 +406,7 @@ func updateNetwork(w http.ResponseWriter, r *http.Request) { {"allowmanualsignup", network.AllowManualSignUp}, {"localrange", network.LocalRange}, {"islocal", network.IsLocal}, - {"defaultcheckininterval", network.DefaultCheckInInterval}, + {"checkininterval", network.DefaultCheckInInterval}, }}, } diff --git a/test/group_test.go b/test/group_test.go index faeed90d5..0ff53b34f 100644 --- a/test/group_test.go +++ b/test/group_test.go @@ -473,22 +473,18 @@ func TestUpdateNetwork(t *testing.T) { assert.Equal(t, network.DefaultPostUp, returnedNetwork.DefaultPostUp) }) t.Run("UpdatePostDown", func(t *testing.T) { - // -------needs fixing ------ - // mismatch in models.Network between struc name and json/bson name - // does not get updated. - type Network struct { - DefaultPreUp string + DefaultPostDown string } var network Network - network.DefaultPreUp = "test string" + network.DefaultPostDown = "test string" response, err := api(t, network, http.MethodPut, baseURL+"/api/networks/skynet", "secretkey") assert.Nil(t, err, err) assert.Equal(t, http.StatusOK, response.StatusCode) defer response.Body.Close() err = json.NewDecoder(response.Body).Decode(&returnedNetwork) assert.Nil(t, err, err) - assert.Equal(t, network.DefaultPreUp, returnedNetwork.DefaultPostDown) + assert.Equal(t, network.DefaultPostDown, returnedNetwork.DefaultPostDown) }) t.Run("UpdateKeepAlive", func(t *testing.T) { type Network struct { @@ -555,38 +551,33 @@ func TestUpdateNetwork(t *testing.T) { assert.Equal(t, network.AllowManualSignUp, returnedNetwork.AllowManualSignUp) }) t.Run("DefaultCheckInterval", func(t *testing.T) { - //value is not updated - t.Skip() type Network struct { - DefaultCheckInInterval int32 + CheckInInterval int32 } var network Network - network.DefaultCheckInInterval = 6000 + network.CheckInInterval = 60 response, err := api(t, network, http.MethodPut, baseURL+"/api/networks/skynet", "secretkey") assert.Nil(t, err, err) assert.Equal(t, http.StatusOK, response.StatusCode) defer response.Body.Close() err = json.NewDecoder(response.Body).Decode(&returnedNetwork) assert.Nil(t, err, err) - assert.Equal(t, network.DefaultCheckInInterval, returnedNetwork.DefaultCheckInInterval) + assert.Equal(t, network.CheckInInterval, returnedNetwork.DefaultCheckInInterval) }) t.Run("DefaultCheckIntervalTooBig", func(t *testing.T) { - //value is not returned in struct --- - t.Skip() - type Network struct { - DefaultCheckInInterval int32 + CheckInInterval int32 } var network Network - network.DefaultCheckInInterval = 100001 + network.CheckInInterval = 100001 response, err := api(t, network, http.MethodPut, baseURL+"/api/networks/skynet", "secretkey") assert.Nil(t, err, err) var message models.ErrorResponse err = json.NewDecoder(response.Body).Decode(&message) assert.Nil(t, err, err) - assert.Equal(t, http.StatusUnprocessableEntity, message.Code) - assert.Equal(t, "W1R3: Field validation for 'DefaultCheckInInterval' failed.", message.Message) - assert.Equal(t, http.StatusUnprocessableEntity, response.StatusCode) + assert.Equal(t, http.StatusBadRequest, message.Code) + assert.Contains(t, message.Message, "Field validation for 'DefaultCheckInInterval' failed") + assert.Equal(t, http.StatusBadRequest, response.StatusCode) }) t.Run("MultipleFields", func(t *testing.T) { type Network struct {