Skip to content

Commit 97075fe

Browse files
OCM-16969 | ci: Add a new HCP profile with proxy that is set username/password
1 parent 533a85b commit 97075fe

File tree

11 files changed

+183
-16
lines changed

11 files changed

+183
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
github.com/nathan-fiscaletti/consolesize-go v0.0.0-20210105204122-a87d9f614b9d
3030
github.com/onsi/ginkgo/v2 v2.17.1
3131
github.com/onsi/gomega v1.30.0
32-
github.com/openshift-online/ocm-common v0.0.29
32+
github.com/openshift-online/ocm-common v0.0.31
3333
github.com/openshift-online/ocm-sdk-go v0.1.476
3434
github.com/pkg/errors v0.9.1
3535
github.com/robfig/cron/v3 v3.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ github.com/openshift-online/ocm-api-model/clientapi v0.0.431 h1:oGyJaX7ERZZVqVQB
278278
github.com/openshift-online/ocm-api-model/clientapi v0.0.431/go.mod h1:fZwy5HY2URG9nrExvQeXrDU/08TGqZ16f8oymVEN5lo=
279279
github.com/openshift-online/ocm-api-model/model v0.0.431 h1:vIuELb0uH2AkN5LMQLYbLrdYIULMEK6ctQkbdoNbEZQ=
280280
github.com/openshift-online/ocm-api-model/model v0.0.431/go.mod h1:PQIoq6P8Vlb7goOdRMLK8nJY+B7HH0RTqYAa4kyidTE=
281-
github.com/openshift-online/ocm-common v0.0.29 h1:EyKoLvQXKOa3UpoWHT3cMyNHBbhSZURC8Ws/cxTaT1U=
282-
github.com/openshift-online/ocm-common v0.0.29/go.mod h1:VEkuZp9aqbXtetZ5ycND6QpvhykvTuBF3oPsVM1X3vI=
281+
github.com/openshift-online/ocm-common v0.0.31 h1:csxB4UQAUhwhDOVBmOzUKgtemuwV9rhCkzMoeFX8zCQ=
282+
github.com/openshift-online/ocm-common v0.0.31/go.mod h1:VEkuZp9aqbXtetZ5ycND6QpvhykvTuBF3oPsVM1X3vI=
283283
github.com/openshift-online/ocm-sdk-go v0.1.476 h1:l5gp/QEqnocqM02m7pDeS9ndXcCTBamewVSGaymd88Y=
284284
github.com/openshift-online/ocm-sdk-go v0.1.476/go.mod h1:ds+aOAlQbiK0ubZP3CwXkzd7m48v6fMQ1ef9UCrjzBY=
285285
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

