mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-09-25 19:11:18 -04:00
Cloud provider Azure: adopt changes to CCM / CNM for Azure
This commit is contained in:
parent
3c1ddfb94e
commit
20811794c2
11 changed files with 351 additions and 14 deletions
54
coordinator/cloudprovider/azure/serviceaccounturi_test.go
Normal file
54
coordinator/cloudprovider/azure/serviceaccounturi_test.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package azure
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/edgelesssys/constellation/cli/azure/client"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGetApplicationCredentials(t *testing.T) {
|
||||
creds := client.ApplicationCredentials{
|
||||
TenantID: "tenant-id",
|
||||
ClientID: "client-id",
|
||||
ClientSecret: "client-secret",
|
||||
}
|
||||
testCases := map[string]struct {
|
||||
cloudServiceAccountURI string
|
||||
expectedCreds client.ApplicationCredentials
|
||||
expectErr bool
|
||||
}{
|
||||
"getApplicationCredentials works": {
|
||||
cloudServiceAccountURI: "serviceaccount://azure?tenant_id=tenant-id&client_id=client-id&client_secret=client-secret",
|
||||
expectedCreds: creds,
|
||||
},
|
||||
"invalid URI fails": {
|
||||
cloudServiceAccountURI: "\x00",
|
||||
expectErr: true,
|
||||
},
|
||||
"incorrect URI scheme fails": {
|
||||
cloudServiceAccountURI: "invalid",
|
||||
expectErr: true,
|
||||
},
|
||||
"incorrect URI host fails": {
|
||||
cloudServiceAccountURI: "serviceaccount://incorrect",
|
||||
expectErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
|
||||
creds, err := getApplicationCredentials(tc.cloudServiceAccountURI)
|
||||
if tc.expectErr {
|
||||
assert.Error(err)
|
||||
return
|
||||
}
|
||||
require.NoError(err)
|
||||
assert.Equal(tc.expectedCreds, creds)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue