mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
test: allowing environment variables on azure acceptance tests
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
This commit is contained in:
committed by
Diógenes Fernandes
parent
6a2bb41f9a
commit
8b4fcce514
@@ -207,11 +207,11 @@ func TestAccBackendAccessKeyBasic(t *testing.T) {
|
||||
rs := acctest.RandString(4)
|
||||
res := testResourceNames(rs, "testState")
|
||||
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), emptyAuthConfig())
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
authCred, err := authMethod.Construct(t.Context(), emptyAuthConfig())
|
||||
authCred, err := authMethod.Construct(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -254,11 +254,11 @@ func TestAccBackendSASToken(t *testing.T) {
|
||||
rs := acctest.RandString(4)
|
||||
res := testResourceNames(rs, "testState")
|
||||
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), emptyAuthConfig())
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
authCred, err := authMethod.Construct(t.Context(), emptyAuthConfig())
|
||||
authCred, err := authMethod.Construct(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -320,11 +320,11 @@ Please set TF_AZURE_TEST_CLIENT_ID and TF_AZURE_TEST_SECRET, either manually or
|
||||
t.Fatal(errors.New("A tenant ID must be provided through ARM_TENANT_ID in order to run this test."))
|
||||
}
|
||||
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), emptyAuthConfig())
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
authCred, err := authMethod.Construct(t.Context(), emptyAuthConfig())
|
||||
authCred, err := authMethod.Construct(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -387,11 +387,11 @@ func TestAccBackendServicePrincipalClientCertificate(t *testing.T) {
|
||||
}
|
||||
cert_file.Close()
|
||||
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), emptyAuthConfig())
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
authCred, err := authMethod.Construct(t.Context(), emptyAuthConfig())
|
||||
authCred, err := authMethod.Construct(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ func TestPutMaintainsMetadata(t *testing.T) {
|
||||
rs := acctest.RandString(4)
|
||||
res := testResourceNames(rs, "testState")
|
||||
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), emptyAuthConfig())
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
authCred, err := authMethod.Construct(t.Context(), emptyAuthConfig())
|
||||
authCred, err := authMethod.Construct(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -99,11 +99,11 @@ func TestAccRemoteClientAccessKeyBasic(t *testing.T) {
|
||||
rs := acctest.RandString(4)
|
||||
res := testResourceNames(rs, "testState")
|
||||
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), emptyAuthConfig())
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
authCred, err := authMethod.Construct(t.Context(), emptyAuthConfig())
|
||||
authCred, err := authMethod.Construct(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -153,11 +153,11 @@ func TestAccRemoteClientSASToken(t *testing.T) {
|
||||
rs := acctest.RandString(4)
|
||||
res := testResourceNames(rs, "testState")
|
||||
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), emptyAuthConfig())
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
authCred, err := authMethod.Construct(t.Context(), emptyAuthConfig())
|
||||
authCred, err := authMethod.Construct(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -228,11 +228,11 @@ Please set TF_AZURE_TEST_CLIENT_ID and TF_AZURE_TEST_SECRET, either manually or
|
||||
t.Fatal(errors.New("A tenant ID must be provided through ARM_TENANT_ID in order to run this test."))
|
||||
}
|
||||
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), emptyAuthConfig())
|
||||
authMethod, err := auth.GetAuthMethod(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
authCred, err := authMethod.Construct(t.Context(), emptyAuthConfig())
|
||||
authCred, err := authMethod.Construct(t.Context(), testAuthConfig())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -203,16 +203,23 @@ func destroyTestResources(t *testing.T, resourceGroupClient *armresources.Resour
|
||||
}
|
||||
}
|
||||
|
||||
func emptyAuthConfig() *auth.Config {
|
||||
// Returns an auth config with the environment variables set for the test environment
|
||||
func testAuthConfig() *auth.Config {
|
||||
return &auth.Config{
|
||||
AzureCLIAuthConfig: auth.AzureCLIAuthConfig{
|
||||
CLIAuthEnabled: true,
|
||||
},
|
||||
ClientSecretCredentialAuthConfig: auth.ClientSecretCredentialAuthConfig{},
|
||||
ClientCertificateAuthConfig: auth.ClientCertificateAuthConfig{},
|
||||
OIDCAuthConfig: auth.OIDCAuthConfig{},
|
||||
MSIAuthConfig: auth.MSIAuthConfig{},
|
||||
StorageAddresses: auth.StorageAddresses{},
|
||||
WorkloadIdentityAuthConfig: auth.WorkloadIdentityAuthConfig{},
|
||||
ClientSecretCredentialAuthConfig: auth.ClientSecretCredentialAuthConfig{
|
||||
ClientID: os.Getenv("ARM_CLIENT_ID"),
|
||||
ClientSecret: os.Getenv("ARM_CLIENT_SECRET"),
|
||||
},
|
||||
ClientCertificateAuthConfig: auth.ClientCertificateAuthConfig{},
|
||||
OIDCAuthConfig: auth.OIDCAuthConfig{},
|
||||
MSIAuthConfig: auth.MSIAuthConfig{},
|
||||
StorageAddresses: auth.StorageAddresses{
|
||||
SubscriptionID: os.Getenv("ARM_SUBSCRIPTION_ID"),
|
||||
TenantID: os.Getenv("ARM_TENANT_ID"),
|
||||
},
|
||||
WorkloadIdentityAuthConfig: auth.WorkloadIdentityAuthConfig{},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user