Add validate the input mac address on docker run command
Signed-off-by: Lei Jitang <leijitang@huawei.com> Upstream-commit: 2ba0fbb0ae1701b638a4bb956187dd878385dc80 Component: engine
This commit is contained in:
@@ -2355,6 +2355,20 @@ func TestRunInspectMacAddress(t *testing.T) {
|
||||
logDone("run - inspecting MAC address")
|
||||
}
|
||||
|
||||
// test docker run use a invalid mac address
|
||||
func TestRunWithInvalidMacAddress(t *testing.T) {
|
||||
defer deleteAllContainers()
|
||||
|
||||
runCmd := exec.Command(dockerBinary, "run", "--mac-address", "92:d0:c6:0a:29", "busybox")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
//use a invalid mac address should with a error out
|
||||
if err == nil || !strings.Contains(out, "is not a valid mac address") {
|
||||
t.Fatalf("run with an invalid --mac-address should with error out")
|
||||
}
|
||||
|
||||
logDone("run - can't use an invalid mac address")
|
||||
}
|
||||
|
||||
func TestRunDeallocatePortOnMissingIptablesRule(t *testing.T) {
|
||||
defer deleteAllContainers()
|
||||
testRequires(t, SameHostDaemon)
|
||||
|
||||
Reference in New Issue
Block a user