Skip to content

Commit 4f3329d

Browse files
committed
test: update tests for exposure removal
- Remove mcp-runtime validation tests and fixtures - Remove mcp-runtime integration tests (add and remove) - Simplify gateway target test fixtures to behind-gateway only
1 parent 812ca42 commit 4f3329d

3 files changed

Lines changed: 15 additions & 294 deletions

File tree

src/cli/commands/add/__tests__/add-gateway-target.test.ts

Lines changed: 7 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,19 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest';
99
describe.skip('add gateway-target command', () => {
1010
let testDir: string;
1111
let projectDir: string;
12-
const agentName = 'TestAgent';
13-
const gatewayName = 'test-gateway'; // Used in skipped behind-gateway tests
12+
const gatewayName = 'test-gateway';
1413

1514
beforeAll(async () => {
1615
testDir = join(tmpdir(), `agentcore-add-gateway-target-${randomUUID()}`);
1716
await mkdir(testDir, { recursive: true });
1817

19-
// Create project with agent
18+
// Create project
2019
const projectName = 'GatewayTargetProj';
21-
let result = await runCLI(['create', '--name', projectName, '--no-agent'], testDir);
20+
const result = await runCLI(['create', '--name', projectName, '--no-agent'], testDir);
2221
if (result.exitCode !== 0) {
2322
throw new Error(`Failed to create project: ${result.stdout} ${result.stderr}`);
2423
}
2524
projectDir = join(testDir, projectName);
26-
27-
// Add agent for mcp-runtime tests
28-
result = await runCLI(
29-
[
30-
'add',
31-
'agent',
32-
'--name',
33-
agentName,
34-
'--language',
35-
'Python',
36-
'--framework',
37-
'Strands',
38-
'--model-provider',
39-
'Bedrock',
40-
'--memory',
41-
'none',
42-
'--json',
43-
],
44-
projectDir
45-
);
46-
if (result.exitCode !== 0) {
47-
throw new Error(`Failed to create agent: ${result.stdout} ${result.stderr}`);
48-
}
4925
});
5026

5127
afterAll(async () => {
@@ -61,32 +37,9 @@ describe.skip('add gateway-target command', () => {
6137
expect(json.error.includes('--name'), `Error: ${json.error}`).toBeTruthy();
6238
});
6339

64-
it('requires exposure flag', async () => {
65-
const result = await runCLI(
66-
['add', 'gateway-target', '--name', 'test', '--language', 'Python', '--json'],
67-
projectDir
68-
);
69-
expect(result.exitCode).toBe(1);
70-
const json = JSON.parse(result.stdout);
71-
expect(json.success).toBe(false);
72-
expect(json.error.includes('--exposure'), `Error: ${json.error}`).toBeTruthy();
73-
});
74-
7540
it('validates language', async () => {
7641
const result = await runCLI(
77-
[
78-
'add',
79-
'gateway-target',
80-
'--name',
81-
'test',
82-
'--language',
83-
'InvalidLang',
84-
'--exposure',
85-
'mcp-runtime',
86-
'--agents',
87-
agentName,
88-
'--json',
89-
],
42+
['add', 'gateway-target', '--name', 'test', '--language', 'InvalidLang', '--json'],
9043
projectDir
9144
);
9245
expect(result.exitCode).toBe(1);
@@ -100,19 +53,7 @@ describe.skip('add gateway-target command', () => {
10053

10154
it('accepts Other as valid language option', async () => {
10255
const result = await runCLI(
103-
[
104-
'add',
105-
'gateway-target',
106-
'--name',
107-
'container-tool',
108-
'--language',
109-
'Other',
110-
'--exposure',
111-
'mcp-runtime',
112-
'--agents',
113-
agentName,
114-
'--json',
115-
],
56+
['add', 'gateway-target', '--name', 'container-tool', '--language', 'Other', '--json'],
11657
projectDir
11758
);
11859

@@ -127,79 +68,6 @@ describe.skip('add gateway-target command', () => {
12768
});
12869
});
12970

130-
describe('mcp-runtime', () => {
131-
it('creates mcp-runtime tool', async () => {
132-
const toolName = `rttool${Date.now()}`;
133-
const result = await runCLI(
134-
[
135-
'add',
136-
'gateway-target',
137-
'--name',
138-
toolName,
139-
'--language',
140-
'Python',
141-
'--exposure',
142-
'mcp-runtime',
143-
'--agents',
144-
agentName,
145-
'--json',
146-
],
147-
projectDir
148-
);
149-
150-
expect(result.exitCode, `stdout: ${result.stdout}, stderr: ${result.stderr}`).toBe(0);
151-
const json = JSON.parse(result.stdout);
152-
expect(json.success).toBe(true);
153-
expect(json.toolName).toBe(toolName);
154-
155-
// Verify in mcp.json
156-
const mcpSpec = JSON.parse(await readFile(join(projectDir, 'agentcore/mcp.json'), 'utf-8'));
157-
const tool = mcpSpec.mcpRuntimeTools?.find((t: { name: string }) => t.name === toolName);
158-
expect(tool, 'Tool should be in mcpRuntimeTools').toBeTruthy();
159-
160-
// Verify agent has remote tool reference
161-
const projectSpec = JSON.parse(await readFile(join(projectDir, 'agentcore/agentcore.json'), 'utf-8'));
162-
const agent = projectSpec.agents.find((a: { name: string }) => a.name === agentName);
163-
const hasRef = agent?.remoteTools?.some((rt: { mcpRuntimeName?: string }) => rt.mcpRuntimeName === toolName);
164-
expect(hasRef, 'Agent should have remoteTools reference').toBeTruthy();
165-
});
166-
167-
it('requires agents for mcp-runtime', async () => {
168-
const result = await runCLI(
169-
['add', 'gateway-target', '--name', 'no-agents', '--language', 'Python', '--exposure', 'mcp-runtime', '--json'],
170-
projectDir
171-
);
172-
expect(result.exitCode).toBe(1);
173-
const json = JSON.parse(result.stdout);
174-
expect(json.success).toBe(false);
175-
expect(json.error.includes('--agents'), `Error: ${json.error}`).toBeTruthy();
176-
});
177-
178-
it('returns clear error for Other language with mcp-runtime', async () => {
179-
const result = await runCLI(
180-
[
181-
'add',
182-
'gateway-target',
183-
'--name',
184-
'runtime-container',
185-
'--language',
186-
'Other',
187-
'--exposure',
188-
'mcp-runtime',
189-
'--agents',
190-
agentName,
191-
'--json',
192-
],
193-
projectDir
194-
);
195-
196-
expect(result.exitCode).toBe(1);
197-
const json = JSON.parse(result.stdout);
198-
expect(json.success).toBe(false);
199-
expect(json.error.length > 0, 'Should have error message').toBeTruthy();
200-
});
201-
});
202-
20371
// Gateway disabled - skip behind-gateway tests until gateway feature is enabled
20472
describe.skip('behind-gateway', () => {
20573
it('creates behind-gateway tool', async () => {
@@ -212,8 +80,6 @@ describe.skip('add gateway-target command', () => {
21280
toolName,
21381
'--language',
21482
'Python',
215-
'--exposure',
216-
'behind-gateway',
21783
'--gateway',
21884
gatewayName,
21985
'--host',
@@ -237,19 +103,7 @@ describe.skip('add gateway-target command', () => {
237103

238104
it('requires gateway for behind-gateway', async () => {
239105
const result = await runCLI(
240-
[
241-
'add',
242-
'gateway-target',
243-
'--name',
244-
'no-gw',
245-
'--language',
246-
'Python',
247-
'--exposure',
248-
'behind-gateway',
249-
'--host',
250-
'Lambda',
251-
'--json',
252-
],
106+
['add', 'gateway-target', '--name', 'no-gw', '--language', 'Python', '--host', 'Lambda', '--json'],
253107
projectDir
254108
);
255109
expect(result.exitCode).toBe(1);
@@ -260,19 +114,7 @@ describe.skip('add gateway-target command', () => {
260114

261115
it('requires host for behind-gateway', async () => {
262116
const result = await runCLI(
263-
[
264-
'add',
265-
'gateway-target',
266-
'--name',
267-
'no-host',
268-
'--language',
269-
'Python',
270-
'--exposure',
271-
'behind-gateway',
272-
'--gateway',
273-
gatewayName,
274-
'--json',
275-
],
117+
['add', 'gateway-target', '--name', 'no-host', '--language', 'Python', '--gateway', gatewayName, '--json'],
276118
projectDir
277119
);
278120
expect(result.exitCode).toBe(1);
@@ -290,8 +132,6 @@ describe.skip('add gateway-target command', () => {
290132
'gateway-container',
291133
'--language',
292134
'Other',
293-
'--exposure',
294-
'behind-gateway',
295135
'--gateway',
296136
gatewayName,
297137
'--host',

src/cli/commands/add/__tests__/validate.test.ts

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,9 @@ const validGatewayOptionsJwt: AddGatewayOptions = {
4646
allowedClients: 'client1,client2',
4747
};
4848

49-
const validGatewayTargetOptionsMcpRuntime: AddGatewayTargetOptions = {
49+
const validGatewayTargetOptions: AddGatewayTargetOptions = {
5050
name: 'test-tool',
5151
language: 'Python',
52-
exposure: 'mcp-runtime',
53-
agents: 'Agent1,Agent2',
54-
};
55-
56-
const validGatewayTargetOptionsBehindGateway: AddGatewayTargetOptions = {
57-
name: 'test-tool',
58-
language: 'Python',
59-
exposure: 'behind-gateway',
6052
gateway: 'my-gateway',
6153
host: 'Lambda',
6254
};
@@ -241,11 +233,10 @@ describe('validate', () => {
241233
const requiredFields: { field: keyof AddGatewayTargetOptions; error: string }[] = [
242234
{ field: 'name', error: '--name is required' },
243235
{ field: 'language', error: '--language is required' },
244-
{ field: 'exposure', error: '--exposure is required' },
245236
];
246237

247238
for (const { field, error } of requiredFields) {
248-
const opts = { ...validGatewayTargetOptionsMcpRuntime, [field]: undefined };
239+
const opts = { ...validGatewayTargetOptions, [field]: undefined };
249240
const result = await validateAddGatewayTargetOptions(opts);
250241
expect(result.valid, `Should fail for missing ${String(field)}`).toBe(false);
251242
expect(result.error).toBe(error);
@@ -254,42 +245,19 @@ describe('validate', () => {
254245

255246
// AC16: Invalid values rejected
256247
it('returns error for invalid values', async () => {
257-
let result = await validateAddGatewayTargetOptions({
258-
...validGatewayTargetOptionsMcpRuntime,
248+
const result = await validateAddGatewayTargetOptions({
249+
...validGatewayTargetOptions,
259250
language: 'Java' as any,
260251
});
261252
expect(result.valid).toBe(false);
262253
expect(result.error?.includes('Invalid language')).toBeTruthy();
263-
264-
result = await validateAddGatewayTargetOptions({
265-
...validGatewayTargetOptionsMcpRuntime,
266-
exposure: 'invalid' as any,
267-
});
268-
expect(result.valid).toBe(false);
269-
expect(result.error?.includes('Invalid exposure')).toBeTruthy();
270254
});
271255

272-
// AC17: mcp-runtime exposure requires agents
273-
it('returns error for mcp-runtime without agents', async () => {
274-
let result = await validateAddGatewayTargetOptions({ ...validGatewayTargetOptionsMcpRuntime, agents: undefined });
275-
expect(result.valid).toBe(false);
276-
expect(result.error).toBe('--agents is required for mcp-runtime exposure');
277-
278-
result = await validateAddGatewayTargetOptions({ ...validGatewayTargetOptionsMcpRuntime, agents: ',,,' });
279-
expect(result.valid).toBe(false);
280-
expect(result.error).toBe('At least one agent is required');
281-
});
282-
283-
// AC18: behind-gateway exposure is enabled
284-
it('passes for valid behind-gateway options', async () => {
285-
const result = await validateAddGatewayTargetOptions({ ...validGatewayTargetOptionsBehindGateway });
256+
// AC18: Valid options pass
257+
it('passes for valid gateway target options', async () => {
258+
const result = await validateAddGatewayTargetOptions({ ...validGatewayTargetOptions });
286259
expect(result.valid).toBe(true);
287260
});
288-
289-
// AC19: Valid options pass
290-
it('passes for valid mcp-runtime options', async () => {
291-
expect(await validateAddGatewayTargetOptions(validGatewayTargetOptionsMcpRuntime)).toEqual({ valid: true });
292-
});
293261
});
294262

295263
describe('validateAddMemoryOptions', () => {

0 commit comments

Comments
 (0)