terraform-provider-docker/internal/provider/config_test.go
Martin cf3f8d6457
feat: Implement support for insecure registries (#414)
* feat: Add new tests for insecure registries.

* chore: Refactor code into parseImageOptions and add tests.

* feat: normalizeRegistryAddress supports http addresses.

* feat: keys of authConfigs are now stored without protocol.

* chore: Refactor of docker registry fallback in parseImageOptions.

* refactor: Improve tests and implementation of parseImageOptions

* feat: Implement support for http registries.

* fix: authConfig unit tests now reflect newest structure.

* fix: docker_image_registry data source can pull without authentication.

* fix: Refactor setup of http headers for registry requests.

* docs: Add note about http registries.

* docs: Fix linting error in docs.
2022-07-22 11:19:15 +02:00

32 lines
955 B
Go

package provider
import (
"testing"
)
func TestNormalizeRegistryAddress(t *testing.T) {
t.Run("Should return same address if http:// is used", func(t *testing.T) {
address := "http://registry.com"
expected := "http://registry.com"
actual := normalizeRegistryAddress(address)
if actual != expected {
t.Fatalf("Expected %s, got %s", expected, actual)
}
})
t.Run("Should return https address if no protocol is specified", func(t *testing.T) {
address := "registry.com"
expected := "https://registry.com"
actual := normalizeRegistryAddress(address)
if actual != expected {
t.Fatalf("Expected %s, got %s", expected, actual)
}
})
t.Run("Should return https address if https protocol is specified", func(t *testing.T) {
address := "https://registry.com"
expected := "https://registry.com"
actual := normalizeRegistryAddress(address)
if actual != expected {
t.Fatalf("Expected %s, got %s", expected, actual)
}
})
}