Skip to content

Commit 3e5a871

Browse files
author
German Robayo Paz
committed
add unit tests
1 parent f952cb8 commit 3e5a871

1 file changed

Lines changed: 67 additions & 2 deletions

File tree

src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4163,6 +4163,71 @@ def test_handle_upgrade_asm(self):
41634163
istio=self.models.IstioServiceMesh(revisions=["asm-1-17", "asm-1-18"]),
41644164
))
41654165

4166+
def test_handle_enable_istio_cni(self):
4167+
# Test enabling Istio CNI on existing ASM-enabled cluster
4168+
ctx_0 = AKSPreviewManagedClusterContext(
4169+
self.cmd,
4170+
AKSManagedClusterParamDict(
4171+
{
4172+
# "enable_azure_service_mesh": True,
4173+
"enable_istio_cni": True,
4174+
# "revision": "asm-1-25"
4175+
}
4176+
),
4177+
self.models,
4178+
decorator_mode=DecoratorMode.UPDATE,
4179+
)
4180+
old_profile = self.models.ServiceMeshProfile(
4181+
mode="Istio",
4182+
istio=self.models.IstioServiceMesh(
4183+
revisions=["asm-1-25"],
4184+
components=self.models.IstioComponents()
4185+
),
4186+
)
4187+
new_profile, updated = ctx_0._handle_istio_cni_asm(old_profile)
4188+
self.assertEqual(updated, True)
4189+
self.assertEqual(new_profile, self.models.ServiceMeshProfile(
4190+
mode="Istio",
4191+
istio=self.models.IstioServiceMesh(
4192+
revisions=["asm-1-25"],
4193+
components=self.models.IstioComponents(
4194+
proxy_redirection_mechanism="CNIChaining"
4195+
)
4196+
)
4197+
))
4198+
4199+
def test_handle_disable_istio_cni(self):
4200+
# Test enabling Istio CNI on existing ASM-enabled cluster
4201+
ctx_0 = AKSPreviewManagedClusterContext(
4202+
self.cmd,
4203+
AKSManagedClusterParamDict(
4204+
{
4205+
"disable_istio_cni": True,
4206+
}
4207+
),
4208+
self.models,
4209+
decorator_mode=DecoratorMode.UPDATE,
4210+
)
4211+
old_profile = self.models.ServiceMeshProfile(
4212+
mode="Istio",
4213+
istio=self.models.IstioServiceMesh(
4214+
revisions=["asm-1-25"],
4215+
components=self.models.IstioComponents()
4216+
),
4217+
)
4218+
new_profile, updated = ctx_0._handle_istio_cni_asm(old_profile)
4219+
self.assertEqual(updated, True)
4220+
self.assertEqual(new_profile, self.models.ServiceMeshProfile(
4221+
mode="Istio",
4222+
istio=self.models.IstioServiceMesh(
4223+
revisions=["asm-1-25"],
4224+
components=self.models.IstioComponents(
4225+
proxy_redirection_mechanism="InitContainers"
4226+
)
4227+
)
4228+
))
4229+
4230+
41664231
def test_get_disable_local_accounts(self):
41674232
# automatic cluster needs to enable the disable_local_accounts
41684233
ctx_1 = AKSPreviewManagedClusterContext(
@@ -5082,7 +5147,7 @@ def test_set_up_kms_infrastructure_encryption(self):
50825147
mc_3 = self.models.ManagedCluster(location="test_location")
50835148
dec_3.context.attach_mc(mc_3)
50845149
dec_mc_3 = dec_3.set_up_kms_infrastructure_encryption(mc_3)
5085-
5150+
50865151
# expected security profile with infrastructure encryption
50875152
ground_truth_kube_resource_encryption_profile_3 = self.models.KubernetesResourceObjectEncryptionProfile(
50885153
infrastructure_encryption="Enabled"
@@ -5112,7 +5177,7 @@ def test_set_up_kms_infrastructure_encryption(self):
51125177
)
51135178
dec_4.context.attach_mc(mc_4)
51145179
dec_mc_4 = dec_4.set_up_kms_infrastructure_encryption(mc_4)
5115-
5180+
51165181
# should add to existing security profile
51175182
ground_truth_kube_resource_encryption_profile_4 = self.models.KubernetesResourceObjectEncryptionProfile(
51185183
infrastructure_encryption="Enabled"

0 commit comments

Comments
 (0)