Skip to content

Commit cef66f2

Browse files
committed
Add new MCP authentication configurations and update tests
- Introduced new YAML configuration files for MCP authentication methods: file, Kubernetes, and OAuth. - Updated existing MCP configuration to include new authentication methods. - Enhanced end-to-end tests to cover scenarios for file-based, Kubernetes, and OAuth authentication. - Added utility functions for unregistering MCP toolgroups in the testing environment. - Implemented new step definitions for checking response body content in tests.
1 parent e73778a commit cef66f2

9 files changed

Lines changed: 528 additions & 17 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lightspeed Core Service (LCS)
2+
service:
3+
host: 0.0.0.0
4+
port: 8080
5+
auth_enabled: false
6+
workers: 1
7+
color_log: true
8+
access_log: true
9+
llama_stack:
10+
# Server mode - connects to separate llama-stack service
11+
use_as_library_client: false
12+
url: http://llama-stack:8321
13+
api_key: xyzzy
14+
user_data_collection:
15+
feedback_enabled: true
16+
feedback_storage: "/tmp/data/feedback"
17+
transcripts_enabled: true
18+
transcripts_storage: "/tmp/data/transcripts"
19+
authentication:
20+
module: "noop"
21+
mcp_servers:
22+
- name: "mcp-client"
23+
url: "http://mock-mcp:3001"
24+
authorization_headers:
25+
Authorization: "client"

tests/e2e/configuration/server-mode/lightspeed-stack-mcp-file-auth.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ user_data_collection:
1919
authentication:
2020
module: "noop"
2121
mcp_servers:
22-
- name: "mcp-file-auth"
23-
provider_id: "model-context-protocol"
22+
- name: "mcp-file"
2423
url: "http://mock-mcp:3001"
2524
authorization_headers:
2625
Authorization: "/tmp/mcp-secret-token"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lightspeed Core Service (LCS)
2+
service:
3+
host: 0.0.0.0
4+
port: 8080
5+
auth_enabled: false
6+
workers: 1
7+
color_log: true
8+
access_log: true
9+
llama_stack:
10+
# Server mode - connects to separate llama-stack service
11+
use_as_library_client: false
12+
url: http://llama-stack:8321
13+
api_key: xyzzy
14+
user_data_collection:
15+
feedback_enabled: true
16+
feedback_storage: "/tmp/data/feedback"
17+
transcripts_enabled: true
18+
transcripts_storage: "/tmp/data/transcripts"
19+
authentication:
20+
module: "noop"
21+
mcp_servers:
22+
- name: "mcp-kubernetes"
23+
url: "http://mock-mcp:3001"
24+
authorization_headers:
25+
Authorization: "kubernetes"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lightspeed Core Service (LCS)
2+
service:
3+
host: 0.0.0.0
4+
port: 8080
5+
auth_enabled: false
6+
workers: 1
7+
color_log: true
8+
access_log: true
9+
llama_stack:
10+
# Server mode - connects to separate llama-stack service
11+
use_as_library_client: false
12+
url: http://llama-stack:8321
13+
api_key: xyzzy
14+
user_data_collection:
15+
feedback_enabled: true
16+
feedback_storage: "/tmp/data/feedback"
17+
transcripts_enabled: true
18+
transcripts_storage: "/tmp/data/transcripts"
19+
authentication:
20+
module: "noop"
21+
mcp_servers:
22+
- name: "mcp-oauth"
23+
url: "http://mock-mcp:3001"
24+
authorization_headers:
25+
Authorization: "oauth"

tests/e2e/configuration/server-mode/lightspeed-stack-mcp.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@ authentication:
2020
module: "noop"
2121
mcp_servers:
2222
- name: "mcp-oauth"
23-
provider_id: "model-context-protocol"
2423
url: "http://mock-mcp:3001"
2524
authorization_headers:
26-
Authorization: "oauth"
25+
Authorization: "oauth"
26+
- name: "mcp-kubernetes"
27+
url: "http://mock-mcp:3001"
28+
authorization_headers:
29+
Authorization: "kubernetes"
30+
- name: "mcp-file"
31+
url: "http://mock-mcp:3001"
32+
authorization_headers:
33+
Authorization: "/tmp/mcp-secret-token"
34+
- name: "mcp-client"
35+
url: "http://mock-mcp:3001"
36+
authorization_headers:
37+
Authorization: "client"

tests/e2e/features/environment.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from tests.e2e.utils.prow_utils import restore_llama_stack_pod
1717
from behave.runner import Context
1818

19+
from tests.e2e.utils.llama_stack_tools import unregister_mcp_toolgroups
1920
from tests.e2e.utils.llama_stack_shields import (
2021
register_shield,
2122
unregister_shield,
@@ -207,6 +208,27 @@ def before_scenario(context: Context, scenario: Scenario) -> None:
207208
switch_config(context.scenario_config)
208209
restart_container("lightspeed-stack")
209210

211+
if "MCPFileAuthConfig" in scenario.effective_tags:
212+
context.scenario_config = _get_config_path("mcp-file-auth", mode_dir)
213+
unregister_mcp_toolgroups()
214+
switch_config(context.scenario_config)
215+
restart_container("lightspeed-stack")
216+
if "MCPKubernetesAuthConfig" in scenario.effective_tags:
217+
context.scenario_config = _get_config_path("mcp-kubernetes", mode_dir)
218+
unregister_mcp_toolgroups()
219+
switch_config(context.scenario_config)
220+
restart_container("lightspeed-stack")
221+
if "MCPClientAuthConfig" in scenario.effective_tags:
222+
context.scenario_config = _get_config_path("mcp-client", mode_dir)
223+
unregister_mcp_toolgroups()
224+
switch_config(context.scenario_config)
225+
restart_container("lightspeed-stack")
226+
if "MCPOAuthAuthConfig" in scenario.effective_tags:
227+
context.scenario_config = _get_config_path("mcp-oauth", mode_dir)
228+
unregister_mcp_toolgroups()
229+
switch_config(context.scenario_config)
230+
restart_container("lightspeed-stack")
231+
210232

211233
def after_scenario(context: Context, scenario: Scenario) -> None:
212234
"""Run after each scenario is run.
@@ -241,7 +263,14 @@ def after_scenario(context: Context, scenario: Scenario) -> None:
241263
context.llama_stack_was_running = False
242264

243265
# Tags that require config restoration after scenario
244-
config_restore_tags = {"InvalidFeedbackStorageConfig", "NoCacheConfig"}
266+
config_restore_tags = {
267+
"InvalidFeedbackStorageConfig",
268+
"NoCacheConfig",
269+
"MCPFileAuthConfig",
270+
"MCPKubernetesAuthConfig",
271+
"MCPClientAuthConfig",
272+
"MCPOAuthAuthConfig",
273+
}
245274
if config_restore_tags & set(scenario.effective_tags):
246275
switch_config(context.feature_config)
247276
restart_container("lightspeed-stack")

0 commit comments

Comments
 (0)