tests/ci/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type TestConfig struct {
4040
ClusterDetailFile string
4141
ClusterInstallLogArtifactFile string
4242
ClusterAdminFile string
43+
ProxyAuthFile string
4344
ClusterIDPAdminUsernamePassword string
4445
TestFocusFile string
4546
TestLabelFilterFile string
@@ -121,6 +122,7 @@ func init() {
121122
Test.ClusterDetailFile = path.Join(Test.OutputDir, "cluster-detail.json")
122123
Test.ClusterInstallLogArtifactFile = path.Join(Test.ArtifactDir, ".install.log")
123124
Test.ClusterAdminFile = path.Join(Test.ArtifactDir, ".admin")
125+
Test.ProxyAuthFile = path.Join(Test.ArtifactDir, ".proxy-auth")
124126
Test.ClusterIDPAdminUsernamePassword = path.Join(Test.ArtifactDir, ".idp-admin-username-password")
125127
Test.TestFocusFile = path.Join(Test.RootDir, "tests", "ci", "data", "commit-focus")
126128
Test.TestLabelFilterFile = path.Join(Test.RootDir, "tests", "ci", "data", "label-filter")

tests/ci/data/profiles/external.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ profiles:
216216
kms_key: true
217217
networking: true
218218
proxy_enabled: true
219+
proxy_type: "auth"
219220
label_enabled: false
220221
zones: ""
221222
tag_enabled: true

tests/utils/handler/cluster_handler.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,22 @@ func (ch *clusterHandler) GenerateClusterCreateFlags() ([]string, error) {
736736
if proxyName == "" {
737737
proxyName = clusterName
738738
}
739-
proxy, err := resourcesHandler.
740-
PrepareProxy(ch.profile.Region, proxyName, config.Test.OutputDir, config.Test.ProxyCABundleFile)
739+
proxy := &ProxyDetail{}
740+
if ch.profile.ClusterConfig.ProxyType == "auth" {
741+
log.Logger.Infof("Proxy auth is enabled. Going to generate the user and password and record in %s",
742+
config.Test.ProxyAuthFile)
743+
username := "proxyuser"
744+
_, password := resourcesHandler.PrepareAdminUser()
745+
_, err = helper.CreateFileWithContent(config.Test.ProxyAuthFile, fmt.Sprintf("%s:%s", username, password))
746+
if err != nil {
747+
return flags, err
748+
}
749+
proxy, err = resourcesHandler.
750+
PrepareProxyWithAuth(ch.profile.Region, proxyName, config.Test.OutputDir, config.Test.ProxyCABundleFile, username, password)
751+
} else {
752+
proxy, err = resourcesHandler.
753+
PrepareProxy(ch.profile.Region, proxyName, config.Test.OutputDir, config.Test.ProxyCABundleFile)
754+
}
741755
if err != nil {
742756
return flags, err
743757
}

tests/utils/handler/interface.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type ClusterConfig struct {
6363
DefaultIngressPrivate bool `yaml:"default_ingress_private,omitempty"`
6464
Private bool `yaml:"private,omitempty" json:"private,omitempty"`
6565
ProxyEnabled bool `yaml:"proxy_enabled,omitempty" json:"proxy_enabled,omitempty"`
66+
ProxyType string `yaml:"proxy_type,omitempty" json:"proxy_type,omitempty"`
6667
STS bool `yaml:"sts,omitempty" json:"sts,omitempty"`
6768
SharedVPC bool `yaml:"shared_vpc,omitempty" json:"shared_vpc,omitempty"`
6869
TagEnabled bool `yaml:"tag_enabled,omitempty" json:"tag_enabled,omitempty"`
@@ -123,5 +124,7 @@ type ProxyDetail struct {
123124
HTTPProxy string
124125
CABundleFilePath string
125126
NoProxy string
127+
Username string
128+
Password string
126129
InstanceID string
127130
}

tests/utils/handler/resources_handler_prepare.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,16 @@ func (rh *resourcesHandler) PrepareSubnets(zones []string, multiZone bool) (map[
262262

263263
func (rh *resourcesHandler) PrepareProxy(zone string, sshPemFileName string, sshPemFileRecordDir string,
264264
caFile string) (*ProxyDetail, error) {
265+
return rh.PrepareProxyWithAuth(zone, sshPemFileName, sshPemFileRecordDir, caFile, "", "")
266+
}
267+
268+
func (rh *resourcesHandler) PrepareProxyWithAuth(zone string, sshPemFileName string, sshPemFileRecordDir string,
269+
caFile string, username string, password string) (*ProxyDetail, error) {
265270

266271
if rh.vpc == nil {
267272
return nil, errors.New("VPC has not been initialized ...")
268273
}
269-
instance, privateIP, caContent, err := rh.vpc.LaunchProxyInstance(zone, sshPemFileName, sshPemFileRecordDir)
274+
instance, privateIP, caContent, err := rh.vpc.LaunchProxyInstanceWithAuth(zone, sshPemFileName, sshPemFileRecordDir, username, password)
270275
if err != nil {
271276
return nil, err
272277
}
@@ -276,8 +281,8 @@ func (rh *resourcesHandler) PrepareProxy(zone string, sshPemFileName string, ssh
276281
}
277282
err = rh.registerProxyInstanceID(*instance.InstanceId)
278283
return &ProxyDetail{
279-
HTTPsProxy: fmt.Sprintf("https://%s:8080", privateIP),
280-
HTTPProxy: fmt.Sprintf("http://%s:8080", privateIP),
284+
HTTPsProxy: rh.vpc.GetHTTPSProxyURL(privateIP, username, password),
285+
HTTPProxy: rh.vpc.GetProxyURL(privateIP, username, password),
281286
CABundleFilePath: caFile,
282287
NoProxy: "quay.io",
283288
InstanceID: *instance.InstanceId,

vendor/github.com/openshift-online/ocm-common/pkg/deprecation/transport_wrapper.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift-online/ocm-common/pkg/test/vpc_client/proxy.go

Lines changed: 102 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift-online/ocm-common/pkg/utils/pointers.go

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)