diff --git a/pkg/zerotier/ztmember.go b/pkg/zerotier/ztmember.go index ecfc1ec..616be65 100644 --- a/pkg/zerotier/ztmember.go +++ b/pkg/zerotier/ztmember.go @@ -38,7 +38,7 @@ func ztMemberCollect(vs ValidatedSchema, d *schema.ResourceData, i interface{}) diags = append(diags, vs.Set(d, "allow_ethernet_bridging", ztMember.Config.ActiveBridge)...) diags = append(diags, vs.Set(d, "no_auto_assign_ips", ztMember.Config.NoAutoAssignIPs)...) diags = append(diags, vs.Set(d, "ip_assignments", ztMember.Config.IPAssignments)...) - diags = append(diags, vs.Set(d, "capabilities", ztMember.Config.Capabilities)...) + //diags = append(diags, vs.Set(d, "capabilities", ztMember.Config.Capabilities)...) return diags } diff --git a/provision_test.go b/provision_test.go index d848282..b8bfb5c 100644 --- a/provision_test.go +++ b/provision_test.go @@ -88,6 +88,36 @@ func TestIdentity(t *testing.T) { } } +func TestBasicMembers(t *testing.T) { + tf := getTFTest(t) + tf.Apply("testdata/plans/basic-member.tf") + for _, resource := range a(tf.State()["resources"]) { + m := h(resource) + attrs := h(h(a(m["instances"])[0])["attributes"]) + + switch m["type"] { + case "zerotier_member": + switch m["name"] { + // see TestBasicNetworkSetup for examples on how this loop works. + case "alice": + if attrs["description"].(string) != "Hello, world" { + t.Fatal("description was not set") + } + + isBool(t, attrs["hidden"], true, "hidden") + isBool(t, attrs["allow_ethernet_bridging"], true, "allow_ethernet_bridging") + isBool(t, attrs["no_auto_assign_ips"], true, "no_auto_assign_ips") + + if a(attrs["ip_assignments"])[0].(string) != "10.0.0.1" { + t.Fatal("ip_assignments was improperly set") + } + default: + t.Fatalf("Unexpected network member %q in plan", m["name"]) + } + } + } +} + func TestBasicNetworkSetup(t *testing.T) { tf := getTFTest(t) tf.Apply("testdata/plans/basic-network.tf") diff --git a/testdata/plans/basic-member.tf b/testdata/plans/basic-member.tf new file mode 100644 index 0000000..0238640 --- /dev/null +++ b/testdata/plans/basic-member.tf @@ -0,0 +1,20 @@ +provider "zerotier" {} + +resource "zerotier_identity" "alice" {} +resource "zerotier_network" "alicenet" { + name = "alicenet" + assignment_pool { + cidr = "10.0.0.0/24" + } +} + +resource "zerotier_member" "alice" { + name = "alice" + member_id = zerotier_identity.alice.id + network_id = zerotier_network.alicenet.id + description = "Hello, world" + hidden = true + allow_ethernet_bridging = true + no_auto_assign_ips = true + ip_assignments = ["10.0.0.1"] +}