Verify native vLLM authentication findings

This commit is contained in:
2026-11-22 21:07:34 +00:00
parent a0cdd3d7c5
commit b7467c59fa
2 changed files with 43 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
package ckprompt
import (
"bytes"
"context"
"io"
"net/http"
"strings"
"testing"
"go.maximumdirect.net/ckconfig"
commandkit "go.maximumdirect.net/commandkit"
"go.maximumdirect.net/configkit"
promptkit "go.maximumdirect.net/promptkit"
)
type smokeTransport func(*http.Request) (*http.Response, error)
func (f smokeTransport) RoundTrip(r *http.Request) (*http.Response, error) { return f(r) }
func TestVLLMAuthenticationEvidenceFlowsThroughCommand(t *testing.T) {
source := configkit.Input{Destination: configkit.Keys("promptkit"), Source: configkit.Mapping("fixture", map[string]any{"backends": []any{map[string]any{"id": "local", "provider": "vllm", "endpoint": "https://example.invalid/v1", "zero_cost": false}}})}
client := &http.Client{Transport: smokeTransport(func(r *http.Request) (*http.Response, error) {
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(`{"object":"list","data":[]}`)), Request: r}, nil
})}
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{Main: &source}, HTTPClient: client}, promptkit.WithBundledOpenRouter(false))
if err != nil {
t.Fatal(err)
}
loader := func(context.Context, ckconfig.Selection, struct{}, struct{}) (*promptkit.Engine, error) {
return engine, nil
}
suite := WithSmokeTesting(FromEngine(loader), loader, nil)
app := newPromptTestApp(t, Command(suite))
var out bytes.Buffer
result := app.Execute(context.Background(), []string{"promptkit", "test", "authentication", "--llm-backend=local", "--format=json"}, commandkit.Streams{Out: &out})
if result.Status != 0 || !strings.Contains(out.String(), `"supported": true`) || !strings.Contains(out.String(), `"applicable": true`) || !strings.Contains(out.String(), `"credentials_accepted": true`) {
t.Fatalf("outcome=%#v report=%s", result, out.String())
}
}