18 lines
464 B
Go
18 lines
464 B
Go
package identity
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestPrincipalContext(t *testing.T) {
|
|
if _, ok := PrincipalFromContext(context.Background()); ok {
|
|
t.Fatal("empty context should not contain a principal")
|
|
}
|
|
expected := Principal{Issuer: "issuer", Subject: "subject"}
|
|
actual, ok := PrincipalFromContext(WithPrincipal(context.Background(), expected))
|
|
if !ok || actual != expected {
|
|
t.Fatalf("principal = %#v, %t, want %#v", actual, ok, expected)
|
|
}
|
|
}
|