24 lines
639 B
Go
24 lines
639 B
Go
package admission
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestAllowAllPreservesContextAndIdentityValidation(t *testing.T) {
|
|
t.Parallel()
|
|
var admission AllowAll
|
|
if err := admission.Admit(context.Background(), "client-a"); err != nil {
|
|
t.Fatalf("Admit(valid) error = %v", err)
|
|
}
|
|
if err := admission.Admit(context.Background(), ""); !errors.Is(err, ErrInvalidIdentity) {
|
|
t.Fatalf("Admit(empty identity) error = %v", err)
|
|
}
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
cancel()
|
|
if err := admission.Admit(ctx, "client-a"); !errors.Is(err, context.Canceled) {
|
|
t.Fatalf("Admit(canceled) error = %v", err)
|
|
}
|
|
}
|