Skip to content

Commit baa5608

Browse files
bokelleyclaude
andauthored
feat: add no-auth test agent helpers (#29)
* feat: add no-auth test agent helpers Add unauthenticated versions of test agent helpers for testing scenarios where authentication is not provided. This enables testing behavior differences between authenticated and unauthenticated requests. New exports: - TEST_AGENT_MCP_NO_AUTH_CONFIG - TEST_AGENT_A2A_NO_AUTH_CONFIG - test_agent_no_auth - test_agent_a2a_no_auth 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: add documentation for no-auth test helpers Updated README and examples to document the new no-auth test helpers: - Added CLI examples showing how to use test agents with/without auth - Updated test helpers demo with authentication comparison example - Documented all no-auth exports in the Features section Users can now easily test authentication behavior differences using test_agent_no_auth and test_agent_a2a_no_auth. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: trigger CI re-run 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 80dee92 commit baa5608

File tree

5 files changed

+274
-12
lines changed

5 files changed

+274
-12
lines changed

README.md

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ if result.success:
4545
```
4646

4747
Test helpers include:
48-
- **`test_agent`**: Pre-configured MCP test agent (ready to use)
49-
- **`test_agent_a2a`**: Pre-configured A2A test agent
48+
- **`test_agent`**: Pre-configured MCP test agent with authentication
49+
- **`test_agent_a2a`**: Pre-configured A2A test agent with authentication
50+
- **`test_agent_no_auth`**: Pre-configured MCP test agent WITHOUT authentication
51+
- **`test_agent_a2a_no_auth`**: Pre-configured A2A test agent WITHOUT authentication
5052
- **`creative_agent`**: Reference creative agent for preview functionality
5153
- **`test_agent_client`**: Multi-agent client with both protocols
5254
- **`create_test_agent()`**: Factory for custom test configurations
@@ -113,32 +115,47 @@ async with ADCPMultiAgentClient(
113115
Pre-configured test agents for instant prototyping and testing:
114116

115117
```python
116-
from adcp.testing import test_agent, test_agent_a2a, creative_agent, test_agent_client, create_test_agent
118+
from adcp.testing import (
119+
test_agent, test_agent_a2a,
120+
test_agent_no_auth, test_agent_a2a_no_auth,
121+
creative_agent, test_agent_client, create_test_agent
122+
)
117123
from adcp.types.generated import GetProductsRequest, PreviewCreativeRequest
118124

119-
# 1. Single agent (MCP)
125+
# 1. Single agent with authentication (MCP)
120126
result = await test_agent.get_products(
121127
GetProductsRequest(brief="Coffee brands")
122128
)
123129

124-
# 2. Single agent (A2A)
130+
# 2. Single agent with authentication (A2A)
125131
result = await test_agent_a2a.get_products(
126132
GetProductsRequest(brief="Coffee brands")
127133
)
128134

129-
# 3. Creative agent (preview functionality)
135+
# 3. Single agent WITHOUT authentication (MCP)
136+
# Useful for testing unauthenticated behavior
137+
result = await test_agent_no_auth.get_products(
138+
GetProductsRequest(brief="Coffee brands")
139+
)
140+
141+
# 4. Single agent WITHOUT authentication (A2A)
142+
result = await test_agent_a2a_no_auth.get_products(
143+
GetProductsRequest(brief="Coffee brands")
144+
)
145+
146+
# 5. Creative agent (preview functionality, no auth required)
130147
result = await creative_agent.preview_creative(
131148
PreviewCreativeRequest(
132149
manifest={"format_id": "banner_300x250", "assets": {...}}
133150
)
134151
)
135152

136-
# 4. Multi-agent (parallel execution)
153+
# 6. Multi-agent (parallel execution with both protocols)
137154
results = await test_agent_client.get_products(
138155
GetProductsRequest(brief="Coffee brands")
139156
)
140157

141-
# 5. Custom configuration
158+
# 7. Custom configuration
142159
from adcp.client import ADCPClient
143160
config = create_test_agent(id="my-test", timeout=60.0)
144161
client = ADCPClient(config)
@@ -148,6 +165,7 @@ client = ADCPClient(config)
148165
- Quick prototyping and experimentation
149166
- Example code and documentation
150167
- Integration testing without mock servers
168+
- Testing authentication behavior (comparing auth vs no-auth results)
151169
- Learning AdCP concepts
152170

153171
**Important:** Test agents are public, rate-limited, and for testing only. Never use in production.
@@ -417,6 +435,46 @@ uvx adcp --json myagent get_products '{"brief":"TV ads"}'
417435
uvx adcp --debug myagent get_products '{"brief":"TV ads"}'
418436
```
419437

438+
### Using Test Agents from CLI
439+
440+
The CLI provides easy access to public test agents without configuration:
441+
442+
```bash
443+
# Use test agent with authentication (MCP)
444+
uvx adcp https://test-agent.adcontextprotocol.org/mcp/ \
445+
--auth 1v8tAhASaUYYp4odoQ1PnMpdqNaMiTrCRqYo9OJp6IQ \
446+
get_products '{"brief":"Coffee brands"}'
447+
448+
# Use test agent WITHOUT authentication (MCP)
449+
uvx adcp https://test-agent.adcontextprotocol.org/mcp/ \
450+
get_products '{"brief":"Coffee brands"}'
451+
452+
# Use test agent with authentication (A2A)
453+
uvx adcp --protocol a2a \
454+
--auth 1v8tAhASaUYYp4odoQ1PnMpdqNaMiTrCRqYo9OJp6IQ \
455+
https://test-agent.adcontextprotocol.org \
456+
get_products '{"brief":"Coffee brands"}'
457+
458+
# Save test agent for easier access
459+
uvx adcp --save-auth test-agent https://test-agent.adcontextprotocol.org/mcp/ mcp
460+
# Enter token when prompted: 1v8tAhASaUYYp4odoQ1PnMpdqNaMiTrCRqYo9OJp6IQ
461+
462+
# Now use saved config
463+
uvx adcp test-agent get_products '{"brief":"Coffee brands"}'
464+
465+
# Use creative agent (no auth required)
466+
uvx adcp https://creative.adcontextprotocol.org/mcp \
467+
preview_creative @creative_manifest.json
468+
```
469+
470+
**Test Agent Details:**
471+
- **URL (MCP)**: `https://test-agent.adcontextprotocol.org/mcp/`
472+
- **URL (A2A)**: `https://test-agent.adcontextprotocol.org`
473+
- **Auth Token**: `1v8tAhASaUYYp4odoQ1PnMpdqNaMiTrCRqYo9OJp6IQ` (optional, public token)
474+
- **Rate Limited**: For testing only, not for production
475+
- **No Auth Mode**: Omit `--auth` flag to test unauthenticated behavior
476+
```
477+
420478
### Configuration Management
421479
422480
```bash

examples/test_helpers_demo.py

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
create_test_agent,
1414
test_agent,
1515
test_agent_a2a,
16+
test_agent_a2a_no_auth,
1617
test_agent_client,
18+
test_agent_no_auth,
1719
)
1820
from adcp.types.generated import GetProductsRequest, ListCreativeFormatsRequest
1921

