| ... | ... |
@@ -319,3 +319,23 @@ func TestAddRequiredHeadersToRedirectedRequests(t *testing.T) {
|
| 319 | 319 |
} |
| 320 | 320 |
} |
| 321 | 321 |
} |
| 322 |
+ |
|
| 323 |
+func TestIsSecure(t *testing.T) {
|
|
| 324 |
+ tests := []struct {
|
|
| 325 |
+ addr string |
|
| 326 |
+ insecureRegistries []string |
|
| 327 |
+ expected bool |
|
| 328 |
+ }{
|
|
| 329 |
+ {"example.com", []string{}, true},
|
|
| 330 |
+ {"example.com", []string{"example.com"}, false},
|
|
| 331 |
+ {"localhost", []string{"localhost:5000"}, true},
|
|
| 332 |
+ {"localhost:5000", []string{"localhost:5000"}, false},
|
|
| 333 |
+ {"localhost", []string{"example.com"}, true},
|
|
| 334 |
+ {"127.0.0.1:5000", []string{"127.0.0.1:5000"}, false},
|
|
| 335 |
+ } |
|
| 336 |
+ for _, tt := range tests {
|
|
| 337 |
+ if sec := IsSecure(tt.addr, tt.insecureRegistries); sec != tt.expected {
|
|
| 338 |
+ t.Errorf("IsSecure failed for %q %v, expected %v got %v", tt.addr, tt.insecureRegistries, tt.expected, sec)
|
|
| 339 |
+ } |
|
| 340 |
+ } |
|
| 341 |
+} |