@@ -112,6 +112,48 @@ func TestAccTeam_ManualDelete(t *testing.T) {
112112 })
113113}
114114
115+ // Import user test
116+ func TestAccTeam_import_test (t * testing.T ) {
117+ var team account.Team
118+ n := fmt .Sprintf ("terraform test team %s" , acctest .RandStringFromCharSet (15 , acctest .CharSetAlphaNum ))
119+ ignored_fields := []string {"dhcp_manage_dhcp" , "dhcp_view_dhcp" , "ipam_manage_ipam" , "ipam_view_ipam" , "dns_records" }
120+
121+ resource .Test (t , resource.TestCase {
122+ PreCheck : func () { testAccPreCheck (t ) },
123+ Providers : testAccProviders ,
124+ CheckDestroy : testAccCheckTeamDestroy ,
125+ Steps : []resource.TestStep {
126+ {
127+ Config : fmt .Sprintf (testAccTeamBasic , n ),
128+ Check : resource .ComposeTestCheckFunc (
129+ testAccCheckTeamExists ("ns1_team.foobar" , & team ),
130+ testAccCheckTeamName (& team , n ),
131+ testAccCheckTeamDNSPermission (& team , "view_zones" , true ),
132+ testAccCheckTeamDNSPermission (& team , "zones_allow_by_default" , true ),
133+ testAccCheckTeamDNSPermissionZones (& team , "zones_allow" , []string {"mytest.zone" }),
134+ testAccCheckTeamDNSPermissionZones (& team , "zones_deny" , []string {"myother.zone" }),
135+ testAccCheckTeamDNSPermissionRecords (& team , "dns_records_allow" , []account.PermissionsRecord {
136+ {Domain : "my.ns1.com" , Subdomains : false , Zone : "ns1.com" , RecordType : "A" }}),
137+ testAccCheckTeamDNSPermissionRecords (& team , "dns_records_deny" , []account.PermissionsRecord {
138+ {Domain : "my.test.com" , Subdomains : true , Zone : "test.com" , RecordType : "A" }}),
139+ testAccCheckTeamDataPermission (& team , "manage_datasources" , true ),
140+ testAccCheckTeamIPWhitelists (& team , []account.IPWhitelist {
141+ {Name : "whitelist-1" , Values : []string {"1.1.1.1" , "2.2.2.2" }},
142+ {Name : "whitelist-2" , Values : []string {"3.3.3.3" , "4.4.4.4" }},
143+ }),
144+ ),
145+ },
146+ {
147+ ResourceName : "ns1_team.foobar" ,
148+ ImportState : true ,
149+ ImportStateVerify : true ,
150+ // Ignoring some fields because of how the dns_records work right now
151+ ImportStateVerifyIgnore : ignored_fields ,
152+ },
153+ },
154+ })
155+ }
156+
115157func testAccCheckTeamExists (n string , team * account.Team ) resource.TestCheckFunc {
116158 return func (s * terraform.State ) error {
117159 rs , ok := s .RootModule ().Resources [n ]
0 commit comments