- Scaffold shared UI fragments and styles in src/shared/ui/ - Implement full Auth vertical slice in src/features/auth/ with WebAuthn ceremonies and recovery endpoints - Implement full Admin vertical slice in src/features/admin/ with responsive tables and mobile decks - Add public client-side JS utilities and pure JS BIP-39 module - Mount routes in src/main.ts and keep legacy server/ and ui/ quarantined - Add pure JSX and API tests for Auth and Admin slices
90 lines
2.2 KiB
TypeScript
90 lines
2.2 KiB
TypeScript
import { test } from "jsr:@std/testing/bdd";
|
|
import { expect } from "jsr:@std/expect";
|
|
import { Hono } from "jsr:@hono/hono@4";
|
|
import { adminRoutes } from "./routes.tsx";
|
|
import {
|
|
AdminAppsPageFragment,
|
|
AdminUserDetailsPageFragment,
|
|
AdminUsersPageFragment,
|
|
AuditLogPageFragment,
|
|
} from "./fragments.tsx";
|
|
|
|
test("admin slice UI endpoints are protected by auth middleware", async () => {
|
|
const app = new Hono();
|
|
app.route("/admin", adminRoutes);
|
|
|
|
const res = await app.request("/admin/users");
|
|
expect(res.status).not.toBe(404);
|
|
expect(res.status).not.toBe(500);
|
|
});
|
|
|
|
test("admin fragment components render valid HTML markup", () => {
|
|
const usersFragment = AdminUsersPageFragment({
|
|
users: [
|
|
{
|
|
id: "u-1",
|
|
username: "alice",
|
|
display_name: "Alice",
|
|
account_status: "active",
|
|
},
|
|
],
|
|
});
|
|
expect(usersFragment).toBeDefined();
|
|
|
|
const userDetailsFragment = AdminUserDetailsPageFragment({
|
|
user: {
|
|
id: "u-1",
|
|
username: "alice",
|
|
display_name: "Alice",
|
|
account_status: "active",
|
|
},
|
|
sessions: [
|
|
{
|
|
id: "sess-1",
|
|
created_at: new Date().toISOString(),
|
|
expires_at: new Date().toISOString(),
|
|
},
|
|
],
|
|
passkeys: [{ id: "pk-1", credential_id: "cred-1", counter: 1 }],
|
|
grants: [
|
|
{
|
|
id: "g-1",
|
|
app_name: "App1",
|
|
spiffe_id: "spiffe://ay/app1",
|
|
role: "admin",
|
|
created_at: new Date().toISOString(),
|
|
},
|
|
],
|
|
allApps: [{ id: "a-1", name: "App1", spiffe_id: "spiffe://ay/app1" }],
|
|
allRoles: [{ id: "r-1", name: "admin" }],
|
|
});
|
|
expect(userDetailsFragment).toBeDefined();
|
|
|
|
const appsFragment = AdminAppsPageFragment({
|
|
apps: [
|
|
{
|
|
id: "a-1",
|
|
name: "Dashboard",
|
|
spiffe_id: "spiffe://ay/dash",
|
|
domain: "dash.atyg.org",
|
|
active_grants_count: 5,
|
|
},
|
|
],
|
|
});
|
|
expect(appsFragment).toBeDefined();
|
|
|
|
const auditFragment = AuditLogPageFragment({
|
|
logs: [
|
|
{
|
|
id: "log-1",
|
|
action: "login_success",
|
|
user: "alice",
|
|
resource: "auth",
|
|
ip_address: "127.0.0.1",
|
|
created_at: new Date().toISOString(),
|
|
},
|
|
],
|
|
});
|
|
expect(auditFragment).toBeDefined();
|
|
});
|