Skip to content

Commit

Permalink
static ipam: show confusing error msg
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
  • Loading branch information
maiqueb committed Jun 22, 2021
1 parent 2876cd5 commit 3ca8a2c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions plugins/ipam/static/static_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,39 @@ var _ = Describe("static Operations", func() {
})
Expect(err).Should(MatchError("IPAM config missing 'ipam' key"))
})

It(fmt.Sprintf("[%s] errors when passed an invalid CIDR", ver), func() {
const ifname string = "eth0"
const nspath string = "/some/where"
const ipStr string = "10.10.0.1"

conf := fmt.Sprintf(`{
"cniVersion": "%s",
"name": "mynet",
"type": "bridge",
"ipam": {
"type": "static",
"addresses": [ {
"address": "%s"
}]
}
}`, ver, ipStr)

args := &skel.CmdArgs{
ContainerID: "dummy",
Netns: nspath,
IfName: ifname,
StdinData: []byte(conf),
}

// Allocate the IP
_, _, err := testutils.CmdAddWithArgs(args, func() error {
return cmdAdd(args)
})
Expect(err).Should(
MatchError(fmt.Sprintf("invalid CIDR %s: invalid CIDR address: %s", ipStr, ipStr)))
})

}
})

Expand Down

0 comments on commit 3ca8a2c

Please sign in to comment.