-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathwhitelist_ips_test.go
More file actions
59 lines (56 loc) · 1.69 KB
/
Copy pathwhitelist_ips_test.go
File metadata and controls
59 lines (56 loc) · 1.69 KB
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
package test
import (
"path/filepath"
"testing"
)
// TestWhitelistIPsValidation tests the whitelist_ips variable validation
func TestWhitelistIPsValidation(t *testing.T) {
tests := []struct {
name string
tfvarsFile string
expectError bool
description string
}{
{
name: "ValidEmptyWhitelist",
tfvarsFile: filepath.Join("test", fixturesDir, "whitelist-ips-empty.tfvars"),
expectError: false,
description: "Empty whitelist_ips should pass validation",
},
{
name: "ValidSingleIP",
tfvarsFile: filepath.Join("test", fixturesDir, "whitelist-ips-single.tfvars"),
expectError: false,
description: "Single valid IP address should pass validation",
},
{
name: "ValidCIDR",
tfvarsFile: filepath.Join("test", fixturesDir, "whitelist-ips-cidr.tfvars"),
expectError: false,
description: "Valid CIDR block should pass validation",
},
{
name: "ValidMultiple",
tfvarsFile: filepath.Join("test", fixturesDir, "whitelist-ips-multiple.tfvars"),
expectError: false,
description: "Multiple valid IPs and CIDR blocks should pass validation",
},
{
name: "InvalidIPFormat",
tfvarsFile: filepath.Join("test", fixturesDir, "whitelist-ips-invalid-format.tfvars"),
expectError: true,
description: "Invalid IP format should fail validation",
},
{
name: "InvalidCIDR",
tfvarsFile: filepath.Join("test", fixturesDir, "whitelist-ips-invalid-cidr.tfvars"),
expectError: true,
description: "Invalid CIDR format should fail validation",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
runValidationTest(t, tt.name, tt.tfvarsFile, tt.expectError, tt.description)
})
}
}