Remove v5 support
This commit is contained in:
1
.github/workflows/acctest.yml
vendored
1
.github/workflows/acctest.yml
vendored
@@ -34,7 +34,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
unifi_version:
|
||||
- "stable-5"
|
||||
- "6.0"
|
||||
- "6.1"
|
||||
- "6.2"
|
||||
|
||||
14
README.md
14
README.md
@@ -12,20 +12,12 @@ You can browse documentation on the [Terraform provider registry](https://regist
|
||||
|
||||
## Supported Unifi Controller Versions
|
||||
|
||||
Currently this provider is tested against [Docker versions of the v5 and v6 controller](https://github.com/paultyng/terraform-provider-unifi/blob/main/.github/workflows/acctest.yml#L45-L46). The UDM and UDM-Pro versions are slightly different (the API is proxied a little differently) but for the most part should also be supported. Individual patch versions of the controller are not tested, just the latest stable versions.
|
||||
As of version [v0.34](https://github.com/paultyng/terraform-provider-unifi/releases/tag/v0.34.0), this provider only supports version 6 of the Unifi controller software. If you need v5 support, you can pin an older version of the provider.
|
||||
|
||||
There are some differences to be aware of between v5 and v6 controller usages (AP groups vs WLAN groups as an example), but in many cases, the provider should warn or error if used incorrectly. Examples will mostly show v6 usage, and a future major version of the provider will probably remove v5 support.
|
||||
|
||||
When reporting issues, please include your controller version and the method you use to run it.
|
||||
The docker, UDM, and UDM-Pro versions are slightly different (the API is proxied a little differently) but for the most part should all be supported. Individual patch versions of the controller are generally not tested for compatibility, just the latest stable versions.
|
||||
|
||||
## Using the Provider
|
||||
|
||||
### Terraform 0.13 and above
|
||||
### Terraform 1.0 and above
|
||||
|
||||
You can use the provider via the [Terraform provider registry](https://registry.terraform.io/providers/paultyng/unifi).
|
||||
|
||||
### Terraform 0.12 or manual installation
|
||||
|
||||
You can download a pre-built binary from the [releases](https://github.com/paultyng/terraform-provider-unifi/releases) page, these are built using [goreleaser](https://goreleaser.com/) (the [configuration](.goreleaser.yml) is in the repo). You can verify the signature and my [key ownership via Keybase](https://keybase.io/paultyng).
|
||||
|
||||
If you want to build from source, you can simply use `go build` in the root of the repository.
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "unifi_wlan_group Data Source - terraform-provider-unifi"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
unifi_wlan_group data source can be used to retrieve the ID for a WLAN group by name.
|
||||
Please note that WLAN Groups are deprecated in v6 of the controller.
|
||||
---
|
||||
|
||||
# unifi_wlan_group (Data Source)
|
||||
|
||||
`unifi_wlan_group` data source can be used to retrieve the ID for a WLAN group by name.
|
||||
|
||||
Please note that WLAN Groups are deprecated in v6 of the controller.
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Optional
|
||||
|
||||
- **name** (String) The name of the WLAN group to look up. Defaults to `Default`.
|
||||
- **site** (String) The name of the site the wlan group is associated with.
|
||||
|
||||
### Read-Only
|
||||
|
||||
- **id** (String) The ID of this AP group.
|
||||
|
||||
|
||||
@@ -77,9 +77,7 @@ resource "unifi_wlan" "wifi" {
|
||||
- **schedule** (Block List) Start and stop schedules for the WLAN (see [below for nested schema](#nestedblock--schedule))
|
||||
- **site** (String) The name of the site to associate the wlan with.
|
||||
- **uapsd** (Boolean) Enable Unscheduled Automatic Power Save Delivery Defaults to `false`.
|
||||
- **vlan_id** (Number, Deprecated) VLAN ID for the network. Set network_id instead of vlan_id for controller version >= 6.
|
||||
- **wlan_band** (String) Radio band your WiFi network will use.
|
||||
- **wlan_group_id** (String, Deprecated) ID of the WLAN group to use for this network. Set ap_group_ids instead of wlan_group_id for controller version >= 6.
|
||||
- **wpa3_support** (Boolean) Enable WPA 3 support (security must be `wpapsk`).
|
||||
- **wpa3_transition** (Boolean) Enable WPA 3 and WPA 2 support (security must be `wpapsk` and `wpa3_support` must be true).
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/go-version"
|
||||
)
|
||||
|
||||
var (
|
||||
controllerV5 = version.Must(version.NewVersion("5.0.0"))
|
||||
controllerV6 = version.Must(version.NewVersion("6.0.0"))
|
||||
|
||||
// https://community.ui.com/releases/UniFi-Network-Controller-6-1-61/62f1ad38-1ac5-430c-94b0-becbb8f71d7d
|
||||
@@ -15,3 +16,14 @@ var (
|
||||
func (c *client) ControllerVersion() *version.Version {
|
||||
return version.Must(version.NewVersion(c.c.Version()))
|
||||
}
|
||||
|
||||
func checkMinimumControllerVersion(versionString string) error {
|
||||
v, err := version.NewVersion(versionString)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if v.LessThan(controllerV6) {
|
||||
return fmt.Errorf("Controller version %q or greater is required to use the provider, found %q.", controllerV6, v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,17 +15,3 @@ func preCheckMinVersion(t *testing.T, min *version.Version) {
|
||||
t.Skipf("skipping test on controller version %q (need at least %q)", v, min)
|
||||
}
|
||||
}
|
||||
|
||||
func preCheckV6Only(t *testing.T) {
|
||||
preCheckMinVersion(t, controllerV6)
|
||||
}
|
||||
|
||||
func preCheckV5Only(t *testing.T) {
|
||||
v, err := version.NewVersion(testClient.Version())
|
||||
if err != nil {
|
||||
t.Fatalf("error parsing version: %s", err)
|
||||
}
|
||||
if v.GreaterThanOrEqual(controllerV6) {
|
||||
t.Skipf("skipping test on controller version %q", v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package provider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
@@ -37,10 +37,6 @@ func dataAPGroup() *schema.Resource {
|
||||
func dataAPGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
c := meta.(*client)
|
||||
|
||||
if v := c.ControllerVersion(); !v.GreaterThanOrEqual(controllerV6) {
|
||||
return diag.Errorf("AP groups are not supported on controller version %q", v)
|
||||
}
|
||||
|
||||
name := d.Get("name").(string)
|
||||
site := d.Get("site").(string)
|
||||
if site == "" {
|
||||
|
||||
@@ -10,7 +10,6 @@ func TestAccDataAPGroup_default(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
// TODO: CheckDestroy: ,
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataWLANGroup() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Description: "`unifi_wlan_group` data source can be used to retrieve the ID for a WLAN group by name.\n\n" +
|
||||
"Please note that WLAN Groups are deprecated in v6 of the controller.",
|
||||
|
||||
DeprecationMessage: "WLAN groups are deprecated in controller version 6 and greater.",
|
||||
|
||||
ReadContext: dataWLANGroupRead,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Description: "The ID of this AP group.",
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"site": {
|
||||
Description: "The name of the site the wlan group is associated with.",
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
},
|
||||
"name": {
|
||||
Description: "The name of the WLAN group to look up.",
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "Default",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dataWLANGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
c := meta.(*client)
|
||||
|
||||
if v := c.ControllerVersion(); !v.LessThan(controllerV6) {
|
||||
return diag.Errorf("WLAN groups are not supported on controller version %q", v)
|
||||
}
|
||||
|
||||
name := d.Get("name").(string)
|
||||
|
||||
site := d.Get("site").(string)
|
||||
if site == "" {
|
||||
site = c.site
|
||||
}
|
||||
|
||||
groups, err := c.c.ListWLANGroup(ctx, site)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
for _, g := range groups {
|
||||
if g.Name == name {
|
||||
d.SetId(g.ID)
|
||||
d.Set("site", site)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return diag.Errorf("WLAN group not found with name %s", name)
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDataWLANGroup_default(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV5Only(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
// TODO: CheckDestroy: ,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccDataWLANGroupConfig_default,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const testAccDataWLANGroupConfig_default = `
|
||||
data "unifi_wlan_group" "default" {
|
||||
}
|
||||
`
|
||||
@@ -65,7 +65,11 @@ func (c *lazyClient) init(ctx context.Context) error {
|
||||
}
|
||||
|
||||
initErr = c.inner.Login(ctx, c.user, c.pass)
|
||||
if initErr != nil {
|
||||
return
|
||||
}
|
||||
|
||||
initErr = checkMinimumControllerVersion(c.inner.Version())
|
||||
log.Printf("[TRACE] Unifi controller version: %q", c.inner.Version())
|
||||
})
|
||||
return initErr
|
||||
|
||||
@@ -73,9 +73,8 @@ func New(version string) func() *schema.Provider {
|
||||
"unifi_network": dataNetwork(),
|
||||
"unifi_port_profile": dataPortProfile(),
|
||||
"unifi_radius_profile": dataRADIUSProfile(),
|
||||
"unifi_user": dataUser(),
|
||||
"unifi_user_group": dataUserGroup(),
|
||||
"unifi_wlan_group": dataWLANGroup(),
|
||||
"unifi_user": dataUser(),
|
||||
},
|
||||
ResourcesMap: map[string]*schema.Resource{
|
||||
// TODO: "unifi_ap_group"
|
||||
|
||||
@@ -294,7 +294,6 @@ func TestAccNetwork_dhcpRelay(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
// TODO: CheckDestroy: ,
|
||||
|
||||
@@ -183,9 +183,6 @@ func resourceWLAN() *schema.Resource {
|
||||
// TODO: this validation is from the UI, if other values work, perhaps remove this is set it to a range instead?
|
||||
ValidateFunc: validation.IntInSlice(append([]int{0}, wlanValidMinimumDataRate5g...)),
|
||||
},
|
||||
|
||||
// controller v6 fields
|
||||
// TODO: this could be defaulted to "both" once v5 controller support is dropped
|
||||
"wlan_band": {
|
||||
Description: "Radio band your WiFi network will use.",
|
||||
Type: schema.TypeString,
|
||||
@@ -193,36 +190,18 @@ func resourceWLAN() *schema.Resource {
|
||||
ValidateFunc: validation.StringInSlice([]string{"2g", "5g", "both"}, false),
|
||||
},
|
||||
"network_id": {
|
||||
Description: "ID of the network for this SSID",
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ConflictsWith: []string{"vlan_id"},
|
||||
Description: "ID of the network for this SSID",
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"ap_group_ids": {
|
||||
Description: "IDs of the AP groups to use for this network.",
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
ConflictsWith: []string{"wlan_group_id"},
|
||||
Description: "IDs of the AP groups to use for this network.",
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
|
||||
// controller v5 fields
|
||||
"vlan_id": {
|
||||
Description: "VLAN ID for the network.",
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
ConflictsWith: []string{"network_id"},
|
||||
Deprecated: "Set network_id instead of vlan_id for controller version >= 6.",
|
||||
},
|
||||
"wlan_group_id": {
|
||||
Description: "ID of the WLAN group to use for this network.",
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ConflictsWith: []string{"ap_group_ids"},
|
||||
Deprecated: "Set ap_group_ids instead of wlan_group_id for controller version >= 6.",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -264,34 +243,11 @@ func resourceWLANGetResourceData(d *schema.ResourceData, meta interface{}) (*uni
|
||||
|
||||
// version specific fields and validation
|
||||
networkID := d.Get("network_id").(string)
|
||||
vlan := d.Get("vlan_id").(int)
|
||||
apGroupIDs, err := setToStringSlice(d.Get("ap_group_ids").(*schema.Set))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
wlanGroupID := d.Get("wlan_group_id").(string)
|
||||
wlanBand := d.Get("wlan_band").(string)
|
||||
switch v := c.ControllerVersion(); {
|
||||
case v.GreaterThanOrEqual(controllerV6):
|
||||
if wlanGroupID != "" {
|
||||
return nil, fmt.Errorf("wlan_group_id is not supported on controller version %q", v)
|
||||
}
|
||||
if vlan != 0 {
|
||||
return nil, fmt.Errorf("vlan_id %d is not supported on controller version %q", vlan, v)
|
||||
}
|
||||
case v.GreaterThanOrEqual(controllerV5):
|
||||
if networkID != "" {
|
||||
return nil, fmt.Errorf("network_id is not supported on controller version %q", v)
|
||||
}
|
||||
if len(apGroupIDs) > 0 {
|
||||
return nil, fmt.Errorf("ap_group_ids is not supported on controller version %q", v)
|
||||
}
|
||||
if wlanBand != "" {
|
||||
return nil, fmt.Errorf("wlan_band is not supported on controller version %q", v)
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("controller version %q not supported", v)
|
||||
}
|
||||
|
||||
schedule, err := listToScheduleStrings(d.Get("schedule").([]interface{}))
|
||||
if err != nil {
|
||||
@@ -319,11 +275,6 @@ func resourceWLANGetResourceData(d *schema.ResourceData, meta interface{}) (*uni
|
||||
ScheduleEnabled: len(schedule) > 0,
|
||||
WLANBand: wlanBand,
|
||||
|
||||
// v5
|
||||
VLAN: vlan,
|
||||
WLANGroupID: wlanGroupID,
|
||||
VLANEnabled: vlan != 0 && vlan != 1,
|
||||
|
||||
// TODO: add to schema
|
||||
WPAEnc: "ccmp",
|
||||
WPAMode: "wpa2",
|
||||
@@ -371,12 +322,6 @@ func resourceWLANCreate(ctx context.Context, d *schema.ResourceData, meta interf
|
||||
|
||||
func resourceWLANSetResourceData(resp *unifi.WLAN, d *schema.ResourceData, meta interface{}, site string) diag.Diagnostics {
|
||||
// c := meta.(*client)
|
||||
|
||||
vlan := 0
|
||||
if resp.VLANEnabled {
|
||||
vlan = resp.VLAN
|
||||
}
|
||||
|
||||
security := resp.Security
|
||||
passphrase := resp.XPassphrase
|
||||
wpa3 := false
|
||||
@@ -424,6 +369,9 @@ func resourceWLANSetResourceData(resp *unifi.WLAN, d *schema.ResourceData, meta
|
||||
d.Set("no2ghz_oui", resp.No2GhzOui)
|
||||
d.Set("l2_isolation", resp.L2Isolation)
|
||||
d.Set("uapsd", resp.UapsdEnabled)
|
||||
d.Set("ap_group_ids", apGroupIDs)
|
||||
d.Set("network_id", resp.NetworkID)
|
||||
|
||||
if resp.MinrateNgEnabled {
|
||||
d.Set("minimum_data_rate_2g_kbps", resp.MinrateNgDataRateKbps)
|
||||
} else {
|
||||
@@ -435,15 +383,6 @@ func resourceWLANSetResourceData(resp *unifi.WLAN, d *schema.ResourceData, meta
|
||||
d.Set("minimum_data_rate_5g_kbps", 0)
|
||||
}
|
||||
|
||||
// switch v := c.ControllerVersion(); {
|
||||
// case v.GreaterThanOrEqual(controllerV6):
|
||||
d.Set("ap_group_ids", apGroupIDs)
|
||||
d.Set("network_id", resp.NetworkID)
|
||||
// case v.GreaterThanOrEqual(controllerV5):
|
||||
d.Set("vlan_id", vlan)
|
||||
d.Set("wlan_group_id", resp.WLANGroupID)
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ func TestAccWLAN_wpapsk(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
@@ -69,7 +68,6 @@ func TestAccWLAN_open(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
@@ -110,7 +108,6 @@ func TestAccWLAN_change_security(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
@@ -150,7 +147,6 @@ func TestAccWLAN_schedule(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
@@ -182,7 +178,6 @@ func TestAccWLAN_wpaeap(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
@@ -209,7 +204,6 @@ func TestAccWLAN_wlan_band(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
@@ -236,7 +230,6 @@ func TestAccWLAN_no2ghz_oui(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
@@ -263,7 +256,6 @@ func TestAccWLAN_uapsd(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
@@ -290,7 +282,6 @@ func TestAccWLAN_wpa3(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
preCheckMinVersion(t, controllerVersionWPA3)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
@@ -332,7 +323,6 @@ func TestAccWLAN_minimum_data_rate(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV6Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
|
||||
@@ -1,325 +0,0 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccWLAN_v5_wpapsk(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV5Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
CheckDestroy: func(*terraform.State) error {
|
||||
// TODO: actual CheckDestroy
|
||||
|
||||
<-wlanConcurrency
|
||||
return nil
|
||||
},
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccWLANConfig_v5_wpapsk,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_wlan.test"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccWLAN_v5_open(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV5Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
CheckDestroy: func(*terraform.State) error {
|
||||
// TODO: actual CheckDestroy
|
||||
|
||||
<-wlanConcurrency
|
||||
return nil
|
||||
},
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccWLANConfig_v5_open,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_wlan.test"),
|
||||
{
|
||||
Config: testAccWLANConfig_v5_open_mac_filter,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_wlan.test"),
|
||||
{
|
||||
Config: testAccWLANConfig_v5_open,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_wlan.test"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccWLAN_v5_change_security(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV5Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
CheckDestroy: func(*terraform.State) error {
|
||||
// TODO: actual CheckDestroy
|
||||
|
||||
<-wlanConcurrency
|
||||
return nil
|
||||
},
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccWLANConfig_v5_wpapsk,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_wlan.test"),
|
||||
{
|
||||
Config: testAccWLANConfig_v5_open,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_wlan.test"),
|
||||
{
|
||||
Config: testAccWLANConfig_v5_wpapsk,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccWLAN_v5_schedule(t *testing.T) {
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV5Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
CheckDestroy: func(*terraform.State) error {
|
||||
// TODO: actual CheckDestroy
|
||||
|
||||
<-wlanConcurrency
|
||||
return nil
|
||||
},
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccWLANConfig_v5_schedule,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_wlan.test"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccWLAN_v5_wpaeap(t *testing.T) {
|
||||
if os.Getenv("UNIFI_TEST_RADIUS") == "" {
|
||||
t.Skip("UNIFI_TEST_RADIUS not set, skipping RADIUS test")
|
||||
}
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV5Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
CheckDestroy: func(*terraform.State) error {
|
||||
// TODO: actual CheckDestroy
|
||||
|
||||
<-wlanConcurrency
|
||||
return nil
|
||||
},
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccWLANConfig_v5_wpaeap,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_wlan.test"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccWLAN_v5_no2ghz_oui(t *testing.T) {
|
||||
if os.Getenv("UNIFI_TEST_RADIUS") == "" {
|
||||
t.Skip("UNIFI_TEST_RADIUS not set, skipping RADIUS test")
|
||||
}
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
preCheck(t)
|
||||
preCheckV5Only(t)
|
||||
wlanPreCheck(t)
|
||||
},
|
||||
ProviderFactories: providerFactories,
|
||||
CheckDestroy: func(*terraform.State) error {
|
||||
// TODO: actual CheckDestroy
|
||||
|
||||
<-wlanConcurrency
|
||||
return nil
|
||||
},
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccWLANConfig_v5_no2ghz_oui,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckNetworkExists(t, "name"),
|
||||
),
|
||||
},
|
||||
importStep("unifi_wlan.test"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const testAccWLANConfig_v5_wpapsk = `
|
||||
data "unifi_wlan_group" "default" {
|
||||
}
|
||||
|
||||
data "unifi_user_group" "default" {
|
||||
}
|
||||
|
||||
resource "unifi_wlan" "test" {
|
||||
name = "tfacc-wpapsk"
|
||||
vlan_id = 202
|
||||
passphrase = "12345678"
|
||||
wlan_group_id = data.unifi_wlan_group.default.id
|
||||
user_group_id = data.unifi_user_group.default.id
|
||||
security = "wpapsk"
|
||||
|
||||
multicast_enhance = true
|
||||
}
|
||||
`
|
||||
|
||||
const testAccWLANConfig_v5_wpaeap = `
|
||||
data "unifi_wlan_group" "default" {
|
||||
}
|
||||
|
||||
data "unifi_user_group" "default" {
|
||||
}
|
||||
|
||||
data "unifi_radius_profile" "default" {
|
||||
}
|
||||
|
||||
resource "unifi_wlan" "test" {
|
||||
name = "tfacc-wpapsk"
|
||||
vlan_id = 202
|
||||
passphrase = "12345678"
|
||||
wlan_group_id = data.unifi_wlan_group.default.id
|
||||
user_group_id = data.unifi_user_group.default.id
|
||||
security = "wpaeap"
|
||||
|
||||
radius_profile_id = data.unifi_radius_profile.default.id
|
||||
}
|
||||
`
|
||||
|
||||
const testAccWLANConfig_v5_open = `
|
||||
data "unifi_wlan_group" "default" {
|
||||
}
|
||||
|
||||
data "unifi_user_group" "default" {
|
||||
}
|
||||
|
||||
resource "unifi_wlan" "test" {
|
||||
name = "tfacc-open"
|
||||
vlan_id = 202
|
||||
wlan_group_id = data.unifi_wlan_group.default.id
|
||||
user_group_id = data.unifi_user_group.default.id
|
||||
security = "open"
|
||||
}
|
||||
`
|
||||
|
||||
const testAccWLANConfig_v5_schedule = `
|
||||
data "unifi_wlan_group" "default" {
|
||||
}
|
||||
|
||||
data "unifi_user_group" "default" {
|
||||
}
|
||||
|
||||
resource "unifi_wlan" "test" {
|
||||
name = "tfacc-open-schedule"
|
||||
vlan_id = 202
|
||||
wlan_group_id = data.unifi_wlan_group.default.id
|
||||
user_group_id = data.unifi_user_group.default.id
|
||||
security = "open"
|
||||
|
||||
schedule {
|
||||
day_of_week = "mon"
|
||||
block_start = "03:00"
|
||||
block_end = "9:00"
|
||||
}
|
||||
|
||||
schedule {
|
||||
day_of_week = "wed"
|
||||
block_start = "13:00"
|
||||
block_end = "17:00"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const testAccWLANConfig_v5_open_mac_filter = `
|
||||
data "unifi_wlan_group" "default" {
|
||||
}
|
||||
|
||||
data "unifi_user_group" "default" {
|
||||
}
|
||||
|
||||
resource "unifi_wlan" "test" {
|
||||
name = "tfacc-open"
|
||||
vlan_id = 202
|
||||
wlan_group_id = data.unifi_wlan_group.default.id
|
||||
user_group_id = data.unifi_user_group.default.id
|
||||
security = "open"
|
||||
|
||||
mac_filter_enabled = true
|
||||
mac_filter_list = ["ab:cd:ef:12:34:56"]
|
||||
mac_filter_policy = "allow"
|
||||
}
|
||||
`
|
||||
|
||||
const testAccWLANConfig_v5_no2ghz_oui = `
|
||||
data "unifi_wlan_group" "default" {
|
||||
}
|
||||
|
||||
data "unifi_user_group" "default" {
|
||||
}
|
||||
|
||||
resource "unifi_wlan" "test" {
|
||||
name = "tfacc-wpapsk"
|
||||
vlan_id = 202
|
||||
passphrase = "12345678"
|
||||
wlan_group_id = data.unifi_wlan_group.default.id
|
||||
user_group_id = data.unifi_user_group.default.id
|
||||
security = "wpapsk"
|
||||
no2ghz_oui = false
|
||||
|
||||
multicast_enhance = true
|
||||
}
|
||||
`
|
||||
@@ -1,3 +1,4 @@
|
||||
//go:build tools
|
||||
// +build tools
|
||||
|
||||
package tools
|
||||
|
||||
Reference in New Issue
Block a user