Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebhookAuthenticator .Status and validation improvements #1894

Merged
merged 17 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ef36b45
Improve WebhookAuthenticator Status and Validations
benjaminapetersen Feb 21, 2024
590e2d1
Add WebhookAuthenticator integration tests, expand unit tests
benjaminapetersen Feb 21, 2024
337459f
Update webhook status integration tests
benjaminapetersen Mar 13, 2024
5c1fa6d
Adjust testlib/client.go for lint quirk
benjaminapetersen Mar 13, 2024
0467e5c
Refactor logLines to SplitByNewline, deduplicate
benjaminapetersen Mar 18, 2024
a45a537
Improve JWTAuthenticator validation of Issuer,Discovery
benjaminapetersen Mar 13, 2024
097e6d5
Always pass spec to CreateTestWebhookAuthenticator
benjaminapetersen Mar 18, 2024
b6512bc
add WebhookCacheFiller updateStatus tests
benjaminapetersen Mar 18, 2024
5c0d67d
refactor WebhookAuthenticator newWebhookAuthenticator func
benjaminapetersen Mar 19, 2024
90e7343
Add IPv6 test to WebhookAuthenticator ctrl tests
joshuatcasey Mar 19, 2024
5bc4e67
WebhookAuthenticator Status integration test refactor to test table
benjaminapetersen Mar 19, 2024
bec5fe8
change WebhookAuthenticator TLSConnectionNegotiationValid to Connecti…
benjaminapetersen Mar 19, 2024
b0904c2
change TestNewWebhookAuthenticator to test table style
benjaminapetersen Mar 20, 2024
e38a27d
Add endpointaddr.ParseFromURL helper, WebhookAuthenticator handle add…
benjaminapetersen Mar 22, 2024
eed0c9d
Update ParseFromURL usage comment.
benjaminapetersen Mar 26, 2024
f86c46e
Update WebhookAuthenticator Status WebhookConnectionValid
benjaminapetersen Mar 26, 2024
c6b0820
Fix some utils, spacing, func naming, test inputs, etc.
benjaminapetersen Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

type WebhookAuthenticatorPhase string

const (
// WebhookAuthenticatorPhasePending is the default phase for newly-created WebhookAuthenticator resources.
WebhookAuthenticatorPhasePending WebhookAuthenticatorPhase = "Pending"

// WebhookAuthenticatorPhaseReady is the phase for an WebhookAuthenticator resource in a healthy state.
WebhookAuthenticatorPhaseReady WebhookAuthenticatorPhase = "Ready"

// WebhookAuthenticatorPhaseError is the phase for an WebhookAuthenticator in an unhealthy state.
WebhookAuthenticatorPhaseError WebhookAuthenticatorPhase = "Error"
)

// Status of a webhook authenticator.
type WebhookAuthenticatorStatus struct {
// Represents the observations of the authenticator's current state.
Expand All @@ -13,6 +26,10 @@ type WebhookAuthenticatorStatus struct {
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
// Phase summarizes the overall status of the WebhookAuthenticator.
// +kubebuilder:default=Pending
// +kubebuilder:validation:Enum=Pending;Ready;Error
Phase WebhookAuthenticatorPhase `json:"phase,omitempty"`
}

// Spec for configuring a webhook authenticator.
Expand Down
12 changes: 2 additions & 10 deletions cmd/pinniped/cmd/login_oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"testing"
"time"

Expand All @@ -22,6 +21,7 @@ import (
"go.pinniped.dev/internal/certauthority"
"go.pinniped.dev/internal/here"
"go.pinniped.dev/internal/plog"
"go.pinniped.dev/internal/testutil/stringutil"
"go.pinniped.dev/pkg/conciergeclient"
"go.pinniped.dev/pkg/oidcclient"
"go.pinniped.dev/pkg/oidcclient/oidctypes"
Expand Down Expand Up @@ -596,15 +596,7 @@ func TestLoginOIDCCommand(t *testing.T) {
require.Equal(t, tt.wantStderr, stderr.String(), "unexpected stderr")
require.Len(t, gotOptions, tt.wantOptionsCount)

require.Equal(t, tt.wantLogs, logLines(buf.String()))
require.Equal(t, tt.wantLogs, stringutil.SplitByNewline(buf.String()))
})
}
}

func logLines(logs string) []string {
if len(logs) == 0 {
return nil
}

return strings.Split(strings.TrimSpace(logs), "\n")
}
5 changes: 3 additions & 2 deletions cmd/pinniped/cmd/login_static_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package cmd
Expand All @@ -20,6 +20,7 @@ import (
"go.pinniped.dev/internal/certauthority"
"go.pinniped.dev/internal/here"
"go.pinniped.dev/internal/plog"
"go.pinniped.dev/internal/testutil/stringutil"
"go.pinniped.dev/pkg/conciergeclient"
)

Expand Down Expand Up @@ -215,7 +216,7 @@ func TestLoginStaticCommand(t *testing.T) {
require.Equal(t, tt.wantStdout, stdout.String(), "unexpected stdout")
require.Equal(t, tt.wantStderr, stderr.String(), "unexpected stderr")

require.Equal(t, tt.wantLogs, logLines(buf.String()))
require.Equal(t, tt.wantLogs, stringutil.SplitByNewline(buf.String()))
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ spec:
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
phase:
default: Pending
description: Phase summarizes the overall status of the WebhookAuthenticator.
enum:
- Pending
- Ready
- Error
type: string
type: object
required:
- spec
Expand Down
13 changes: 13 additions & 0 deletions generated/1.21/README.adoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions generated/1.22/README.adoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions generated/1.23/README.adoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions generated/1.24/README.adoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading