-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCM-5718 | feat: Display login error if --govcloud supplied with comm…
…ercial region
- Loading branch information
1 parent
4b55e57
commit 445d223
Showing
3 changed files
with
117 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package login_test | ||
|
||
import ( | ||
"os" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/openshift/rosa/cmd/login" | ||
"github.com/openshift/rosa/pkg/config" | ||
"github.com/openshift/rosa/pkg/fedramp" | ||
"github.com/openshift/rosa/pkg/rosa" | ||
) | ||
|
||
var _ = Describe("Validate login command", func() { | ||
|
||
AfterEach(func() { | ||
fedramp.Disable() | ||
os.Setenv("AWS_REGION", "") | ||
}) | ||
|
||
Context("login command", func() { | ||
When("logging into FedRAMP", func() { | ||
It("only 'region' is FedRAMP", func() { | ||
os.Setenv("AWS_REGION", "us-gov-west-1") | ||
// Load the configuration file: | ||
cfg, err := config.Load() | ||
Expect(err).ToNot(HaveOccurred()) | ||
if cfg == nil { | ||
cfg = new(config.Config) | ||
} | ||
err = login.CheckAndLogIntoFedramp(false, false, cfg, "", "staging", rosa.NewRuntime()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
It("only 'govcloud' flag is true", func() { | ||
os.Setenv("AWS_REGION", "us-east-1") | ||
// Load the configuration file: | ||
cfg, err := config.Load() | ||
Expect(err).ToNot(HaveOccurred()) | ||
if cfg == nil { | ||
cfg = new(config.Config) | ||
} | ||
err = login.CheckAndLogIntoFedramp(true, false, cfg, "", "staging", rosa.NewRuntime()) | ||
Expect(err).To(HaveOccurred()) | ||
}) | ||
It("only 'cfg' has FedRAMP", func() { | ||
os.Setenv("AWS_REGION", "us-east-1") | ||
// Load the configuration file: | ||
cfg, err := config.Load() | ||
Expect(err).ToNot(HaveOccurred()) | ||
if cfg == nil { | ||
cfg = new(config.Config) | ||
} | ||
cfg.FedRAMP = true | ||
err = login.CheckAndLogIntoFedramp(false, false, cfg, "", "staging", rosa.NewRuntime()) | ||
Expect(err).To(HaveOccurred()) | ||
}) | ||
It("'cfg' has FedRAMP and region is govcloud", func() { | ||
os.Setenv("AWS_REGION", "us-gov-east-1") | ||
// Load the configuration file: | ||
cfg, err := config.Load() | ||
Expect(err).ToNot(HaveOccurred()) | ||
if cfg == nil { | ||
cfg = new(config.Config) | ||
} | ||
cfg.FedRAMP = true | ||
err = login.CheckAndLogIntoFedramp(false, false, cfg, "", "staging", rosa.NewRuntime()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package login_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestCluster(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Login Suite") | ||
} |