(t *testing.T)
| 177 | } |
| 178 | |
| 179 | func 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 | |
| 220 | func TestPrintModelsDevAllowance(t *testing.T) { |
| 221 | t.Parallel() |
nothing calls this directly
no test coverage detected