diff --git a/api/vendor/github.com/openshift/assisted-service/models/cluster.go b/api/vendor/github.com/openshift/assisted-service/models/cluster.go index 1f54de6a02d7..bf8d6e96bd54 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/cluster.go +++ b/api/vendor/github.com/openshift/assisted-service/models/cluster.go @@ -110,7 +110,7 @@ type Cluster struct { HTTPProxy string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy string `json:"https_proxy,omitempty" gorm:"column:https_proxy"` diff --git a/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go b/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go index 0f72526515bd..188ab71f4d48 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go +++ b/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go @@ -64,7 +64,7 @@ type ClusterCreateParams struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty"` diff --git a/api/vendor/github.com/openshift/assisted-service/models/proxy.go b/api/vendor/github.com/openshift/assisted-service/models/proxy.go index 7945bd104b62..8d8aeb3f3026 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/proxy.go +++ b/api/vendor/github.com/openshift/assisted-service/models/proxy.go @@ -23,7 +23,7 @@ type Proxy struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty" gorm:"column:https_proxy"` diff --git a/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go b/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go index 979f98035982..15d66e2f1308 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go +++ b/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go @@ -57,7 +57,7 @@ type V2ClusterUpdateParams struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty"` diff --git a/client/vendor/github.com/openshift/assisted-service/models/cluster.go b/client/vendor/github.com/openshift/assisted-service/models/cluster.go index 1f54de6a02d7..bf8d6e96bd54 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/cluster.go +++ b/client/vendor/github.com/openshift/assisted-service/models/cluster.go @@ -110,7 +110,7 @@ type Cluster struct { HTTPProxy string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy string `json:"https_proxy,omitempty" gorm:"column:https_proxy"` diff --git a/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go b/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go index 0f72526515bd..188ab71f4d48 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go +++ b/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go @@ -64,7 +64,7 @@ type ClusterCreateParams struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty"` diff --git a/client/vendor/github.com/openshift/assisted-service/models/proxy.go b/client/vendor/github.com/openshift/assisted-service/models/proxy.go index 7945bd104b62..8d8aeb3f3026 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/proxy.go +++ b/client/vendor/github.com/openshift/assisted-service/models/proxy.go @@ -23,7 +23,7 @@ type Proxy struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty" gorm:"column:https_proxy"` diff --git a/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go b/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go index 979f98035982..15d66e2f1308 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go +++ b/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go @@ -57,7 +57,7 @@ type V2ClusterUpdateParams struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty"` diff --git a/internal/bminventory/inventory.go b/internal/bminventory/inventory.go index 8d4cd53c6176..9b7cc0afccf7 100644 --- a/internal/bminventory/inventory.go +++ b/internal/bminventory/inventory.go @@ -4890,7 +4890,7 @@ func validateProxySettings(httpProxy, httpsProxy, noProxy, ocpVersion *string) e } } if httpsProxy != nil && *httpsProxy != "" { - if err := pkgvalidations.ValidateHTTPProxyFormat(*httpsProxy); err != nil { + if err := pkgvalidations.ValidateHTTPSProxyFormat(*httpsProxy); err != nil { return errors.Errorf("Failed to validate HTTPS Proxy: %s", err) } } diff --git a/internal/bminventory/inventory_test.go b/internal/bminventory/inventory_test.go index 11862c7a8e74..1f37877f2438 100644 --- a/internal/bminventory/inventory_test.go +++ b/internal/bminventory/inventory_test.go @@ -3755,6 +3755,13 @@ var _ = Describe("cluster", func() { _ = updateCluster("http://proxy.proxy", "", "proxy.proxy") }) + It("set a valid https proxy", func() { + mockEvents.EXPECT().SendClusterEvent(gomock.Any(), eventstest.NewEventMatcher( + eventstest.WithNameMatcher(eventgen.ProxySettingsChangedEventName), + eventstest.WithClusterIdMatcher(clusterID.String()))) + _ = updateCluster("", "https://proxy.proxy", "") + }) + It("set a valid noProxy wildcard", func() { mockEvents.EXPECT().SendClusterEvent(gomock.Any(), eventstest.NewEventMatcher( eventstest.WithNameMatcher(eventgen.ProxySettingsChangedEventName), @@ -10418,6 +10425,10 @@ var _ = Describe("infraEnvs", func() { _ = updateInfraEnv("http://proxy.proxy", "", "proxy.proxy") }) + It("set a valid https proxy", func() { + _ = updateInfraEnv("", "https://proxy.proxy", "") + }) + It("set a valid noProxy wildcard", func() { _ = updateInfraEnv("", "", "*") }) diff --git a/models/cluster.go b/models/cluster.go index 1f54de6a02d7..bf8d6e96bd54 100644 --- a/models/cluster.go +++ b/models/cluster.go @@ -110,7 +110,7 @@ type Cluster struct { HTTPProxy string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy string `json:"https_proxy,omitempty" gorm:"column:https_proxy"` diff --git a/models/cluster_create_params.go b/models/cluster_create_params.go index 0f72526515bd..188ab71f4d48 100644 --- a/models/cluster_create_params.go +++ b/models/cluster_create_params.go @@ -64,7 +64,7 @@ type ClusterCreateParams struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty"` diff --git a/models/proxy.go b/models/proxy.go index 7945bd104b62..8d8aeb3f3026 100644 --- a/models/proxy.go +++ b/models/proxy.go @@ -23,7 +23,7 @@ type Proxy struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty" gorm:"column:https_proxy"` diff --git a/models/v2_cluster_update_params.go b/models/v2_cluster_update_params.go index 979f98035982..15d66e2f1308 100644 --- a/models/v2_cluster_update_params.go +++ b/models/v2_cluster_update_params.go @@ -57,7 +57,7 @@ type V2ClusterUpdateParams struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty"` diff --git a/pkg/validations/validations.go b/pkg/validations/validations.go index d54bb8e7f817..15f1f963c65b 100644 --- a/pkg/validations/validations.go +++ b/pkg/validations/validations.go @@ -95,8 +95,7 @@ func ValidateHTTPFormat(theurl string) error { return nil } -// ValidateHTTPProxyFormat validates the HTTP Proxy and HTTPS Proxy format -func ValidateHTTPProxyFormat(proxyURL string) error { +func validateProxyURLFormat(proxyURL string, allowedSchemes ...string) error { if !govalidator.IsURL(proxyURL) { return errors.Errorf("Proxy URL format is not valid: '%s'", proxyURL) } @@ -104,13 +103,23 @@ func ValidateHTTPProxyFormat(proxyURL string) error { if err != nil { return errors.Errorf("Proxy URL format is not valid: '%s'", proxyURL) } - if u.Scheme == "https" { - return errors.Errorf("The URL scheme must be http; https is currently not supported: '%s'", proxyURL) - } - if u.Scheme != "http" { - return errors.Errorf("The URL scheme must be http and specified in the URL: '%s'", proxyURL) + for _, scheme := range allowedSchemes { + if u.Scheme == scheme { + return nil + } } - return nil + return errors.Errorf("The URL scheme must be %s and specified in the URL: '%s'", + strings.Join(allowedSchemes, " or "), proxyURL) +} + +// ValidateHTTPProxyFormat validates the HTTP Proxy format (http scheme only) +func ValidateHTTPProxyFormat(proxyURL string) error { + return validateProxyURLFormat(proxyURL, "http") +} + +// ValidateHTTPSProxyFormat validates the HTTPS Proxy URL format (http or https schemes are valid) +func ValidateHTTPSProxyFormat(proxyURL string) error { + return validateProxyURLFormat(proxyURL, "http", "https") } func validateNoProxyEntry(entry string) error { diff --git a/pkg/validations/validations_test.go b/pkg/validations/validations_test.go index 1ea723ce4c5a..df5ecb6ba102 100644 --- a/pkg/validations/validations_test.go +++ b/pkg/validations/validations_test.go @@ -37,7 +37,7 @@ var _ = Describe("URL validations", func() { }, { "https://proxy.com:3128", - "The URL scheme must be http; https is currently not supported: 'https://proxy.com:3128'", + "The URL scheme must be http and specified in the URL: 'https://proxy.com:3128'", }, { "ftp://proxy.com:3128", @@ -82,6 +82,50 @@ var _ = Describe("URL validations", func() { }) }) + Context("test HTTPS proxy URL", func() { + var parameters = []struct { + input, err string + }{ + {"http://proxy.com:3128", ""}, + {"http://username:pswd@proxy.com", ""}, + {"http://10.9.8.7:123", ""}, + {"http://username:pswd@10.9.8.7:123", ""}, + {"https://proxy.com:3128", ""}, + {"https://username:pswd@proxy.com", ""}, + {"https://10.9.8.7:123", ""}, + {"https://username:pswd@10.9.8.7:443", ""}, + {"https://[1080:0:0:0:8:800:200C:417A]:8888", ""}, + { + "ftp://proxy.com:3128", + "The URL scheme must be http or https and specified in the URL: 'ftp://proxy.com:3128'", + }, + { + "proxy.com:3128", + "The URL scheme must be http or https and specified in the URL: 'proxy.com:3128'", + }, + { + "xyz", + "Proxy URL format is not valid: 'xyz'", + }, + { + "", + "Proxy URL format is not valid: ''", + }, + } + + It("validates HTTPS proxy URL input", func() { + for _, param := range parameters { + err := ValidateHTTPSProxyFormat(param.input) + if param.err == "" { + Expect(err).Should(BeNil()) + } else { + Expect(err).ShouldNot(BeNil()) + Expect(err.Error()).To(Equal(param.err)) + } + } + }) + }) + Context("test URL", func() { var parameters = []struct { input, err string diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go index 1861b977d777..7bcad1dfae5f 100644 --- a/restapi/embedded_spec.go +++ b/restapi/embedded_spec.go @@ -6717,7 +6717,7 @@ func init() { "type": "string" }, "https_proxy": { - "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", + "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e or https://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", "type": "string", "x-go-custom-tag": "gorm:\"column:https_proxy\"" }, @@ -7092,7 +7092,7 @@ func init() { "x-nullable": true }, "https_proxy": { - "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", + "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e or https://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", "type": "string", "x-nullable": true }, @@ -10718,7 +10718,7 @@ func init() { "x-nullable": true }, "https_proxy": { - "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", + "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e or https://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", "type": "string", "x-go-custom-tag": "gorm:\"column:https_proxy\"", "x-nullable": true @@ -11301,7 +11301,7 @@ func init() { "x-nullable": true }, "https_proxy": { - "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", + "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e or https://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", "type": "string", "x-nullable": true }, @@ -18510,7 +18510,7 @@ func init() { "type": "string" }, "https_proxy": { - "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", + "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e or https://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", "type": "string", "x-go-custom-tag": "gorm:\"column:https_proxy\"" }, @@ -18885,7 +18885,7 @@ func init() { "x-nullable": true }, "https_proxy": { - "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", + "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e or https://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", "type": "string", "x-nullable": true }, @@ -22468,7 +22468,7 @@ func init() { "x-nullable": true }, "https_proxy": { - "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", + "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e or https://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", "type": "string", "x-go-custom-tag": "gorm:\"column:https_proxy\"", "x-nullable": true @@ -23025,7 +23025,7 @@ func init() { "x-nullable": true }, "https_proxy": { - "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", + "description": "A proxy URL to use for creating HTTPS connections outside the cluster.\nhttp://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e or https://\\\u003cusername\\\u003e:\\\u003cpswd\\\u003e@\\\u003cip\\\u003e:\\\u003cport\\\u003e\n", "type": "string", "x-nullable": true }, diff --git a/swagger.yaml b/swagger.yaml index 852a32e1bc8a..4b7bfd0eef56 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -5252,7 +5252,7 @@ definitions: type: string description: | A proxy URL to use for creating HTTPS connections outside the cluster. - http://\:\@\:\ + http://\:\@\:\ or https://\:\@\:\ x-nullable: true no_proxy: type: string @@ -5488,7 +5488,7 @@ definitions: type: string description: | A proxy URL to use for creating HTTPS connections outside the cluster. - http://\:\@\:\ + http://\:\@\:\ or https://\:\@\:\ x-nullable: true no_proxy: type: string @@ -5718,7 +5718,7 @@ definitions: type: string description: | A proxy URL to use for creating HTTPS connections outside the cluster. - http://\:\@\:\ + http://\:\@\:\ or https://\:\@\:\ x-go-custom-tag: gorm:"column:https_proxy" no_proxy: type: string @@ -7979,7 +7979,7 @@ definitions: type: string description: | A proxy URL to use for creating HTTPS connections outside the cluster. - http://\:\@\:\ + http://\:\@\:\ or https://\:\@\:\ x-nullable: true x-go-custom-tag: gorm:"column:https_proxy" no_proxy: diff --git a/vendor/github.com/openshift/assisted-service/models/cluster.go b/vendor/github.com/openshift/assisted-service/models/cluster.go index 1f54de6a02d7..bf8d6e96bd54 100644 --- a/vendor/github.com/openshift/assisted-service/models/cluster.go +++ b/vendor/github.com/openshift/assisted-service/models/cluster.go @@ -110,7 +110,7 @@ type Cluster struct { HTTPProxy string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy string `json:"https_proxy,omitempty" gorm:"column:https_proxy"` diff --git a/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go b/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go index 0f72526515bd..188ab71f4d48 100644 --- a/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go +++ b/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go @@ -64,7 +64,7 @@ type ClusterCreateParams struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty"` diff --git a/vendor/github.com/openshift/assisted-service/models/proxy.go b/vendor/github.com/openshift/assisted-service/models/proxy.go index 7945bd104b62..8d8aeb3f3026 100644 --- a/vendor/github.com/openshift/assisted-service/models/proxy.go +++ b/vendor/github.com/openshift/assisted-service/models/proxy.go @@ -23,7 +23,7 @@ type Proxy struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty" gorm:"column:https_proxy"` diff --git a/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go b/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go index 979f98035982..15d66e2f1308 100644 --- a/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go +++ b/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go @@ -57,7 +57,7 @@ type V2ClusterUpdateParams struct { HTTPProxy *string `json:"http_proxy,omitempty"` // A proxy URL to use for creating HTTPS connections outside the cluster. - // http://\:\@\:\ + // http://\:\@\:\ or https://\:\@\:\ // HTTPSProxy *string `json:"https_proxy,omitempty"`