Skip to content

Commit

Permalink
feat(iam): allow passing iam url (#31)
Browse files Browse the repository at this point in the history
* feat(iam): allow passing iam url

* test(iam): update tests for new param

* test(iam): address pr feedback to support it with other endpoints

* fix(integration-sample): remove to address conflicts

Co-authored-by: Steven Collins <Steven.Collins@ibm.com>
  • Loading branch information
jmeis and steven-collins-omega authored Mar 29, 2021
1 parent 108413c commit ece05a6
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion client/actions/channels/channel_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ = Describe("ClusterClient", func() {

BeforeEach(func() {
endpoint = "https://satcon.foo"
iamClient, err = iam.NewIAMClient("some_key")
iamClient, err = iam.NewIAMClient("some_key", "")
Expect(err).ToNot(HaveOccurred())
})

Expand Down
2 changes: 1 addition & 1 deletion client/actions/clusters/cluster_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ = Describe("ClusterClient", func() {

BeforeEach(func() {
endpoint = "https://satcon.foo"
iamClient, err = iam.NewIAMClient("some_key")
iamClient, err = iam.NewIAMClient("some_key", "")
Expect(err).ToNot(HaveOccurred())

})
Expand Down
2 changes: 1 addition & 1 deletion client/actions/subscriptions/subscription_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ = Describe("ClusterClient", func() {

BeforeEach(func() {
endpoint = "https://satcon.foo"
iamClient, err = iam.NewIAMClient("some_key")
iamClient, err = iam.NewIAMClient("some_key", "")
Expect(err).ToNot(HaveOccurred())
})

Expand Down
2 changes: 1 addition & 1 deletion client/actions/users/user_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ = Describe("UserClient", func() {

BeforeEach(func() {
endpoint = "https://satcon.foo"
iamClient, err = iam.NewIAMClient("some_key")
iamClient, err = iam.NewIAMClient("some_key", "")
Expect(err).ToNot(HaveOccurred())
})

Expand Down
2 changes: 1 addition & 1 deletion client/actions/versions/version_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ = Describe("ClusterClient", func() {

BeforeEach(func() {
endpoint = "https://satcon.foo"
iamClient, err = iam.NewIAMClient("some_key")
iamClient, err = iam.NewIAMClient("some_key", "")
Expect(err).ToNot(HaveOccurred())

})
Expand Down
4 changes: 2 additions & 2 deletions client/auth/iam/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ type Client struct {
}

//NewIAMClient returns a new core.IamAuthenticator struct and also returns the error
func NewIAMClient(apiKey string) (*Client, error) {
func NewIAMClient(apiKey string, url string) (*Client, error) {

iamClient, err := core.NewIamAuthenticator(apiKey, "", "", "", false, nil)
iamClient, err := core.NewIamAuthenticator(apiKey, url, "", "", false, nil)

if err == nil {
return &Client{Client: iamClient}, nil
Expand Down
4 changes: 2 additions & 2 deletions client/auth/iam/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var _ = Describe("Client", func() {

It("returns a new IAMClient", func() {

iamClient, err := iam.NewIAMClient(apiKey)
iamClient, err := iam.NewIAMClient(apiKey, "")
Expect(iamClient.Client).NotTo(BeNil())
Expect(err).NotTo(HaveOccurred())

Expand All @@ -30,7 +30,7 @@ var _ = Describe("Client", func() {

It("returns an error", func() {

iamClient, err := iam.NewIAMClient(apiKey)
iamClient, err := iam.NewIAMClient(apiKey, "")
Expect(err).To(HaveOccurred())
Expect(iamClient).To(BeNil())

Expand Down
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var _ = Describe("Client", func() {

BeforeEach(func() {
endpointURL = "https://foo.bar"
iamClient, err = iam.NewIAMClient("some_key")
iamClient, err = iam.NewIAMClient("some_key", "")
Expect(err).NotTo(HaveOccurred())
})

Expand Down
2 changes: 1 addition & 1 deletion test/integration/channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var _ = Describe("Channels", func() {
BeforeEach(func() {
var err error
var iamClient *iam.Client
iamClient, err = iam.NewIAMClient(testConfig.APIKey)
iamClient, err = iam.NewIAMClient(testConfig.APIKey, testConfig.IAMEndpoint)
Expect(err).ToNot(HaveOccurred())
c, _ = client.New(testConfig.SatConEndpoint, nil, iamClient.Client)
Expect(c.Channels).NotTo(BeNil())
Expand Down
2 changes: 1 addition & 1 deletion test/integration/clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var _ = Describe("Clusters", func() {

BeforeEach(func() {
var err error
iamClient, err = iam.NewIAMClient(testConfig.APIKey)
iamClient, err = iam.NewIAMClient(testConfig.APIKey, testConfig.IAMEndpoint)
Expect(err).ToNot(HaveOccurred())
c, _ = client.New(testConfig.SatConEndpoint, nil, iamClient.Client)
Expect(c.Clusters).NotTo(BeNil())
Expand Down
2 changes: 1 addition & 1 deletion test/integration/groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ = Describe("Groups", func() {

BeforeEach(func() {
var err error
iamClient, err = iam.NewIAMClient(testConfig.APIKey)
iamClient, err = iam.NewIAMClient(testConfig.APIKey, testConfig.IAMEndpoint)
Expect(err).ToNot(HaveOccurred())
c, _ = client.New(testConfig.SatConEndpoint, nil, iamClient.Client)
Expect(c.Groups).NotTo(BeNil())
Expand Down
3 changes: 2 additions & 1 deletion test/integration/subscriptions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package integration_test
import (
"encoding/base64"
"fmt"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

Expand All @@ -20,7 +21,7 @@ var _ = Describe("Subscriptions", func() {

BeforeEach(func() {
var err error
iamClient, err = iam.NewIAMClient(testConfig.APIKey)
iamClient, err = iam.NewIAMClient(testConfig.APIKey, testConfig.IAMEndpoint)
Expect(err).ToNot(HaveOccurred())
c, _ = client.New(testConfig.SatConEndpoint, nil, iamClient.Client)
Expect(c.Subscriptions).NotTo(BeNil())
Expand Down
2 changes: 1 addition & 1 deletion test/integration/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var _ = Describe("Users", func() {

BeforeEach(func() {
var err error
iamClient, err = iam.NewIAMClient(testConfig.APIKey)
iamClient, err = iam.NewIAMClient(testConfig.APIKey, testConfig.IAMEndpoint)
Expect(err).ToNot(HaveOccurred())
c, _ = client.New(testConfig.SatConEndpoint, nil, iamClient.Client)
Expect(c.Clusters).NotTo(BeNil())
Expand Down
2 changes: 1 addition & 1 deletion test/integration/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ = Describe("Versions", func() {

BeforeEach(func() {
var err error
iamClient, err = iam.NewIAMClient(testConfig.APIKey)
iamClient, err = iam.NewIAMClient(testConfig.APIKey, testConfig.IAMEndpoint)
Expect(err).ToNot(HaveOccurred())
c, _ = client.New(testConfig.SatConEndpoint, nil, iamClient.Client)
Expect(c.Versions).NotTo(BeNil())
Expand Down

0 comments on commit ece05a6

Please sign in to comment.