libnetwork: TestUserChain: don't manually manipulate Controller.cfg.DriverCfg

New() allows for driver-options to be passed using the config.OptionDriverConfig.
Update the test to not manually mutate the controller's configuration after
creating.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-07-16 17:59:29 +02:00
parent ee79423124
commit c471255153
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -5,6 +5,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/libnetwork/config"
"github.com/docker/docker/libnetwork/iptables" "github.com/docker/docker/libnetwork/iptables"
"github.com/docker/docker/libnetwork/netlabel" "github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/libnetwork/options" "github.com/docker/docker/libnetwork/options"
@ -52,15 +53,14 @@ func TestUserChain(t *testing.T) {
defer testutils.SetupTestOSContext(t)() defer testutils.SetupTestOSContext(t)()
defer resetIptables(t) defer resetIptables(t)
c, err := New() c, err := New(config.OptionDriverConfig("bridge", map[string]any{
assert.NilError(t, err)
defer c.Stop()
c.cfg.DriverCfg["bridge"] = map[string]interface{}{
netlabel.GenericData: options.Generic{ netlabel.GenericData: options.Generic{
"EnableIPTables": tc.iptables, "EnableIPTables": tc.iptables,
"EnableIP6Tables": tc.iptables, "EnableIP6Tables": tc.iptables,
}, },
} }))
assert.NilError(t, err)
defer c.Stop()
// init. condition, FORWARD chain empty DOCKER-USER not exist // init. condition, FORWARD chain empty DOCKER-USER not exist
assert.DeepEqual(t, getRules(t, iptables.IPv4, fwdChainName), []string{"-P FORWARD ACCEPT"}) assert.DeepEqual(t, getRules(t, iptables.IPv4, fwdChainName), []string{"-P FORWARD ACCEPT"})