mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +08:00
fixing validation
This commit is contained in:
parent
45895f5f93
commit
0d60cd385b
1 changed files with 2 additions and 14 deletions
|
@ -274,7 +274,7 @@ func TestCreateEgressGateway(t *testing.T) {
|
|||
//assert.False(t, node.IsEgressGateway/g)
|
||||
var gateway models.EgressGatewayRequest
|
||||
t.Run("Valid", func(t *testing.T) {
|
||||
gateway.RangeString = "0.0.0.0/0"
|
||||
gateway.Ranges = ["0.0.0.0/0"]
|
||||
gateway.Interface = "eth0"
|
||||
response, err := api(t, gateway, http.MethodPost, baseURL+"/api/nodes/skynet/01:02:03:04:05:06/creategateway", "secretkey")
|
||||
assert.Nil(t, err, err)
|
||||
|
@ -286,21 +286,9 @@ func TestCreateEgressGateway(t *testing.T) {
|
|||
assert.True(t, message.IsEgressGateway)
|
||||
t.Log(err)
|
||||
})
|
||||
t.Run("BadRange", func(t *testing.T) {
|
||||
gateway.RangeString = "0.0.0.0/36"
|
||||
gateway.Interface = "eth0"
|
||||
response, err := api(t, gateway, http.MethodPost, baseURL+"/api/nodes/skynet/01:02:03:04:05:06/creategateway", "secretkey")
|
||||
assert.Nil(t, err, err)
|
||||
assert.Equal(t, http.StatusInternalServerError, response.StatusCode)
|
||||
defer response.Body.Close()
|
||||
var message models.ErrorResponse
|
||||
err = json.NewDecoder(response.Body).Decode(&message)
|
||||
assert.Nil(t, err, err)
|
||||
assert.Equal(t, http.StatusInternalServerError, message.Code)
|
||||
assert.Equal(t, "IP Range Not Valid", message.Message)
|
||||
})
|
||||
t.Run("BadInterface", func(t *testing.T) {
|
||||
gateway.RangeString = "0.0.0.0/0"
|
||||
gateway.Ranges = ["0.0.0.0/0"]
|
||||
gateway.Interface = ""
|
||||
response, err := api(t, gateway, http.MethodPost, baseURL+"/api/nodes/skynet/01:02:03:04:05:06/creategateway", "secretkey")
|
||||
assert.Nil(t, err, err)
|
||||
|
|
Loading…
Reference in a new issue