Bootstrap copied BFF and local accounts with public Sendico contracts (#34)

This commit is contained in:
Stephan D committed 2026-09-12 13:37:48 +02:00
1 parent 67dc5b5b1e
commit 7062672a87
556 files changed
+42291 -777

No files matched your search

@@ -0,0 +1,53 @@
package client
import (
"context"
"errors"
"testing"
"git.sendico.io/tech/sxchnge/bff/edge/shared/storage/refreshtokens"
"git.sendico.io/tech/sxchnge/bff/pkg/model"
)
type resolveClientDB struct {
refreshtokens.DB
calls int
client *model.Client
err error
}
func (db *resolveClientDB) GetClient(ctx context.Context, clientID string) (*model.Client, error) {
db.calls++
return db.client, db.err
}
func TestResolveRejectsBlankClientIDWithoutStorageLookup(t *testing.T) {
db := &resolveClientDB{}
client, err := Resolve(context.Background(), db, " ")
if !errors.Is(err, ErrUnknownClientID) {
t.Fatalf("expected unknown client id, got %v", err)
}
if client != nil {
t.Fatalf("expected nil client, got %#v", client)
}
if db.calls != 0 {
t.Fatalf("expected no storage lookup for blank client id, got %d", db.calls)
}
}
func TestResolveTrimsClientID(t *testing.T) {
want := &model.Client{ClientID: "client-1"}
db := &resolveClientDB{client: want}
client, err := Resolve(context.Background(), db, " client-1 ")
if err != nil {
t.Fatalf("expected client resolution to succeed, got %v", err)
}
if client != want {
t.Fatalf("expected resolved client %#v, got %#v", want, client)
}
if db.calls != 1 {
t.Fatalf("expected one storage lookup, got %d", db.calls)
}
}