Skip to content

Commit bfc7953

Browse files
committed
add test
1 parent b38082e commit bfc7953

1 file changed

Lines changed: 147 additions & 0 deletions

File tree

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

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,6 +2996,65 @@ def test_get_disable_keda(self):
29962996
with self.assertRaises(MutuallyExclusiveArgumentError):
29972997
ctx_5.get_disable_keda()
29982998

2999+
def test_get_enable_run_command(self):
3000+
ctx_1 = AKSPreviewManagedClusterContext(
3001+
self.cmd,
3002+
AKSManagedClusterParamDict({"enable_run_command": False}),
3003+
self.models,
3004+
DecoratorMode.CREATE,
3005+
)
3006+
self.assertEqual(ctx_1.get_enable_run_command(), False)
3007+
mc_1 = self.models.ManagedCluster(
3008+
location="test_location",
3009+
api_server_access_profile=self.models.ManagedClusterAPIServerAccessProfile(
3010+
disable_run_command=False
3011+
)
3012+
)
3013+
ctx_1.attach_mc(mc_1)
3014+
self.assertEqual(ctx_1.get_enable_run_command(), True)
3015+
3016+
ctx_2 = AKSPreviewManagedClusterContext(
3017+
self.cmd,
3018+
AKSManagedClusterParamDict({"enable_run_command": True, "disable_run_command": True}),
3019+
self.models,
3020+
DecoratorMode.CREATE,
3021+
)
3022+
# fail on mutually exclusive enable_run_command and disable_run_command
3023+
with self.assertRaises(MutuallyExclusiveArgumentError):
3024+
self.assertEqual(ctx_2.get_enable_run_command(), True)
3025+
3026+
ctx_3 = AKSPreviewManagedClusterContext(
3027+
self.cmd,
3028+
AKSManagedClusterParamDict({"enable_run_command": True}),
3029+
self.models,
3030+
DecoratorMode.UPDATE,
3031+
)
3032+
mc_3 = self.models.ManagedCluster(
3033+
location="test_location",
3034+
api_server_access_profile=self.models.ManagedClusterAPIServerAccessProfile(
3035+
disable_run_command=True
3036+
)
3037+
)
3038+
ctx_3.attach_mc(mc_3)
3039+
self.assertEqual(ctx_3.get_enable_run_command(), True)
3040+
3041+
def test_get_disable_run_command(self):
3042+
ctx_1 = AKSPreviewManagedClusterContext(
3043+
self.cmd,
3044+
AKSManagedClusterParamDict({"disable_run_command": False}),
3045+
self.models,
3046+
DecoratorMode.UPDATE,
3047+
)
3048+
self.assertEqual(ctx_1.get_disable_run_command(), False)
3049+
mc_1 = self.models.ManagedCluster(
3050+
location="test_location",
3051+
api_server_access_profile=self.models.ManagedClusterAPIServerAccessProfile(
3052+
disable_run_command=True
3053+
)
3054+
)
3055+
ctx_1.attach_mc(mc_1)
3056+
self.assertEqual(ctx_1.get_disable_run_command(), False)
3057+
29993058
def test_get_defender_config(self):
30003059
ctx_1 = AKSPreviewManagedClusterContext(
30013060
self.cmd,
@@ -4876,6 +4935,24 @@ def test_set_up_custom_ca_trust_certificates(self):
48764935
)
48774936
self.assertEqual(dec_mc_1, ground_truth_mc_1)
48784937

