From 1965f0624493fd4a79977d9835787736282fbea5 Mon Sep 17 00:00:00 2001 From: Yoav Schwammenthal Date: Thu, 2 Jul 2026 11:52:52 +0300 Subject: [PATCH 1/3] MGMT-24487: Update swagger https_proxy field to allow https scheme Update the https_proxy field description in all 4 swagger definitions (cluster-create-params, v2-cluster-update-params, cluster, proxy) to document that both http:// and https:// schemes are valid, aligning with OCP docs since 4.9. --- swagger.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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: From 8316f316f06b981083580ca832730f2fda2cc260 Mon Sep 17 00:00:00 2001 From: Yoav Schwammenthal Date: Thu, 2 Jul 2026 15:58:07 +0300 Subject: [PATCH 2/3] MGMT-24487: skipper make generate after swagger https_proxy description update Auto-generated by skipper make generate. --- .../openshift/assisted-service/models/cluster.go | 2 +- .../models/cluster_create_params.go | 2 +- .../openshift/assisted-service/models/proxy.go | 2 +- .../models/v2_cluster_update_params.go | 2 +- .../openshift/assisted-service/models/cluster.go | 2 +- .../models/cluster_create_params.go | 2 +- .../openshift/assisted-service/models/proxy.go | 2 +- .../models/v2_cluster_update_params.go | 2 +- models/cluster.go | 2 +- models/cluster_create_params.go | 2 +- models/proxy.go | 2 +- models/v2_cluster_update_params.go | 2 +- restapi/embedded_spec.go | 16 ++++++++-------- .../openshift/assisted-service/models/cluster.go | 2 +- .../models/cluster_create_params.go | 2 +- .../openshift/assisted-service/models/proxy.go | 2 +- .../models/v2_cluster_update_params.go | 2 +- 17 files changed, 24 insertions(+), 24 deletions(-) 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/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/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/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"` From 0cea09d775819bc618230254b7a5bf0742bd73ff Mon Sep 17 00:00:00 2001 From: Yoav Schwammenthal Date: Thu, 2 Jul 2026 16:56:18 +0300 Subject: [PATCH 3/3] MGMT-24487: Allow https scheme in HTTPS proxy URL validation Add ValidateHTTPSProxyFormat that accepts both http:// and https:// schemes for the https_proxy field. Extract shared validation logic into validateProxyURLFormat helper with variadic allowedSchemes parameter. Add integration tests for https:// proxy through V2UpdateCluster and UpdateInfraEnv API handlers. --- internal/bminventory/inventory.go | 2 +- internal/bminventory/inventory_test.go | 11 ++++++ pkg/validations/validations.go | 25 +++++++++----- pkg/validations/validations_test.go | 46 +++++++++++++++++++++++++- 4 files changed, 74 insertions(+), 10 deletions(-) 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/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