update code for compatibility with Go 1.27

Fix some test expectations and also fix the production code in
impersonator.go to make them compatible with both Go 1.27 and also
with older versions, e.g. Go 1.26. With these changes, all unit
tests pass when run with either Go 1.26 or Go 1.27.

Signed-off-by: Ryan Richard <richardry@vmware.com>
This commit is contained in:
Ryan Richard
2026-08-28 11:45:56 -07:00
parent 74f422a2d9
commit f81d65bcb7
5 changed files with 94 additions and 4 deletions
+7 -2
View File
@@ -1,4 +1,4 @@
// Copyright 2020-2025 the Pinniped contributors. All Rights Reserved.
// Copyright 2020-2026 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package supervisor
@@ -14,6 +14,7 @@ import (
"go.pinniped.dev/internal/here"
"go.pinniped.dev/internal/plog"
"go.pinniped.dev/internal/testutil"
)
func TestFromPath(t *testing.T) {
@@ -424,7 +425,11 @@ func TestFromPath(t *testing.T) {
oidc:
ignoreUserInfoEndpoint: "should be a struct, but is a string"
`),
wantError: "decode yaml: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go struct field OIDCSpec.oidc.ignoreUserInfoEndpoint of type supervisor.IgnoreUserInfoEndpointSpec",
wantError: testutil.StringBasedOnGoVersion(testutil.GoVersionDependentString{
GoVersion: "go1.27",
BeforeVersion: "decode yaml: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go struct field OIDCSpec.oidc.ignoreUserInfoEndpoint of type supervisor.IgnoreUserInfoEndpointSpec",
SinceVersion: "decode yaml: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go struct field .oidc.ignoreUserInfoEndpoint of type supervisor.IgnoreUserInfoEndpointSpec",
}),
},
}
for _, test := range tests {