4938+
def test_set_up_run_command(self):
4939+
dec_1 = AKSPreviewManagedClusterCreateDecorator(
4940+
self.cmd,
4941+
self.client,
4942+
{"disable_run_command": True},
4943+
CUSTOM_MGMT_AKS_PREVIEW,
4944+
)
4945+
mc_1 = self.models.ManagedCluster(location="test_location")
4946+
dec_1.context.attach_mc(mc_1)
4947+
dec_mc_1 = dec_1.set_up_run_command(mc_1)
4948+
ground_truth_mc_1 = self.models.ManagedCluster(
4949+
location="test_location",
4950+
api_server_access_profile=self.models.ManagedClusterAPIServerAccessProfile(
4951+
disable_run_command=True
4952+
)
4953+
)
4954+
self.assertEqual(dec_mc_1, ground_truth_mc_1)
4955+
48794956
def test_set_up_ingress_web_app_routing(self):
48804957
dec_1 = AKSPreviewManagedClusterCreateDecorator(
48814958
self.cmd,
@@ -7395,6 +7472,76 @@ def test_update_custom_ca_certificates(self):
73957472
)
73967473
self.assertEqual(dec_mc_2, ground_truth_mc_2)
73977474

7475+
def test_update_run_command(self):
7476+
dec_1 = AKSPreviewManagedClusterUpdateDecorator(
7477+
self.cmd,
7478+
self.client,
7479+
{
7480+
"disable_run_command": True,
7481+
},
7482+
CUSTOM_MGMT_AKS_PREVIEW,
7483+
)
7484+
mc_1 = self.models.ManagedCluster(location="test_location")
7485+
dec_1.context.attach_mc(mc_1)
7486+
dec_mc_1 = dec_1.update_run_command(mc_1)
7487+
7488+
ground_truth_mc_1 = self.models.ManagedCluster(
7489+
location="test_location",
7490+
api_server_access_profile=self.models.ManagedClusterAPIServerAccessProfile(
7491+
disable_run_command=True
7492+
)
7493+
)
7494+
self.assertEqual(dec_mc_1, ground_truth_mc_1)
7495+
7496+
dec_2 = AKSPreviewManagedClusterUpdateDecorator(
7497+
self.cmd,
7498+
self.client,
7499+
{
7500+
"enable_run_command": True,
7501+
},
7502+
CUSTOM_MGMT_AKS_PREVIEW,
7503+
)
7504+
mc_2 = self.models.ManagedCluster(
7505+
location="test_location",
7506+
api_server_access_profile=self.models.ManagedClusterAPIServerAccessProfile(
7507+
disable_run_command=True
7508+
)
7509+
)
7510+
dec_2.context.attach_mc(mc_2)
7511+
dec_mc_2 = dec_2.update_run_command(mc_2)
7512+
ground_truth_mc_2 = self.models.ManagedCluster(
7513+
location="test_location",
7514+
api_server_access_profile=self.models.ManagedClusterAPIServerAccessProfile(
7515+
disable_run_command=False
7516+
)
7517+
)
7518+
self.assertEqual(dec_mc_2, ground_truth_mc_2)
7519+
7520+
dec_3 = AKSPreviewManagedClusterUpdateDecorator(
7521+
self.cmd,
7522+
self.client,
7523+
{
7524+
"enable_run_command": False,
7525+
"disable_run_command": False,
7526+
},
7527+
CUSTOM_MGMT_AKS_PREVIEW,
7528+
)
7529+
mc_3 = self.models.ManagedCluster(
7530+
location="test_location",
7531+
api_server_access_profile=self.models.ManagedClusterAPIServerAccessProfile(
7532+
disable_run_command=True
7533+
)
7534+
)
7535+
dec_3.context.attach_mc(mc_3)
7536+
dec_mc_3 = dec_3.update_run_command(mc_3)
7537+
ground_truth_mc_3 = self.models.ManagedCluster(
7538+
location="test_location",
7539+
api_server_access_profile=self.models.ManagedClusterAPIServerAccessProfile(
7540+
disable_run_command=True
7541+
)
7542+
)
7543+
self.assertEqual(dec_mc_3, ground_truth_mc_3)
7544+
73987545
def test_update_vpa(self):
73997546
dec_1 = AKSPreviewManagedClusterUpdateDecorator(
74007547
self.cmd,

0 commit comments

Comments
 (0)