@@ -148,12 +150,57 @@ async def custom_test_agent() -> None:
148150
await client.close()
149151

150152

153+
async def auth_vs_no_auth_comparison() -> None:
154+
"""Example 5: Authenticated vs Unauthenticated Requests.
155+
156+
Compare behavior between authenticated and unauthenticated test agents.
157+
Useful for testing how agents handle different authentication states.
158+
"""
159+
print("🔐 Example 5: Authentication Comparison")
160+
print("=" * 39)
161+
print()
162+
163+
request = GetProductsRequest(
164+
brief="Coffee subscription service",
165+
promoted_offering="Premium coffee",
166+
)
167+
168+
try:
169+
# Test with authentication
170+
print("Testing WITH authentication (MCP)...")
171+
auth_result = await test_agent.get_products(request)
172+
auth_success = "✅" if auth_result.success else "❌"
173+
auth_count = len(auth_result.data.products) if auth_result.data else 0
174+
print(f" {auth_success} With Auth: {auth_count} products")
175+
176+
# Test without authentication
177+
print("Testing WITHOUT authentication (MCP)...")
178+
no_auth_result = await test_agent_no_auth.get_products(request)
179+
no_auth_success = "✅" if no_auth_result.success else "❌"
180+
no_auth_count = len(no_auth_result.data.products) if no_auth_result.data else 0
181+
print(f" {no_auth_success} No Auth: {no_auth_count} products")
182+
183+
# Compare results
184+
print()
185+
if auth_count != no_auth_count:
186+
print(" 💡 Note: Different results with/without auth!")
187+
print(f" Auth returned {auth_count} products")
188+
print(f" No auth returned {no_auth_count} products")
189+
else:
190+
print(" 💡 Note: Same results with/without auth")
191+
192+
print()
193+
except Exception as e:
194+
print(f"❌ Error: {e}")
195+
print()
196+
197+
151198
async def various_operations() -> None:
152-
"""Example 5: Testing Different Operations.
199+
"""Example 6: Testing Different Operations.
153200
154201
Show various ADCP operations with test agents.
155202
"""
156-
print("🎬 Example 5: Various ADCP Operations")
203+
print("🎬 Example 6: Various ADCP Operations")
157204
print("=" * 37)
158205
print()
159206

@@ -195,11 +242,14 @@ async def main() -> None:
195242
await protocol_comparison()
196243
await multi_agent_example()
197244
await custom_test_agent()
245+
await auth_vs_no_auth_comparison()
198246
await various_operations()
199247

200248
print("💡 Key Takeaways:")
201-
print(" • test_agent = Pre-configured MCP test agent (ready to use!)")
202-
print(" • test_agent_a2a = Pre-configured A2A test agent")
249+
print(" • test_agent = Pre-configured MCP test agent with auth")
250+
print(" • test_agent_a2a = Pre-configured A2A test agent with auth")
251+
print(" • test_agent_no_auth = Pre-configured MCP test agent WITHOUT auth")
252+
print(" • test_agent_a2a_no_auth = Pre-configured A2A test agent WITHOUT auth")
203253
print(" • test_agent_client = Multi-agent client with both protocols")
204254
print(" • create_test_agent() = Create custom test configurations")
205255
print(" • Perfect for examples, docs, and quick testing")

src/adcp/testing/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,31 @@
88
from adcp.testing.test_helpers import (
99
CREATIVE_AGENT_CONFIG,
1010
TEST_AGENT_A2A_CONFIG,
11+
TEST_AGENT_A2A_NO_AUTH_CONFIG,
1112
TEST_AGENT_MCP_CONFIG,
13+
TEST_AGENT_MCP_NO_AUTH_CONFIG,
1214
TEST_AGENT_TOKEN,
1315
create_test_agent,
1416
creative_agent,
1517
test_agent,
1618
test_agent_a2a,
19+
test_agent_a2a_no_auth,
1720
test_agent_client,
21+
test_agent_no_auth,
1822
)
1923

2024
__all__ = [
2125
"test_agent",
2226
"test_agent_a2a",
27+
"test_agent_no_auth",
28+
"test_agent_a2a_no_auth",
2329
"creative_agent",
2430
"test_agent_client",
2531
"create_test_agent",
2632
"TEST_AGENT_TOKEN",
2733
"TEST_AGENT_MCP_CONFIG",
2834
"TEST_AGENT_A2A_CONFIG",
35+
"TEST_AGENT_MCP_NO_AUTH_CONFIG",
36+
"TEST_AGENT_A2A_NO_AUTH_CONFIG",
2937
"CREATIVE_AGENT_CONFIG",
3038
]

src/adcp/testing/test_helpers.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@
3030
auth_token=TEST_AGENT_TOKEN,
3131
)
3232

33+
# Public test agent configuration (no auth) - MCP protocol
34+
TEST_AGENT_MCP_NO_AUTH_CONFIG = AgentConfig(
35+
id="test-agent-mcp-no-auth",
36+
agent_uri="https://test-agent.adcontextprotocol.org/mcp/",
37+
protocol=Protocol.MCP,
38+
)
39+
40+
# Public test agent configuration (no auth) - A2A protocol
41+
TEST_AGENT_A2A_NO_AUTH_CONFIG = AgentConfig(
42+
id="test-agent-a2a-no-auth",
43+
agent_uri="https://test-agent.adcontextprotocol.org",
44+
protocol=Protocol.A2A,
45+
)
46+
3347
# Reference creative agent configuration - MCP protocol
3448
# No authentication required for the reference creative agent
3549
CREATIVE_AGENT_CONFIG = AgentConfig(
@@ -67,6 +81,34 @@ def _create_test_agent_a2a_client() -> ADCPClient:
6781
return ADCPClient(TEST_AGENT_A2A_CONFIG)
6882

6983

84+
def _create_test_agent_no_auth_client() -> ADCPClient:
85+
"""Create pre-configured test agent client (no auth) using MCP protocol.
86+
87+
Returns:
88+
ADCPClient instance configured for the public test agent without authentication
89+
90+
Note:
91+
This agent is rate-limited and intended for testing scenarios where no auth is provided.
92+
Useful for testing behavior differences between authenticated and unauthenticated requests.
93+
DO NOT use in production applications.
94+
"""
95+
return ADCPClient(TEST_AGENT_MCP_NO_AUTH_CONFIG)
96+
97+
98+
def _create_test_agent_a2a_no_auth_client() -> ADCPClient:
99+
"""Create pre-configured test agent client (no auth) using A2A protocol.
100+
101+
Returns:
102+
ADCPClient instance configured for the public test agent without authentication
103+
104+
Note:
105+
This agent is rate-limited and intended for testing scenarios where no auth is provided.
106+
Useful for testing behavior differences between authenticated and unauthenticated requests.
107+
DO NOT use in production applications.
108+
"""
109+
return ADCPClient(TEST_AGENT_A2A_NO_AUTH_CONFIG)
110+
111+
70112
def _create_creative_agent_client() -> ADCPClient:
71113
"""Create pre-configured creative agent client.
72114
@@ -139,6 +181,50 @@ def _create_test_multi_agent_client() -> ADCPMultiAgentClient:
139181
# DO NOT use in production applications.
140182
test_agent_a2a: ADCPClient = _create_test_agent_a2a_client()
141183

