feat:Update pnpm-lock.yaml to link shared package; modify API routes to utilize new schemas for domain and service management; enhance DNS record handling with CNAME support; refactor service and subdomain routes for improved functionality; implement confirm dialog for domain deletion in the frontend; clean up unused components and improve UI consistency.
Build, Test, and Push CFDM Docker Image / test (push) Failing after 51s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been skipped
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been skipped
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
Build, Test, and Push CFDM Docker Image / test (push) Failing after 51s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been skipped
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been skipped
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { repos } from "@cfdm/db";
|
||||
import { buildApp } from "../src/app.js";
|
||||
import { loadConfig } from "../src/config.js";
|
||||
|
||||
async function authHeaders(app: Awaited<ReturnType<typeof buildApp>>) {
|
||||
const config = loadConfig();
|
||||
const res = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/v1/auth/login",
|
||||
payload: { username: config.adminUsername, password: "admin" },
|
||||
});
|
||||
expect(res.statusCode).toBe(200);
|
||||
const { token } = res.json() as { token: string };
|
||||
return { authorization: `Bearer ${token}` };
|
||||
}
|
||||
|
||||
describe("subdomains", () => {
|
||||
it("PATCH /subdomains/:id toggles enabled and renames", async () => {
|
||||
const app = await buildApp({
|
||||
config: { ...loadConfig(), staticDir: null },
|
||||
memory: true,
|
||||
});
|
||||
const headers = await authHeaders(app);
|
||||
|
||||
const domain = repos.createDomain(
|
||||
app.db,
|
||||
null,
|
||||
"example.com",
|
||||
"cf-zone-1",
|
||||
);
|
||||
const created = repos.createSubdomain(
|
||||
app.db,
|
||||
domain.id,
|
||||
"www",
|
||||
"www.example.com",
|
||||
);
|
||||
expect(created.enabled).toBe(true);
|
||||
|
||||
const disableRes = await app.inject({
|
||||
method: "PATCH",
|
||||
url: `/api/v1/subdomains/${created.id}`,
|
||||
headers,
|
||||
payload: { enabled: false },
|
||||
});
|
||||
expect(disableRes.statusCode).toBe(200);
|
||||
expect(disableRes.json().enabled).toBe(false);
|
||||
|
||||
const renameRes = await app.inject({
|
||||
method: "PATCH",
|
||||
url: `/api/v1/subdomains/${created.id}`,
|
||||
headers,
|
||||
payload: { name: "api" },
|
||||
});
|
||||
expect(renameRes.statusCode).toBe(200);
|
||||
const renamed = renameRes.json();
|
||||
expect(renamed.name).toBe("api");
|
||||
expect(renamed.fqdn).toBe("api.example.com");
|
||||
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user