MCPcopy Index your code
hub / github.com/docker/docker-agent / TestPrintModelsGateway

Function TestPrintModelsGateway

cmd/root/sandbox_test.go:179–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

177}
178
179func TestPrintModelsGateway(t *testing.T) {
180 t.Parallel()
181
182 tests := []struct {
183 name string
184 gateway string
185 want string
186 }{
187 {
188 name: "no gateway",
189 gateway: "",
190 want: "Models gateway: none configured\n",
191 },
192 {
193 name: "URL gateway shows allow-listed host",
194 gateway: "https://ai-backend-service-stage.docker.com/proxy",
195 want: "Models gateway: https://ai-backend-service-stage.docker.com/proxy (allowlisting ai-backend-service-stage.docker.com in the sandbox proxy)\n",
196 },
197 {
198 name: "bare authority is its own host",
199 gateway: "ai-backend-service.docker.com:443",
200 want: "Models gateway: ai-backend-service.docker.com:443\n",
201 },
202 {
203 name: "URL with credentials is rendered without them",
204 gateway: "https://user:supersecret@gw.example.com/proxy",
205 want: "Models gateway: https://***@gw.example.com/proxy (allowlisting gw.example.com in the sandbox proxy)\n",
206 },
207 }
208
209 for _, tt := range tests {
210 t.Run(tt.name, func(t *testing.T) {
211 var buf strings.Builder
212 printModelsGateway(&buf, tt.gateway)
213 assert.Equal(t, tt.want, buf.String())
214 assert.NotContains(t, buf.String(), "supersecret",
215 "printed gateway must never include credentials")
216 })
217 }
218}
219
220func TestPrintModelsDevAllowance(t *testing.T) {
221 t.Parallel()

Callers

nothing calls this directly

Calls 3

printModelsGatewayFunction · 0.85
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected