-
Notifications
You must be signed in to change notification settings - Fork 1
/
fixed_address_test.go
105 lines (97 loc) · 2.77 KB
/
fixed_address_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//go:build all || unittests
// +build all unittests
package infoblox
import (
"os"
"testing"
)
var (
fixedAddressConfig = Config{
Host: os.Getenv("INFOBLOX_HOST"),
Port: os.Getenv("INFOBLOX_PORT"),
Username: os.Getenv("INFOBLOX_USERNAME"),
Password: os.Getenv("INFOBLOX_PASSWORD"),
Version: os.Getenv("INFOBLOX_VERSION"),
DisableTLSVerification: true,
}
fixedAddressClient = New(fixedAddressConfig)
testFixedAddress = FixedAddress{
IPAddress: "172.19.10.1",
Comment: "Gateway",
MatchClient: "RESERVED",
ExtensibleAttributes: newExtensibleAttribute(ExtensibleAttribute{
"Owner": ExtensibleAttributeValue{
Value: "testUser",
},
}),
}
fixedAddressTestNetwork = Network{
CIDR: "172.19.10.0/24",
NetworkView: "default",
Comment: "testing",
ExtensibleAttributes: newExtensibleAttribute(ExtensibleAttribute{
"Owner": ExtensibleAttributeValue{
Value: "testUser",
},
"Gateway": ExtensibleAttributeValue{
Value: "172.19.10.1",
},
}),
}
)
func TestCreateFixedAddress(t *testing.T) {
err := networkClient.CreateNetwork(&fixedAddressTestNetwork)
if err != nil {
t.Errorf("Error creating network: %s", err)
}
err = fixedAddressClient.CreateFixedAddress(&testFixedAddress)
if err != nil {
t.Errorf("Error creating fixed address: %s", err)
}
}
func TestGetFixedAddress(t *testing.T) {
record, err := fixedAddressClient.GetFixedAddressByRef(testFixedAddress.Ref)
if err != nil {
t.Errorf("Error retrieving fixed address: %s", err)
}
prettyPrint(record)
}
func TestUpdateFixedAddress(t *testing.T) {
updates := FixedAddress{
Comment: "testing2",
ExtensibleAttributes: newExtensibleAttribute(ExtensibleAttribute{
"Location": ExtensibleAttributeValue{
Value: "austin",
},
}),
}
record, err := fixedAddressClient.UpdateFixedAddress(testFixedAddress.Ref, updates)
if err != nil {
t.Errorf("Error retrieving fixed address: %s", err)
}
eas := *record.ExtensibleAttributes
if eas["Location"].Value.(string) != "austin" {
t.Errorf("Error updating fixed address. EA value does not match expected value")
}
if record.Comment != "testing2" {
t.Errorf("Error updating fixed address. Comment string does not match expected value")
}
prettyPrint(record)
testFixedAddress = record
}
func TestDeleteFixedAddress(t *testing.T) {
err := fixedAddressClient.DeleteFixedAddress(testFixedAddress.Ref)
if err != nil {
t.Errorf("Error deleting fixed address: %s", err)
}
err = networkClient.DeleteNetwork(fixedAddressTestNetwork.Ref)
if err != nil {
t.Errorf("Error deleting network: %s", err)
}
}
func TestLogoutFixedAddress(t *testing.T) {
err := fixedAddressClient.Logout()
if err != nil {
t.Errorf("Error logging out: %s", err)
}
}