mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
test: simplify network restrictions test output
This commit is contained in:
@@ -2,7 +2,6 @@ import { describe, it, expect } from "bun:test";
|
|||||||
|
|
||||||
describe("Network Restrictions", () => {
|
describe("Network Restrictions", () => {
|
||||||
it("should block access to unauthorized domains", async () => {
|
it("should block access to unauthorized domains", async () => {
|
||||||
// This test verifies that the proxy blocks unauthorized domains
|
|
||||||
const unauthorizedUrls = [
|
const unauthorizedUrls = [
|
||||||
"https://example.com/api/data",
|
"https://example.com/api/data",
|
||||||
"https://jsonplaceholder.typicode.com/posts",
|
"https://jsonplaceholder.typicode.com/posts",
|
||||||
@@ -15,24 +14,19 @@ describe("Network Restrictions", () => {
|
|||||||
try {
|
try {
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
// Force through proxy if set
|
|
||||||
agent: undefined,
|
agent: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we reach here, the proxy didn't block it - test should fail
|
|
||||||
expect(response.ok).toBe(false);
|
expect(response.ok).toBe(false);
|
||||||
throw new Error(`Unauthorized domain ${url} was not blocked by proxy`);
|
throw new Error(`Unauthorized domain ${url} was not blocked by proxy`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// We expect an error (connection refused, timeout, etc)
|
|
||||||
// This is the desired behavior - proxy blocked the request
|
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
console.log(`✓ Successfully blocked: ${url}`);
|
console.log(`Successfully blocked: ${url}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow access to whitelisted domains", async () => {
|
it("should allow access to whitelisted domains", async () => {
|
||||||
// These should work through the proxy
|
|
||||||
const allowedUrls = [
|
const allowedUrls = [
|
||||||
"https://api.github.com/zen",
|
"https://api.github.com/zen",
|
||||||
"https://registry.npmjs.org/-/ping",
|
"https://registry.npmjs.org/-/ping",
|
||||||
@@ -42,9 +36,8 @@ describe("Network Restrictions", () => {
|
|||||||
try {
|
try {
|
||||||
const response = await fetch(url, { timeout: 5000 });
|
const response = await fetch(url, { timeout: 5000 });
|
||||||
expect(response.ok).toBe(true);
|
expect(response.ok).toBe(true);
|
||||||
console.log(`✓ Successfully allowed: ${url}`);
|
console.log(`Successfully allowed: ${url}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// If whitelisted domains fail, something is wrong
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Whitelisted domain ${url} was blocked: ${error.message}`,
|
`Whitelisted domain ${url} was blocked: ${error.message}`,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user