feat(keycloak): M4.3 — Admin API adapter + claim resolver
internal/keycloak Adapter (HTTPAdapter + Mock). POST /v1/tenants now provisions a KC organization + IT_ADMIN invite when admin_email is set; KC failures emit keycloak.provision_failed but don't roll back. POST /v1/internal/keycloak/claims resolves the current claim bundle for any (tenant_id|tenant_slug|user_attrs.*) lookup. Mock used in tests + when KEYCLOAK_ADMIN_URL is empty. HTTPAdapter tested against an in-process stub KC (httptest.Server). Refs: M4.3
This commit was merged in pull request #8.
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
tcpostgres "github.com/testcontainers/testcontainers-go/modules/postgres"
|
||||
|
||||
"gitea.meghsakha.com/platform/tenant-registry/internal/config"
|
||||
"gitea.meghsakha.com/platform/tenant-registry/internal/keycloak"
|
||||
"gitea.meghsakha.com/platform/tenant-registry/internal/server"
|
||||
"gitea.meghsakha.com/platform/tenant-registry/internal/store"
|
||||
"gitea.meghsakha.com/platform/tenant-registry/migrations"
|
||||
@@ -33,6 +34,7 @@ type testHarness struct {
|
||||
srv *httptest.Server
|
||||
store store.Store
|
||||
tenant *store.Tenant // pre-created acme tenant
|
||||
kcMock *keycloak.Mock
|
||||
}
|
||||
|
||||
func (h *testHarness) Close() {
|
||||
@@ -131,14 +133,19 @@ func newPostgresHarness(t *testing.T) *testHarness {
|
||||
func wireHarness(t *testing.T, s store.Store, seed *store.Tenant) *testHarness {
|
||||
t.Helper()
|
||||
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
mock := keycloak.NewMock()
|
||||
handler := server.NewRouter(&server.Server{
|
||||
Cfg: &config.Config{Env: "dev"}, Log: logger, Store: s,
|
||||
Cfg: &config.Config{Env: "dev"},
|
||||
Log: logger,
|
||||
Store: s,
|
||||
Keycloak: mock,
|
||||
})
|
||||
return &testHarness{
|
||||
t: t,
|
||||
srv: httptest.NewServer(handler),
|
||||
store: s,
|
||||
tenant: seed,
|
||||
kcMock: mock,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user