Skip to content

Commit aad401e

Browse files
Slachaider-chat-bot
andcommitted
feat: add test cases for SSE and HTTP transport with OpenAPI without JWE
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
1 parent cf11eef commit aad401e

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

cmd/altinity-mcp/main_test.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,98 @@ func TestApplicationStart(t *testing.T) {
15011501
}
15021502
})
15031503

1504+
t.Run("sse_transport_openapi_without_jwe", func(t *testing.T) {
1505+
cfg := config.Config{
1506+
Server: config.ServerConfig{
1507+
Transport: config.SSETransport,
1508+
Address: "localhost",
1509+
Port: 0, // Use random port
1510+
JWE: config.JWEConfig{
1511+
Enabled: false,
1512+
},
1513+
OpenAPI: config.OpenAPIConfig{
1514+
Enabled: true,
1515+
TLS: false,
1516+
},
1517+
TLS: config.ServerTLSConfig{
1518+
Enabled: false,
1519+
},
1520+
},
1521+
}
1522+
app := &application{
1523+
config: cfg,
1524+
mcpServer: altinitymcp.NewClickHouseMCPServer(cfg),
1525+
}
1526+
1527+
// Start in a goroutine since it will block
1528+
done := make(chan error, 1)
1529+
go func() {
1530+
done <- app.Start()
1531+
}()
1532+
1533+
// Give it a moment to start
1534+
time.Sleep(100 * time.Millisecond)
1535+
1536+
// Should start successfully (will block on ListenAndServe)
1537+
select {
1538+
case err := <-done:
1539+
// If it returns immediately, it should be an error
1540+
require.Error(t, err)
1541+
default:
1542+
// If it's still running, that's expected - stop it
1543+
if app.httpSrv != nil {
1544+
_ = app.httpSrv.Close()
1545+
<-done // Wait for it to finish
1546+
}
1547+
}
1548+
})
1549+
1550+
t.Run("http_transport_openapi_without_jwe", func(t *testing.T) {
1551+
cfg := config.Config{
1552+
Server: config.ServerConfig{
1553+
Transport: config.HTTPTransport,
1554+
Address: "localhost",
1555+
Port: 0, // Use random port
1556+
JWE: config.JWEConfig{
1557+
Enabled: false,
1558+
},
1559+
OpenAPI: config.OpenAPIConfig{
1560+
Enabled: true,
1561+
TLS: false,
1562+
},
1563+
TLS: config.ServerTLSConfig{
1564+
Enabled: false,
1565+
},
1566+
},
1567+
}
1568+
app := &application{
1569+
config: cfg,
1570+
mcpServer: altinitymcp.NewClickHouseMCPServer(cfg),
1571+
}
1572+
1573+
// Start in a goroutine since it will block
1574+
done := make(chan error, 1)
1575+
go func() {
1576+
done <- app.Start()
1577+
}()
1578+
1579+
// Give it a moment to start
1580+
time.Sleep(100 * time.Millisecond)
1581+
1582+
// Should start successfully (will block on ListenAndServe)
1583+
select {
1584+
case err := <-done:
1585+
// If it returns immediately, it should be an error
1586+
require.Error(t, err)
1587+
default:
1588+
// If it's still running, that's expected - stop it
1589+
if app.httpSrv != nil {
1590+
_ = app.httpSrv.Close()
1591+
<-done // Wait for it to finish
1592+
}
1593+
}
1594+
})
1595+
15041596
t.Run("sse_transport_with_tls_invalid_config", func(t *testing.T) {
15051597
cfg := config.Config{
15061598
Server: config.ServerConfig{

0 commit comments

Comments
 (0)