-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from NetApp/old-name-security
add old name support to security
- Loading branch information
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
internal/provider/security/security_account_resource_alias_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package security_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
ntest "github.com/netapp/terraform-provider-netapp-ontap/internal/provider" | ||
) | ||
|
||
func TestAccSecurityAccountResourceAlias(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { ntest.TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: ntest.TestAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccSecurityAccountResourceConfigAlias("carchitest", "password"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_security_account_resource.security_account", "name", "carchitest"), | ||
), | ||
}, | ||
// Test updating a resource | ||
{ | ||
Config: testAccSecurityAccountResourceConfigAlias("carchitest", "password123"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_security_account_resource.security_account", "name", "carchitest"), | ||
resource.TestCheckResourceAttr("netapp-ontap_security_account_resource.security_account", "password", "password123"), | ||
), | ||
}, | ||
// Test importing a resource | ||
{ | ||
ResourceName: "netapp-ontap_security_account_resource.security_account", | ||
ImportState: true, | ||
ImportStateId: fmt.Sprintf("%s,%s", "acc_user", "cluster2"), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("netapp-ontap_security_account_resource.security_account", "name", "acc_user"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccSecurityAccountResourceConfigAlias(name string, accpassword string) string { | ||
host := os.Getenv("TF_ACC_NETAPP_HOST2") | ||
admin := os.Getenv("TF_ACC_NETAPP_USER") | ||
password := os.Getenv("TF_ACC_NETAPP_PASS2") | ||
if host == "" || admin == "" || password == "" { | ||
fmt.Println("TF_ACC_NETAPP_HOST, TF_ACC_NETAPP_USER, and TF_ACC_NETAPP_PASS must be set for acceptance tests") | ||
os.Exit(1) | ||
} | ||
return fmt.Sprintf(` | ||
provider "netapp-ontap" { | ||
connection_profiles = [ | ||
{ | ||
name = "cluster2" | ||
hostname = "%s" | ||
username = "%s" | ||
password = "%s" | ||
validate_certs = false | ||
}, | ||
] | ||
} | ||
resource "netapp-ontap_security_account_resource" "security_account" { | ||
# required to know which system to interface with | ||
cx_profile_name = "cluster2" | ||
name = "%s" | ||
applications = [{ | ||
application = "http" | ||
authentication_methods = ["password"] | ||
}] | ||
password = "%s" | ||
} | ||
`, host, admin, password, name, accpassword) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters