@@ -2391,6 +2391,71 @@ def test_get_outbound_type(self):
23912391 with self.assertRaises(InvalidArgumentValueError):
23922392 ctx_17.get_outbound_type()
23932393
2394+ # update to UDR on a BYO VNet cluster (subnet known from agentpool) should succeed
2395+ ctx_18 = AKSManagedClusterContext(
2396+ self.cmd,
2397+ AKSManagedClusterParamDict(
2398+ {"outbound_type": CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING}
2399+ ),
2400+ self.models,
2401+ DecoratorMode.UPDATE,
2402+ )
2403+ ctx_18.agentpool_context = mock.MagicMock()
2404+ ctx_18.agentpool_context.get_vnet_subnet_id.return_value = "test_vnet_subnet_id"
2405+ self.assertEqual(
2406+ ctx_18.get_outbound_type(), CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING
2407+ )
2408+
2409+ # update to userAssignedNATGateway on a BYO VNet cluster (subnet known from agentpool) should succeed
2410+ ctx_18_1 = AKSManagedClusterContext(
2411+ self.cmd,
2412+ AKSManagedClusterParamDict(
2413+ {"outbound_type": CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY}
2414+ ),
2415+ self.models,
2416+ DecoratorMode.UPDATE,
2417+ )
2418+ ctx_18_1.agentpool_context = mock.MagicMock()
2419+ ctx_18_1.agentpool_context.get_vnet_subnet_id.return_value = "test_vnet_subnet_id"
2420+ self.assertEqual(
2421+ ctx_18_1.get_outbound_type(), CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY
2422+ )
2423+
2424+ # update to UDR on a managed VNet cluster (no subnet) should fail with a clear error,
2425+ # not ask for --vnet-subnet-id (which is not registered for 'aks update')
2426+ ctx_19 = AKSManagedClusterContext(
2427+ self.cmd,
2428+ AKSManagedClusterParamDict(
2429+ {"outbound_type": CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING}
2430+ ),
2431+ self.models,
2432+ DecoratorMode.UPDATE,
2433+ )
2434+ ctx_19.agentpool_context = mock.MagicMock()
2435+ ctx_19.agentpool_context.get_vnet_subnet_id.return_value = None
2436+ with self.assertRaisesRegex(
2437+ InvalidArgumentValueError,
2438+ "only supported for clusters using a custom",
2439+ ):
2440+ ctx_19.get_outbound_type()
2441+
2442+ # update to userAssignedNATGateway on a managed VNet cluster (no subnet) should fail with a clear error
2443+ ctx_20 = AKSManagedClusterContext(
2444+ self.cmd,
2445+ AKSManagedClusterParamDict(
2446+ {"outbound_type": CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY}
2447+ ),
2448+ self.models,
2449+ DecoratorMode.UPDATE,
2450+ )
2451+ ctx_20.agentpool_context = mock.MagicMock()
2452+ ctx_20.agentpool_context.get_vnet_subnet_id.return_value = None
2453+ with self.assertRaisesRegex(
2454+ InvalidArgumentValueError,
2455+ "only supported for clusters using a custom",
2456+ ):
2457+ ctx_20.get_outbound_type()
2458+
23942459 def test_get_network_plugin_mode(self):
23952460 # default
23962461 ctx_1 = AKSManagedClusterContext(
0 commit comments