Skip to content

Commit

Permalink
Pass ConfigInterface to SetAuthConfig method for mock
Browse files Browse the repository at this point in the history
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
  • Loading branch information
helayoty committed Apr 13, 2023
1 parent 54f09c6 commit 1f5e08f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/init-container/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func main() {
azConfig := auth.Config{}

//Setup config
err = azConfig.SetAuthConfig(ctx)
err = azConfig.SetAuthConfig(ctx, &azConfig)
if err != nil {
log.G(ctx).Fatalf("cannot setup the auth configuration. Retrying, ", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/virtual-kubelet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func main() {

var provider string
//Setup config
err := azConfig.SetAuthConfig(ctx)
err := azConfig.SetAuthConfig(ctx, &azConfig)
if err != nil {
log.G(ctx).Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/auth/auth_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (c *Config) GetAuthorizer(ctx context.Context, resource string) (autorest.A
}

// SetAuthConfig sets the configuration needed for Authentication.
func (c *Config) SetAuthConfig(ctx context.Context) error {
func (c *Config) SetAuthConfig(ctx context.Context, configInterface ConfigInterface) error {
ctx, span := trace.StartSpan(ctx, "auth.SetAuthConfig")
defer span.End()

Expand Down Expand Up @@ -186,7 +186,7 @@ func (c *Config) SetAuthConfig(ctx context.Context) error {

resource := c.Cloud.Services[cloud.ResourceManager].Endpoint

c.Authorizer, err = c.GetAuthorizer(ctx, resource)
c.Authorizer, err = configInterface.GetAuthorizer(ctx, resource)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/auth/auth_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestSetAuthConfigWithAuthFile(t *testing.T) {
}

azConfig := Config{}
err = azConfig.SetAuthConfig(context.TODO())
err = azConfig.SetAuthConfig(context.TODO(), &azConfig)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestSetAuthConfigWithAKSCredFile(t *testing.T) {
}

azConfig := Config{}
err = azConfig.SetAuthConfig(context.TODO())
err = azConfig.SetAuthConfig(context.TODO(), &azConfig)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -244,7 +244,7 @@ func TestSetAuthConfigWithEnvVariablesOnly(t *testing.T) {
}

azConfig := Config{}
err = azConfig.SetAuthConfig(context.TODO())
err = azConfig.SetAuthConfig(context.TODO(), &azConfig)
if err != nil {
t.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/aci_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func TestSetupNetwork(t *testing.T) {
networkMocks := NewMockProviderNetworkInterface(mockCtrl)

azConfig := &auth.Config{}
err := azConfig.SetAuthConfig(context.TODO())
err := azConfig.SetAuthConfig(context.TODO(), azConfig)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/aci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ func TestPodToACIEnvVar(t *testing.T) {
}

func setAuthConfig() error {
err := azConfig.SetAuthConfig(context.TODO())
err := azConfig.SetAuthConfig(context.TODO(), &azConfig)
if err != nil {
return err
}
Expand Down Expand Up @@ -1133,7 +1133,7 @@ func TestGetPodWithContainerID(t *testing.T) {
mockPodsNamespaceLister.EXPECT().Get(podName).
Return(testsutil.CreatePodObj(podName, podNamespace), nil)

err := azConfig.SetAuthConfig(context.TODO())
err := azConfig.SetAuthConfig(context.TODO(), &azConfig)
if err != nil {
t.Fatal("failed to get auth configuration", err)
}
Expand Down

0 comments on commit 1f5e08f

Please sign in to comment.