mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-01-03 03:35:46 +00:00
plog.TestLogger returns a buffer that holds the logs
# Conflicts: # internal/controller/apicerts/certs_expirer_test.go # internal/plog/plog_test.go # internal/plog/testing.go # pkg/oidcclient/login_test.go
This commit is contained in:
@@ -2555,7 +2555,7 @@ func TestController(t *testing.T) {
|
|||||||
require.Len(t, actualIDP.Status.Conditions, countExpectedConditions)
|
require.Len(t, actualIDP.Status.Conditions, countExpectedConditions)
|
||||||
require.Equal(t, tt.wantResultingUpstreams[i], *actualIDP)
|
require.Equal(t, tt.wantResultingUpstreams[i], *actualIDP)
|
||||||
}
|
}
|
||||||
testutil.RequireLogLines(t, tt.wantLogs, &log)
|
testutil.RequireLogLines(t, tt.wantLogs, log)
|
||||||
|
|
||||||
// This needs to happen after the expected condition LastTransitionTime has been updated.
|
// This needs to happen after the expected condition LastTransitionTime has been updated.
|
||||||
wantActions := make([]coretesting.Action, 3+len(tt.wantResultingUpstreams))
|
wantActions := make([]coretesting.Action, 3+len(tt.wantResultingUpstreams))
|
||||||
|
|||||||
@@ -3941,8 +3941,7 @@ func TestAuthorizationEndpoint(t *testing.T) { //nolint:gocyclo
|
|||||||
if len(test.wantDownstreamAdditionalClaims) > 0 {
|
if len(test.wantDownstreamAdditionalClaims) > 0 {
|
||||||
require.True(t, oidcIDPsCount > 0, "wantDownstreamAdditionalClaims requires at least one OIDC IDP")
|
require.True(t, oidcIDPsCount > 0, "wantDownstreamAdditionalClaims requires at least one OIDC IDP")
|
||||||
}
|
}
|
||||||
var auditLog bytes.Buffer
|
auditLogger, auditLog := plog.TestLogger(t)
|
||||||
auditLogger := plog.TestLogger(t, &auditLog)
|
|
||||||
subject := NewHandler(
|
subject := NewHandler(
|
||||||
downstreamIssuer,
|
downstreamIssuer,
|
||||||
idps,
|
idps,
|
||||||
@@ -3951,7 +3950,7 @@ func TestAuthorizationEndpoint(t *testing.T) { //nolint:gocyclo
|
|||||||
test.stateEncoder, test.cookieEncoder,
|
test.stateEncoder, test.cookieEncoder,
|
||||||
auditLogger,
|
auditLogger,
|
||||||
)
|
)
|
||||||
runOneTestCase(t, test, subject, kubeOauthStore, supervisorClient, kubeClient, secretsClient, &auditLog)
|
runOneTestCase(t, test, subject, kubeOauthStore, supervisorClient, kubeClient, secretsClient, auditLog)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3969,8 +3968,7 @@ func TestAuthorizationEndpoint(t *testing.T) { //nolint:gocyclo
|
|||||||
oauthHelperWithRealStorage, kubeOauthStore := createOauthHelperWithRealStorage(secretsClient, oidcClientsClient)
|
oauthHelperWithRealStorage, kubeOauthStore := createOauthHelperWithRealStorage(secretsClient, oidcClientsClient)
|
||||||
oauthHelperWithNullStorage, _ := createOauthHelperWithNullStorage(secretsClient, oidcClientsClient)
|
oauthHelperWithNullStorage, _ := createOauthHelperWithNullStorage(secretsClient, oidcClientsClient)
|
||||||
idpLister := test.idps.BuildFederationDomainIdentityProvidersListerFinder()
|
idpLister := test.idps.BuildFederationDomainIdentityProvidersListerFinder()
|
||||||
var auditLog bytes.Buffer
|
auditLogger, auditLog := plog.TestLogger(t)
|
||||||
auditLogger := plog.TestLogger(t, &auditLog)
|
|
||||||
subject := NewHandler(
|
subject := NewHandler(
|
||||||
downstreamIssuer,
|
downstreamIssuer,
|
||||||
idpLister,
|
idpLister,
|
||||||
@@ -3980,7 +3978,7 @@ func TestAuthorizationEndpoint(t *testing.T) { //nolint:gocyclo
|
|||||||
auditLogger,
|
auditLogger,
|
||||||
)
|
)
|
||||||
|
|
||||||
runOneTestCase(t, test, subject, kubeOauthStore, supervisorClient, kubeClient, secretsClient, &auditLog)
|
runOneTestCase(t, test, subject, kubeOauthStore, supervisorClient, kubeClient, secretsClient, auditLog)
|
||||||
|
|
||||||
// Call the idpLister's setter to change the upstream IDP settings.
|
// Call the idpLister's setter to change the upstream IDP settings.
|
||||||
newProviderSettings := oidctestutil.NewTestUpstreamOIDCIdentityProviderBuilder().
|
newProviderSettings := oidctestutil.NewTestUpstreamOIDCIdentityProviderBuilder().
|
||||||
@@ -4023,7 +4021,7 @@ func TestAuthorizationEndpoint(t *testing.T) { //nolint:gocyclo
|
|||||||
// modified expectations. This should ensure that the implementation is using the in-memory cache
|
// modified expectations. This should ensure that the implementation is using the in-memory cache
|
||||||
// of upstream IDP settings appropriately in terms of always getting the values from the cache
|
// of upstream IDP settings appropriately in terms of always getting the values from the cache
|
||||||
// on every request.
|
// on every request.
|
||||||
runOneTestCase(t, test, subject, kubeOauthStore, supervisorClient, kubeClient, secretsClient, &auditLog)
|
runOneTestCase(t, test, subject, kubeOauthStore, supervisorClient, kubeClient, secretsClient, auditLog)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
package plog
|
package plog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -355,14 +356,14 @@ func TestPlog(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, test := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
subjectLogger, log := TestLogger(t)
|
testLogger, log := TestLogger(t)
|
||||||
tt.run(subjectLogger)
|
test.run(testLogger)
|
||||||
|
|
||||||
require.Equal(t, strings.TrimSpace(tt.want), strings.TrimSpace(log.String()))
|
require.Equal(t, strings.TrimSpace(test.want), strings.TrimSpace(log.String()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user