Skip to content

Commit

Permalink
Add TC for making sure DOCKER-USER exists
Browse files Browse the repository at this point in the history
Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
  • Loading branch information
Arko Dasgupta committed Oct 11, 2019
1 parent 083c739 commit a8417b6
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions drivers/bridge/bridge_test.go
Expand Up @@ -19,6 +19,41 @@ import (
"github.com/vishvananda/netlink"
)

// TestEnableIPTables enables EnableIPTables and checks if
// the DOCKER-USER chain is created or not
func TestEnableIPTables(t *testing.T) {
if !testutils.IsRunningInContainer() {
defer testutils.SetupTestOSContext(t)()
}

d := newDriver()

config := &configuration{
EnableIPTables: true,
}
genericOption := make(map[string]interface{})
genericOption[netlabel.GenericData] = config

if err := d.configure(genericOption); err != nil {
t.Fatalf("Failed to setup driver config: %v", err)
}

userRule1 := []string{
"-j", "DOCKER-USER"}

if !iptables.Exists(iptables.Filter, "FORWARD", userRule1...) {
t.Fatal("rule does not exist")
}

userRule2 := []string{
"-j", "RETURN"}

if !iptables.Exists(iptables.Filter, "DOCKER-USER", userRule2...) {
t.Fatal("rule does not exist")
}

}

func TestEndpointMarshalling(t *testing.T) {
ip1, _ := types.ParseCIDR("172.22.0.9/16")
ip2, _ := types.ParseCIDR("2001:db8::9")
Expand Down

0 comments on commit a8417b6

Please sign in to comment.