|
9 | 9 | import pytest |
10 | 10 | import yaml |
11 | 11 | from charmed_kubeflow_chisme.exceptions import GenericCharmRuntimeError |
| 12 | +from charms.istio_ingress_k8s.v0.istio_ingress_route import ProtocolType |
12 | 13 | from charms.kubeflow_dashboard.v0.kubeflow_dashboard_links import ( |
13 | 14 | DASHBOARD_LINKS_FIELD, |
14 | 15 | DashboardLink, |
@@ -401,6 +402,33 @@ def test_sidecar_and_ambient_relations_added( |
401 | 402 | BlockedStatus, |
402 | 403 | ) |
403 | 404 |
|
| 405 | + @pytest.mark.parametrize("tls_enabled, expected_port", [(False, 80), (True, 443)]) |
| 406 | + @patch("charm.KubernetesServicePatch", lambda x, y: None) |
| 407 | + @patch("charm.IstioIngressRouteRequirer") |
| 408 | + @patch("charm.ServiceMeshConsumer") |
| 409 | + def test_ambient_mesh_ingress( |
| 410 | + self, |
| 411 | + mock_mesh_consumer: MagicMock, |
| 412 | + mock_ingress_cls: MagicMock, |
| 413 | + harness: Harness, |
| 414 | + tls_enabled: bool, |
| 415 | + expected_port: int, |
| 416 | + ): |
| 417 | + """Test that _ambient_mesh_ingress uses the correct port based on TLS setting.""" |
| 418 | + mock_ingress = MagicMock() |
| 419 | + mock_ingress.tls_enabled = tls_enabled |
| 420 | + mock_ingress_cls.return_value = mock_ingress |
| 421 | + |
| 422 | + harness.add_relation("istio-ingress-route", "istio-ingress-k8s") |
| 423 | + harness.set_leader(True) |
| 424 | + harness.begin() |
| 425 | + |
| 426 | + mock_ingress.submit_config.assert_called_once() |
| 427 | + config = mock_ingress.submit_config.call_args[0][0] |
| 428 | + assert len(config.listeners) == 1 |
| 429 | + assert config.listeners[0].port == expected_port |
| 430 | + assert config.listeners[0].protocol == ProtocolType.HTTP |
| 431 | + |
404 | 432 |
|
405 | 433 | def add_sidebar_relation(harness: Harness, other_app_name: str): |
406 | 434 | """Adds a sidebar relation to a harness.""" |
|
0 commit comments