@bryan-thompson/inspector-assessment-cli 1.27.0 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
* - Profile/format validation - CLI option validation
|
|
12
12
|
* - Mutual exclusivity - Flag conflict detection
|
|
13
13
|
*/
|
|
14
|
-
import { describe, it, expect } from "@jest/globals";
|
|
14
|
+
import { describe, it, expect, jest } from "@jest/globals";
|
|
15
|
+
import { parseArgs, printVersion } from "../lib/cli-parser.js";
|
|
16
|
+
import packageJson from "../../package.json" with { type: "json" };
|
|
15
17
|
describe("Key-Value Pair Parsing", () => {
|
|
16
18
|
/**
|
|
17
19
|
* Recreates parseKeyValuePair logic from cli.ts
|
|
@@ -603,3 +605,42 @@ describe("Log Level Validation", () => {
|
|
|
603
605
|
});
|
|
604
606
|
});
|
|
605
607
|
});
|
|
608
|
+
describe("Version Flag Parsing", () => {
|
|
609
|
+
describe("parseArgs with version flags", () => {
|
|
610
|
+
it("should set versionRequested flag for --version", () => {
|
|
611
|
+
const options = parseArgs(["test-server", "--version"]);
|
|
612
|
+
expect(options.versionRequested).toBe(true);
|
|
613
|
+
});
|
|
614
|
+
it("should set versionRequested flag for -V", () => {
|
|
615
|
+
const options = parseArgs(["test-server", "-V"]);
|
|
616
|
+
expect(options.versionRequested).toBe(true);
|
|
617
|
+
});
|
|
618
|
+
it("should return early when version flag is present", () => {
|
|
619
|
+
const options = parseArgs(["--version"]);
|
|
620
|
+
expect(options.versionRequested).toBe(true);
|
|
621
|
+
expect(options.serverName).toBeUndefined();
|
|
622
|
+
});
|
|
623
|
+
it("should handle version flag at any position", () => {
|
|
624
|
+
const options = parseArgs(["--version", "--verbose"]);
|
|
625
|
+
expect(options.versionRequested).toBe(true);
|
|
626
|
+
});
|
|
627
|
+
});
|
|
628
|
+
describe("printVersion function", () => {
|
|
629
|
+
it("should output version in correct format", () => {
|
|
630
|
+
const consoleSpy = jest
|
|
631
|
+
.spyOn(console, "log")
|
|
632
|
+
.mockImplementation(() => { });
|
|
633
|
+
printVersion();
|
|
634
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringMatching(/^mcp-assess-full \d+\.\d+\.\d+$/));
|
|
635
|
+
consoleSpy.mockRestore();
|
|
636
|
+
});
|
|
637
|
+
it("should match package.json version", () => {
|
|
638
|
+
const consoleSpy = jest
|
|
639
|
+
.spyOn(console, "log")
|
|
640
|
+
.mockImplementation(() => { });
|
|
641
|
+
printVersion();
|
|
642
|
+
expect(consoleSpy).toHaveBeenCalledWith(`mcp-assess-full ${packageJson.version}`);
|
|
643
|
+
consoleSpy.mockRestore();
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
});
|
|
@@ -25,6 +25,8 @@ const DEFAULT_HEADERS = {
|
|
|
25
25
|
*/
|
|
26
26
|
async function checkServerAvailable(url) {
|
|
27
27
|
try {
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
28
30
|
const response = await fetch(url, {
|
|
29
31
|
method: "POST",
|
|
30
32
|
headers: DEFAULT_HEADERS,
|
|
@@ -38,7 +40,9 @@ async function checkServerAvailable(url) {
|
|
|
38
40
|
},
|
|
39
41
|
id: 1,
|
|
40
42
|
}),
|
|
43
|
+
signal: controller.signal,
|
|
41
44
|
});
|
|
45
|
+
clearTimeout(timeoutId);
|
|
42
46
|
// Accept any response (200 or error) as indication server is up
|
|
43
47
|
return response.status < 500;
|
|
44
48
|
}
|
|
@@ -108,7 +112,7 @@ describe("HTTP Transport Integration", () => {
|
|
|
108
112
|
console.log(" - vulnerable-mcp: http://localhost:10900/mcp");
|
|
109
113
|
console.log(" - hardened-mcp: http://localhost:10901/mcp\n");
|
|
110
114
|
}
|
|
111
|
-
});
|
|
115
|
+
}, 30000);
|
|
112
116
|
describe("HTTP Transport Creation (Unit-level)", () => {
|
|
113
117
|
it("should create transport with valid HTTP URL", () => {
|
|
114
118
|
const options = {
|
|
@@ -27,6 +27,8 @@ const DEFAULT_HEADERS = {
|
|
|
27
27
|
*/
|
|
28
28
|
async function checkServerAvailable(url) {
|
|
29
29
|
try {
|
|
30
|
+
const controller = new AbortController();
|
|
31
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
30
32
|
const response = await fetch(url, {
|
|
31
33
|
method: "POST",
|
|
32
34
|
headers: DEFAULT_HEADERS,
|
|
@@ -40,7 +42,9 @@ async function checkServerAvailable(url) {
|
|
|
40
42
|
},
|
|
41
43
|
id: 1,
|
|
42
44
|
}),
|
|
45
|
+
signal: controller.signal,
|
|
43
46
|
});
|
|
47
|
+
clearTimeout(timeoutId);
|
|
44
48
|
return response.status < 500;
|
|
45
49
|
}
|
|
46
50
|
catch {
|
|
@@ -133,7 +137,7 @@ describe("Testbed A/B Comparison", () => {
|
|
|
133
137
|
console.log(" - vulnerable-mcp: http://localhost:10900/mcp");
|
|
134
138
|
console.log(" - hardened-mcp: http://localhost:10901/mcp\n");
|
|
135
139
|
}
|
|
136
|
-
});
|
|
140
|
+
}, 30000);
|
|
137
141
|
describe("Health Check Tests", () => {
|
|
138
142
|
it("should connect to vulnerable-mcp server", async () => {
|
|
139
143
|
if (!vulnerableAvailable) {
|
package/package.json
CHANGED