Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCM-6926 | fix: needs to also go through admin fedramp url aliases #1872

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/ocm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,12 @@ func GetEnv() (string, error) {
}
}

// Special use case for Admin users in the GovCloud environment
for env, api := range fedramp.AdminURLAliases {
if api == strings.TrimSuffix(cfg.URL, "/") {
return env, nil
}
}

return "", fmt.Errorf("Invalid OCM API")
}
16 changes: 16 additions & 0 deletions pkg/ocm/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ var _ = Describe("Gateway URL Resolution", func() {
Expect(env).To(Equal("integration"))
})

It("Returns a valid admin fedRAMP env", func() {
url := "https://api-admin.int.openshiftusgov.com"
cfg := &config.Config{}
cfg.URL = url
cfg.FedRAMP = true
err := config.Save(cfg)
Expect(err).To(BeNil())
currentConfig, err := config.Load()
Expect(err).To(BeNil())
Expect(currentConfig.URL).To(Equal(url))

env, err := GetEnv()
Expect(err).To(BeNil())
Expect(env).To(Equal("integration"))
})

It("Returns a valid regionalized env", func() {
url := "https://api.aws.ap-southeast-1.integration.openshift.com"
cfg := &config.Config{}
Expand Down