mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-08-25 23:07:32 +00:00
fix some unit test failures caused by k8s bump
Signed-off-by: Ryan Richard <richardry@vmware.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021-2024 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2021-2026 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package kubecertagent
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
"go.pinniped.dev/internal/crypto/ptls"
|
||||
@@ -34,11 +33,13 @@ func TestSecureTLS(t *testing.T) {
|
||||
client, err := kubeclient.New(kubeclient.WithConfig(config))
|
||||
require.NoError(t, err)
|
||||
|
||||
// build this exactly like our production could does
|
||||
// Build this exactly like our production code does.
|
||||
podCommandExecutor := NewPodCommandExecutor(client.JSONConfig, client.Kubernetes)
|
||||
|
||||
got, err := podCommandExecutor.Exec(context.Background(), "podNamespace", "podName", "containerName", "command", "arg1", "arg2")
|
||||
require.Equal(t, &apierrors.StatusError{}, err)
|
||||
// Expect to get an error because the fake server above does not allow upgrade to spdy.
|
||||
// This doesn't matter because all we really care about in this test is the results of AssertTLS.
|
||||
require.EqualError(t, err, "unable to upgrade connection: empty server response")
|
||||
require.Empty(t, got)
|
||||
|
||||
require.True(t, sawRequest)
|
||||
|
||||
@@ -135,7 +135,7 @@ func TestCreate(t *testing.T) {
|
||||
wantErrStatus: &metav1.Status{
|
||||
Status: metav1.StatusFailure,
|
||||
Message: `not an OIDCClientSecretRequest: &v1.Status{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ` +
|
||||
`ListMeta:v1.ListMeta{SelfLink:"", ResourceVersion:"", Continue:"", RemainingItemCount:(*int64)(nil)},` +
|
||||
`ListMeta:v1.ListMeta{SelfLink:"", ResourceVersion:"", Continue:"", RemainingItemCount:(*int64)(nil), ShardInfo:(*v1.ShardInfo)(nil)},` +
|
||||
` Status:"", Message:"", Reason:"", Details:(*v1.StatusDetails)(nil), Code:0}`,
|
||||
Reason: metav1.StatusReasonBadRequest,
|
||||
Code: http.StatusBadRequest,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021-2025 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2021-2026 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package whoamirequest
|
||||
@@ -73,8 +73,10 @@ func TestCreate(t *testing.T) {
|
||||
createValidation: nil,
|
||||
options: nil,
|
||||
},
|
||||
want: nil,
|
||||
wantErr: `not a WhoAmIRequest: &v1.Status{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ListMeta:v1.ListMeta{SelfLink:"", ResourceVersion:"", Continue:"", RemainingItemCount:(*int64)(nil)}, Status:"", Message:"", Reason:"", Details:(*v1.StatusDetails)(nil), Code:0}`,
|
||||
want: nil,
|
||||
wantErr: `not a WhoAmIRequest: &v1.Status{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ` +
|
||||
`ListMeta:v1.ListMeta{SelfLink:"", ResourceVersion:"", Continue:"", RemainingItemCount:(*int64)(nil), ShardInfo:(*v1.ShardInfo)(nil)}, ` +
|
||||
`Status:"", Message:"", Reason:"", Details:(*v1.StatusDetails)(nil), Code:0}`,
|
||||
},
|
||||
{
|
||||
name: "bad options",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2024 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2024-2026 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package testutil
|
||||
@@ -16,6 +16,7 @@ func ScrubListOptionsForActions(t *testing.T, actions []coretesting.Action) []co
|
||||
t.Helper()
|
||||
|
||||
scrubbedActions := make([]coretesting.Action, 0, len(actions))
|
||||
|
||||
for _, action := range actions {
|
||||
switch action.GetVerb() {
|
||||
case "watch":
|
||||
@@ -23,7 +24,13 @@ func ScrubListOptionsForActions(t *testing.T, actions []coretesting.Action) []co
|
||||
require.True(t, ok)
|
||||
watchAction.ListOptions.AllowWatchBookmarks = false
|
||||
watchAction.ListOptions.TimeoutSeconds = nil
|
||||
|
||||
// These get filled in starting in k8s 1.36 packages, but we don't care to assert about them.
|
||||
watchAction.ListOptions.ResourceVersion = ""
|
||||
watchAction.WatchRestrictions.ResourceVersion = ""
|
||||
|
||||
scrubbedActions = append(scrubbedActions, watchAction)
|
||||
|
||||
case "list":
|
||||
listAction, ok := action.(coretesting.ListActionImpl)
|
||||
require.True(t, ok)
|
||||
@@ -31,9 +38,11 @@ func ScrubListOptionsForActions(t *testing.T, actions []coretesting.Action) []co
|
||||
listAction.ListOptions.TimeoutSeconds = nil
|
||||
listAction.ListOptions.Limit = 0
|
||||
scrubbedActions = append(scrubbedActions, listAction)
|
||||
|
||||
default:
|
||||
scrubbedActions = append(scrubbedActions, action)
|
||||
}
|
||||
}
|
||||
|
||||
return scrubbedActions
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user