Skip to content

Commit

Permalink
Remove Azure client dependency from registerConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardjkim committed Dec 13, 2024
1 parent f48d229 commit 5ee9911
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 215 deletions.
18 changes: 1 addition & 17 deletions lib/auth/bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import (
"github.com/gravitational/teleport/lib/auth/machineid/machineidv1"
"github.com/gravitational/teleport/lib/auth/state"
"github.com/gravitational/teleport/lib/auth/testauthority"
"github.com/gravitational/teleport/lib/cloud/azure"
libevents "github.com/gravitational/teleport/lib/events"
"github.com/gravitational/teleport/lib/events/eventstest"
"github.com/gravitational/teleport/lib/fixtures"
Expand Down Expand Up @@ -586,21 +585,6 @@ func TestRegisterBot_RemoteAddr(t *testing.T) {
require.NoError(t, err)
require.NoError(t, a.UpsertToken(ctx, azureToken))

vmClient := &mockAzureVMClient{
vms: map[string]*azure.VirtualMachine{
rsID: {
ID: rsID,
Name: "test-vm",
Subscription: subID,
ResourceGroup: resourceGroup,
VMID: vmID,
},
},
}
getVMClient := makeVMClientGetter(map[string]*mockAzureVMClient{
subID: vmClient,
})

tlsConfig, err := fixtures.LocalTLSConfig()
require.NoError(t, err)

Expand Down Expand Up @@ -641,7 +625,7 @@ func TestRegisterBot_RemoteAddr(t *testing.T) {
AccessToken: accessToken,
}
return req, nil
}, withCerts([]*x509.Certificate{tlsConfig.Certificate}), withVerifyFunc(mockVerifyToken(nil)), withVMClientGetter(getVMClient))
}, withCerts([]*x509.Certificate{tlsConfig.Certificate}), withVerifyFunc(mockVerifyToken(nil)))
require.NoError(t, err)
checkCertLoginIP(t, certs.TLS, remoteAddr)
})
Expand Down
7 changes: 0 additions & 7 deletions lib/auth/join_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ type azureRegisterConfig struct {
clock clockwork.Clock
certificateAuthorities []*x509.Certificate
verify azureVerifyTokenFunc
getVMClient vmClientGetter
}

func azureVerifyFuncFromOIDCVerifier(cfg *oidc.Config) azureVerifyTokenFunc {
Expand Down Expand Up @@ -155,12 +154,6 @@ func (cfg *azureRegisterConfig) CheckAndSetDefaults(ctx context.Context) error {
}
cfg.certificateAuthorities = certs
}
if cfg.getVMClient == nil {
cfg.getVMClient = func(subscriptionID string, token *azure.StaticCredential) (azure.VirtualMachinesClient, error) {
client, err := azure.NewVirtualMachinesClient(subscriptionID, token, nil)
return client, trace.Wrap(err)
}
}
return nil
}

Expand Down
Loading

0 comments on commit 5ee9911

Please sign in to comment.