@@ -15,6 +15,7 @@ func TestPlanAzurePolicy(t *testing.T) {
15
15
16
16
variables := helpers .GetDefaultPlanVars (t )
17
17
variables ["aks_azure_policy_enabled" ] = true
18
+ variables ["aks_network_plugin" ] = "azure"
18
19
19
20
tests := map [string ]helpers.TestCase {
20
21
"azurePolicyEnabledTest" : {
@@ -23,6 +24,69 @@ func TestPlanAzurePolicy(t *testing.T) {
23
24
AttributeJsonPath : "{$.azure_policy_enabled}" ,
24
25
Message : "Unexpected azure_policy_enabled value" ,
25
26
},
27
+ "networkPluginTest" : {
28
+ Expected : "azure" ,
29
+ ResourceMapName : "module.aks.azurerm_kubernetes_cluster.aks" ,
30
+ AttributeJsonPath : "{$.network_profile[0].network_plugin}" ,
31
+ },
32
+ "azurePluginAksPodCidrTest" : {
33
+ Expected : "192.168.0.0/23" ,
34
+ ResourceMapName : "aks_pod_cidr" ,
35
+ Retriever : helpers .RetrieveFromRawPlanOutputChanges ,
36
+ },
37
+ }
38
+
39
+ plan := helpers .GetPlan (t , variables )
40
+ helpers .RunTests (t , tests , plan )
41
+ }
42
+
43
+ // Test the default variables when using the sample-input-defaults.tfvars file
44
+ // with aks_network_plugin set to azure and custom subnets.
45
+ func TestPlanCustomSubnets (t * testing.T ) {
46
+ t .Parallel ()
47
+
48
+ variables := helpers .GetDefaultPlanVars (t )
49
+ variables ["aks_network_plugin" ] = "azure"
50
+ variables ["subnets" ] = map [string ]interface {}{
51
+ "aks" : map [string ]interface {}{
52
+ "prefixes" : []string {"123.12.0.0/21" },
53
+ "service_endpoints" : []string {"Microsoft.Sql" },
54
+ "private_endpoint_network_policies" : "Disabled" ,
55
+ "private_link_service_network_policies_enabled" : false ,
56
+ "service_delegations" : map [string ]interface {}{},
57
+ },
58
+ "misc" : map [string ]interface {}{
59
+ "prefixes" : []string {"123.12.8.0/24" },
60
+ "service_endpoints" : []string {"Microsoft.Sql" },
61
+ "private_endpoint_network_policies" : "Disabled" ,
62
+ "private_link_service_network_policies_enabled" : false ,
63
+ "service_delegations" : map [string ]interface {}{},
64
+ },
65
+ "netapp" : map [string ]interface {}{
66
+ "prefixes" : []string {"123.12.9.0/24" },
67
+ "service_endpoints" : []string {"" },
68
+ "private_endpoint_network_policies" : "Disabled" ,
69
+ "private_link_service_network_policies_enabled" : false ,
70
+ "service_delegations" : map [string ]interface {}{
71
+ "netapp" : map [string ]interface {}{
72
+ "name" : "Microsoft.Netapp/volumes" ,
73
+ "actions" : []string {"Microsoft.Network/networkinterfaces/*" , "Microsoft.Network/virtualNetworks/subnets/join/action" },
74
+ },
75
+ },
76
+ },
77
+ }
78
+
79
+ tests := map [string ]helpers.TestCase {
80
+ "networkPluginTest" : {
81
+ Expected : "azure" ,
82
+ ResourceMapName : "module.aks.azurerm_kubernetes_cluster.aks" ,
83
+ AttributeJsonPath : "{$.network_profile[0].network_plugin}" ,
84
+ },
85
+ "azurePluginAksPodCidrTest" : {
86
+ Expected : "123.12.0.0/21" ,
87
+ ResourceMapName : "aks_pod_cidr" ,
88
+ Retriever : helpers .RetrieveFromRawPlanOutputChanges ,
89
+ },
26
90
}
27
91
28
92
plan := helpers .GetPlan (t , variables )
0 commit comments