Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions backend-api/__tests__/agents.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,26 @@ describe("GET /agents/:id/gateway-url", () => {
delete process.env.GATEWAY_HOST;
});

it("allows gateway url lookups for warning agents so degraded control-plane recovery still works", async () => {
mockDb.query.mockResolvedValueOnce({
rows: [{
id: "a-warning-gateway",
container_id: "container-warning-gateway",
gateway_host_port: 19123,
user_id: "user-1",
status: "warning",
}],
});

const res = await auth(request(app).get("/agents/a-warning-gateway/gateway-url"));

expect(res.status).toBe(200);
expect(res.body).toEqual({
url: "http://localhost:19123",
port: 19123,
});
});

it("rejects gateway url lookups for stopped agents so stale ports are not exposed", async () => {
mockDb.query.mockResolvedValueOnce({
rows: [{
Expand All @@ -230,6 +250,23 @@ describe("GET /agents/:id/gateway-url", () => {
expect(res.status).toBe(409);
expect(res.body.error).toMatch(/only available while running/i);
});

it("rejects gateway url lookups for error agents so failed control-plane state stays closed", async () => {
mockDb.query.mockResolvedValueOnce({
rows: [{
id: "a-error-gateway",
container_id: "container-error-gateway",
gateway_host_port: 19123,
user_id: "user-1",
status: "error",
}],
});

const res = await auth(request(app).get("/agents/a-error-gateway/gateway-url"));

expect(res.status).toBe(409);
expect(res.body.error).toMatch(/only available while running/i);
});
});

describe("POST /agents/deploy", () => {
Expand Down
Loading