providers/proxy: add more kubernetes tests
This commit is contained in:
parent
635f6c1ef2
commit
69d2a1cf3b
|
@ -1,17 +1,23 @@
|
||||||
"""Test Controllers"""
|
"""Test Controllers"""
|
||||||
|
from os import environ
|
||||||
|
from unittest import skipUnless
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from passbook.flows.models import Flow
|
from passbook.flows.models import Flow
|
||||||
from passbook.outposts.models import Outpost, OutpostDeploymentType, OutpostType
|
from passbook.outposts.models import Outpost, OutpostDeploymentType, OutpostType
|
||||||
from passbook.providers.proxy.controllers.kubernetes import KubernetesController
|
from passbook.providers.proxy.controllers.kubernetes import (
|
||||||
|
ProxyKubernetesController,
|
||||||
|
)
|
||||||
from passbook.providers.proxy.models import ProxyProvider
|
from passbook.providers.proxy.models import ProxyProvider
|
||||||
|
|
||||||
|
|
||||||
|
@skipUnless("PB_TEST_K8S" in environ, "Kubernetes test cluster required")
|
||||||
class TestControllers(TestCase):
|
class TestControllers(TestCase):
|
||||||
"""Test Controllers"""
|
"""Test Controllers"""
|
||||||
|
|
||||||
def test_kubernetes_controller(self):
|
def test_kubernetes_controller_static(self):
|
||||||
"""Test Kubernetes Controller"""
|
"""Test Kubernetes Controller"""
|
||||||
provider: ProxyProvider = ProxyProvider.objects.create(
|
provider: ProxyProvider = ProxyProvider.objects.create(
|
||||||
name="test",
|
name="test",
|
||||||
|
@ -22,11 +28,30 @@ class TestControllers(TestCase):
|
||||||
outpost: Outpost = Outpost.objects.create(
|
outpost: Outpost = Outpost.objects.create(
|
||||||
name="test",
|
name="test",
|
||||||
type=OutpostType.PROXY,
|
type=OutpostType.PROXY,
|
||||||
deployment_type=OutpostDeploymentType.CUSTOM,
|
deployment_type=OutpostDeploymentType.KUBERNETES,
|
||||||
)
|
)
|
||||||
outpost.providers.add(provider)
|
outpost.providers.add(provider)
|
||||||
outpost.save()
|
outpost.save()
|
||||||
|
|
||||||
controller = KubernetesController(outpost.pk)
|
controller = ProxyKubernetesController(outpost.pk)
|
||||||
manifest = controller.get_static_deployment()
|
manifest = controller.get_static_deployment()
|
||||||
self.assertEqual(len(list(yaml.load_all(manifest, Loader=yaml.SafeLoader))), 3)
|
self.assertEqual(len(list(yaml.load_all(manifest, Loader=yaml.SafeLoader))), 3)
|
||||||
|
|
||||||
|
def test_kubernetes_controller_deploy(self):
|
||||||
|
"""Test Kubernetes Controller"""
|
||||||
|
provider: ProxyProvider = ProxyProvider.objects.create(
|
||||||
|
name="test",
|
||||||
|
internal_host="http://localhost",
|
||||||
|
external_host="http://localhost",
|
||||||
|
authorization_flow=Flow.objects.first(),
|
||||||
|
)
|
||||||
|
outpost: Outpost = Outpost.objects.create(
|
||||||
|
name="test",
|
||||||
|
type=OutpostType.PROXY,
|
||||||
|
deployment_type=OutpostDeploymentType.KUBERNETES,
|
||||||
|
)
|
||||||
|
outpost.providers.add(provider)
|
||||||
|
outpost.save()
|
||||||
|
|
||||||
|
controller = ProxyKubernetesController(outpost.pk)
|
||||||
|
controller.run()
|
||||||
|
|
Reference in New Issue