Move authentication probes into the outbound adapter
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
type SmokeTester struct {
|
||||
runner *Runner
|
||||
httpClient smokeHTTPGetter
|
||||
authClient smokeAuthenticationClient
|
||||
now func() time.Time
|
||||
}
|
||||
|
||||
@@ -24,18 +25,22 @@ type SmokeTester struct {
|
||||
// leaves HTTP operations unsupported rather than falling back to another client.
|
||||
func NewSmokeTester(runner *Runner, httpClient *llm.OpenAICompatibleClient) *SmokeTester {
|
||||
var getter smokeHTTPGetter
|
||||
var authentication smokeAuthenticationClient
|
||||
if httpClient != nil {
|
||||
getter = httpClient
|
||||
authentication = httpClient
|
||||
}
|
||||
return &SmokeTester{runner: runner, httpClient: getter, now: time.Now}
|
||||
return &SmokeTester{runner: runner, httpClient: getter, authClient: authentication, now: time.Now}
|
||||
}
|
||||
|
||||
func newSmokeTesterWithClock(runner *Runner, httpClient *llm.OpenAICompatibleClient, now func() time.Time) *SmokeTester {
|
||||
var getter smokeHTTPGetter
|
||||
var authentication smokeAuthenticationClient
|
||||
if httpClient != nil {
|
||||
getter = httpClient
|
||||
authentication = httpClient
|
||||
}
|
||||
return &SmokeTester{runner: runner, httpClient: getter, now: now}
|
||||
return &SmokeTester{runner: runner, httpClient: getter, authClient: authentication, now: now}
|
||||
}
|
||||
|
||||
// Run selects and executes one diagnostic, retaining only factual results.
|
||||
@@ -126,7 +131,7 @@ func (t *SmokeTester) Run(ctx context.Context, request domain.SmokeTestRequest)
|
||||
return t.finishHTTP(ctx, report, finish)
|
||||
case domain.SmokeTestAuthentication:
|
||||
requestStartedAt := now().UTC()
|
||||
outcome, err := (authenticationProbe{client: t.httpClient}).run(ctx, selection.backend, selection.target)
|
||||
outcome, err := (authenticationProbe{client: t.authClient}).run(ctx, selection.backend, selection.target)
|
||||
requestDuration := nonnegativeDuration(now().UTC().Sub(requestStartedAt))
|
||||
if err != nil {
|
||||
if contextErr := ctx.Err(); contextErr != nil {
|
||||
@@ -349,7 +354,7 @@ func (t *SmokeTester) setSupport(report *domain.SmokeTestReport, selection *smok
|
||||
report.Applicable = boolPointer(true)
|
||||
return nil
|
||||
case domain.SmokeTestAuthentication:
|
||||
outcome, err := (authenticationProbe{client: t.httpClient}).support(selection.backend)
|
||||
outcome, err := (authenticationProbe{client: t.authClient}).support(selection.backend)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user