diff --git a/zititest/models/smoke/capabilities.go b/zititest/models/smoke/capabilities.go index 9a6cb3723..dd492ddfc 100644 --- a/zititest/models/smoke/capabilities.go +++ b/zititest/models/smoke/capabilities.go @@ -50,11 +50,12 @@ var ( Description: "binds SDK-hosted terminators with the JWT service sessions a 2.x controller issues", } - // The floor is the oldest line the compat test has run with OIDC on, not a confirmed boundary. + // Routers before 1.6 handle OIDC api sessions only partly: 1.1 rejects them outright, and 1.6 + // fixed many bugs in the rest. CapOidc = Capability{ Name: "oidc", MinVersion: "v1.6.0", - Description: "accepts OIDC api sessions from a 2.x controller", + Description: "handles the OIDC api sessions SDK clients get from a 2.x controller", } ) @@ -84,6 +85,17 @@ func RouterSupports(m *model.Model, c *model.Component, capability Capability) S return capability.supportedBy(c.Id, router.Version, override, overridden) } +// And reports whether both s and other hold, with both reasons when they don't. +func (s Support) And(other Support) Support { + var reasons []string + for _, support := range []Support{s, other} { + if !support.Supported { + reasons = append(reasons, support.Reason) + } + } + return combine(reasons) +} + // RoutersSupport reports whether every router selected by selector has every one of capabilities. // When one doesn't, Reason lists each gap. func RoutersSupport(m *model.Model, selector string, capabilities ...Capability) Support { @@ -139,8 +151,8 @@ func combine(reasons []string) Support { } // applyCapabilities fits the model's config to what its edge routers support: a router without -// managed link config keeps its link config local, and OIDC defaults off when any router lacks it, -// though an oidc label still decides. It runs after the routers' versions are set. +// managed link config keeps its link config local. It also rejects malformed capability overrides and +// logs what each router lacks. It runs after the routers' versions are set. func applyCapabilities(m *model.Model) error { for _, capability := range Capabilities { if override, found := m.GetStringVariable(capability.variable()); found && override != "on" && override != "off" { @@ -148,8 +160,7 @@ func applyCapabilities(m *model.Model) error { } } - oidc := true - err := m.ForEachComponent(".edge-router", 1, func(c *model.Component) error { + return m.ForEachComponent(".edge-router", 1, func(c *model.Component) error { if support := combine(gaps(m, c, Capabilities)); !support.Supported { pfxlog.Logger().Infof("router capabilities: %s", support.Reason) } @@ -159,17 +170,6 @@ func applyCapabilities(m *model.Model) error { return tag == "ctrl-managed-link" }) } - if !RouterSupports(m, c, CapOidc).Supported { - oidc = false - } return nil }) - if err != nil { - return err - } - - if !oidc { - m.Scope.Defaults["oidc"] = false - } - return nil } diff --git a/zititest/models/smoke/capabilities_test.go b/zititest/models/smoke/capabilities_test.go index edf23a285..e2f59c754 100644 --- a/zititest/models/smoke/capabilities_test.go +++ b/zititest/models/smoke/capabilities_test.go @@ -59,3 +59,14 @@ func TestCapabilityMinVersionsParse(t *testing.T) { require.NoError(t, err, capability.Name) } } + +func TestSupportAnd(t *testing.T) { + yes := Support{Supported: true} + noClient := Support{Reason: "client router lacks it"} + noHost := Support{Reason: "host router lacks it"} + + require.Equal(t, yes, yes.And(yes)) + require.Equal(t, noClient, noClient.And(yes)) + require.Equal(t, noHost, yes.And(noHost)) + require.Equal(t, Support{Reason: "client router lacks it; host router lacks it"}, noClient.And(noHost)) +} diff --git a/zititest/tests/files_test.go b/zititest/tests/files_test.go index ce43b045b..8b7df9252 100644 --- a/zititest/tests/files_test.go +++ b/zititest/tests/files_test.go @@ -111,7 +111,7 @@ func testFileDownload(t *testing.T, hostSelector string, client smoke.HttpClient } name := fmt.Sprintf("%v-(%s<-%s)-%s-%v", client, hostSelector, hostType, fileSize, encDesk) - if support := hostingSupport(hostType); !support.Supported { + if support := pathSupport(hostSelector, hostType); !support.Supported { t.Run(name, func(t *testing.T) { t.Skip(support.Reason) }) return true } diff --git a/zititest/tests/helpers_test.go b/zititest/tests/helpers_test.go index e72cb6fc8..099bb83d2 100644 --- a/zititest/tests/helpers_test.go +++ b/zititest/tests/helpers_test.go @@ -27,9 +27,23 @@ import ( "github.com/openziti/ziti/zititest/zitirest" ) +// sdkClientSupport reports whether the client routers can carry SDK clients' connections. +func sdkClientSupport() smoke.Support { + return smoke.RoutersSupport(run.GetModel(), ".client", smoke.CapOidc) +} + // sdkHostingSupport reports whether the hosting routers can carry SDK-hosted services. func sdkHostingSupport() smoke.Support { - return smoke.RoutersSupport(run.GetModel(), ".host", smoke.CapSdkHosting) + return smoke.RoutersSupport(run.GetModel(), ".host", smoke.CapSdkHosting, smoke.CapOidc) +} + +// clientSupport reports whether the client routers can carry connections from clients of clientType. +// Every client type but the router's own tunneler, "ert", connects through the SDK. +func clientSupport(clientType string) smoke.Support { + if clientType == "ert" { + return smoke.Support{Supported: true} + } + return sdkClientSupport() } // hostingSupport reports whether the hosting routers can carry services hosted by hostType. Every host @@ -41,6 +55,11 @@ func hostingSupport(hostType string) smoke.Support { return sdkHostingSupport() } +// pathSupport reports whether clients of clientType can reach services hosted by hostType. +func pathSupport(clientType, hostType string) smoke.Support { + return clientSupport(clientType).And(hostingSupport(hostType)) +} + // hostedServices returns the encrypted and unencrypted kind services of each of hostTypes that the // hosting routers can carry. func hostedServices(kind string, hostTypes ...string) []string { diff --git a/zititest/tests/iperf_test.go b/zititest/tests/iperf_test.go index 428f29a8e..c59190f46 100644 --- a/zititest/tests/iperf_test.go +++ b/zititest/tests/iperf_test.go @@ -81,7 +81,7 @@ func testIPerf(t *testing.T, hostSelector string, hostType string, encrypted boo success := false t.Run(fmt.Sprintf("(%s%s%s)-%v", hostSelector, direction, hostType, encDesk), func(t *testing.T) { - if support := hostingSupport(hostType); !support.Supported { + if support := pathSupport(hostSelector, hostType); !support.Supported { t.Skip(support.Reason) } o, err := smoke.TestIperf(hostSelector, hostType, encrypted, reversed, run) diff --git a/zititest/tests/scp_test.go b/zititest/tests/scp_test.go index 3b73ba391..9df591cdb 100644 --- a/zititest/tests/scp_test.go +++ b/zititest/tests/scp_test.go @@ -84,7 +84,7 @@ func testScp(t *testing.T, hostSelector string, hostType string, encrypted bool) encDesk = "unencrypted" } - if support := hostingSupport(hostType); !support.Supported { + if support := pathSupport(hostSelector, hostType); !support.Supported { t.Run(fmt.Sprintf("(%s<->%s)-%v", hostSelector, hostType, encDesk), func(t *testing.T) { t.Skip(support.Reason) }) return true } diff --git a/zititest/tests/sim_test.go b/zititest/tests/sim_test.go index 698c554ac..5afcb8fdd 100644 --- a/zititest/tests/sim_test.go +++ b/zititest/tests/sim_test.go @@ -25,7 +25,7 @@ import ( ) func TestSdkSim(t *testing.T) { - if support := sdkHostingSupport(); !support.Supported { + if support := sdkClientSupport().And(sdkHostingSupport()); !support.Supported { t.Skip(support.Reason) } waitForTerminators(t, 30*time.Second, "sim")