feat(storage): add native PostgreSQL runtime and verified offline application import
Build and publish container images / images (push) Failing after 12m29s
Build and publish container images / images (push) Failing after 12m29s
This commit is contained in:
1 parent
96065d1e89
commit
0ba1dcfef0
243 files changed
+21441
-3090
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMagicLinkIdentityBackend(t *testing.T) {
|
||||
for _, backend := range []storeSQLBackend{storeSQLite, storePostgreSQL} {
|
||||
t.Run(fmt.Sprint(backend), func(t *testing.T) {
|
||||
s, d := accountBackendStore(t, backend)
|
||||
p, err := s.BootstrapOwner(d, "magic-owner", "synthetic login password", "Owner", "synthetic@example.test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
for _, tc := range []struct {
|
||||
domain, email string
|
||||
want bool
|
||||
}{
|
||||
{d, "synthetic@example.test", true}, {d, "", false}, {d, "old@example.test", false}, {"other-domain", "synthetic@example.test", false},
|
||||
} {
|
||||
valid, err := s.ValidateMagicLinkIdentity(ctx, tc.domain, p.UUID, tc.email)
|
||||
if err != nil || valid != tc.want {
|
||||
t.Fatal("identity validation", valid, err)
|
||||
}
|
||||
}
|
||||
if err = s.UpdatePrincipalProfile(p.UUID, "Owner", "changed@example.test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if valid, err := s.ValidateMagicLinkIdentity(ctx, d, p.UUID, "synthetic@example.test"); err != nil || valid {
|
||||
t.Fatal("old email accepted", valid, err)
|
||||
}
|
||||
if _, err = s.DB.Exec(`UPDATE domain_memberships SET state='suspended' WHERE domain_uuid=`+s.sqlParam(1), d); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if valid, err := s.ValidateMagicLinkIdentity(ctx, d, p.UUID, "changed@example.test"); err != nil || valid {
|
||||
t.Fatal("inactive member accepted", valid, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user