refactor(10.2-01): nest framework packages under modules
- Move remaining beach packages and embedded admin assets\n- Rewrite framework, example, build, and gate paths
This commit is contained in:
32
modules/bouncer/context_test.go
Normal file
32
modules/bouncer/context_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package bouncer
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestPrincipalLocaleAndCutoff(t *testing.T) {
|
||||
when := time.Unix(1_700_000_000, 0)
|
||||
p := Principal{PreferredLocale: "pl", TokensValidAfter: when}
|
||||
if p.PreferredLocale != "pl" || !p.TokensValidAfter.Equal(when) {
|
||||
t.Fatalf("%+v", p)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextCredentialRoundTrip(t *testing.T) {
|
||||
if _, ok := Credential(t.Context()); ok {
|
||||
t.Fatal("empty context must have no credential")
|
||||
}
|
||||
if _, ok := Credential(nil); ok {
|
||||
t.Fatal("nil context must have no credential")
|
||||
}
|
||||
token := &struct{ Name string }{Name: "parity"}
|
||||
got, ok := Credential(WithCredential(t.Context(), token))
|
||||
if !ok || got != token {
|
||||
t.Fatalf("got %#v ok=%t", got, ok)
|
||||
}
|
||||
got, ok = Credential(WithCredential(nil, token))
|
||||
if !ok || got != token {
|
||||
t.Fatalf("nil ctx got %#v ok=%t", got, ok)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user