184+
# Pre-configured test agent client (no auth) using MCP protocol.
185+
# Useful for testing scenarios where authentication is not provided,
186+
# such as testing how agents handle unauthenticated requests or
187+
# comparing behavior between authenticated and unauthenticated calls.
188+
#
189+
# Example:
190+
# ```python
191+
# from adcp.testing import test_agent_no_auth
192+
#
193+
# # Test behavior without authentication
194+
# result = await test_agent_no_auth.get_products(
195+
# GetProductsRequest(
196+
# brief="Coffee subscription service",
197+
# promoted_offering="Premium monthly coffee"
198+
# )
199+
# )
200+
# ```
201+
#
202+
# Note:
203+
# This agent is rate-limited and intended for testing/examples only.
204+
# DO NOT use in production applications.
205+
test_agent_no_auth: ADCPClient = _create_test_agent_no_auth_client()
206+
207+
# Pre-configured test agent client (no auth) using A2A protocol.
208+
# Identical functionality to test_agent_no_auth but uses A2A instead of MCP.
209+
#
210+
# Example:
211+
# ```python
212+
# from adcp.testing import test_agent_a2a_no_auth
213+
#
214+
# # Test A2A behavior without authentication
215+
# result = await test_agent_a2a_no_auth.get_products(
216+
# GetProductsRequest(
217+
# brief="Sustainable fashion brands",
218+
# promoted_offering="Eco-friendly clothing"
219+
# )
220+
# )
221+
# ```
222+
#
223+
# Note:
224+
# This agent is rate-limited and intended for testing/examples only.
225+
# DO NOT use in production applications.
226+
test_agent_a2a_no_auth: ADCPClient = _create_test_agent_a2a_no_auth_client()
227+
142228
# Pre-configured reference creative agent.
143229
# Provides creative preview functionality without authentication.
144230
#

0 commit comments

Comments
 (0)