outposts: fix defaults and tests for outposts
This commit is contained in:
@ -3,15 +3,15 @@ from typing import Dict
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from passbook.outposts.controllers.docker import DockerController
|
||||
from passbook.outposts.models import Outpost
|
||||
from passbook.outposts.models import DockerServiceConnection, Outpost
|
||||
from passbook.providers.proxy.models import ProxyProvider
|
||||
|
||||
|
||||
class ProxyDockerController(DockerController):
|
||||
"""Proxy Provider Docker Contoller"""
|
||||
|
||||
def __init__(self, outpost: Outpost):
|
||||
super().__init__(outpost)
|
||||
def __init__(self, outpost: Outpost, connection: DockerServiceConnection):
|
||||
super().__init__(outpost, connection)
|
||||
self.deployment_ports = {
|
||||
"http": 4180,
|
||||
"https": 4443,
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
"""Proxy Provider Kubernetes Contoller"""
|
||||
from passbook.outposts.controllers.kubernetes import KubernetesController
|
||||
from passbook.outposts.models import Outpost
|
||||
from passbook.outposts.models import KubernetesServiceConnection, Outpost
|
||||
from passbook.providers.proxy.controllers.k8s.ingress import IngressReconciler
|
||||
|
||||
|
||||
class ProxyKubernetesController(KubernetesController):
|
||||
"""Proxy Provider Kubernetes Contoller"""
|
||||
|
||||
def __init__(self, outpost: Outpost):
|
||||
super().__init__(outpost)
|
||||
def __init__(self, outpost: Outpost, connection: KubernetesServiceConnection):
|
||||
super().__init__(outpost, connection)
|
||||
self.deployment_ports = {
|
||||
"http": 4180,
|
||||
"https": 4443,
|
||||
|
||||
@ -6,7 +6,7 @@ import yaml
|
||||
from django.test import TestCase
|
||||
|
||||
from passbook.flows.models import Flow
|
||||
from passbook.outposts.models import Outpost, OutpostDeploymentType, OutpostType
|
||||
from passbook.outposts.models import KubernetesServiceConnection, Outpost, OutpostType
|
||||
from passbook.providers.proxy.controllers.kubernetes import ProxyKubernetesController
|
||||
from passbook.providers.proxy.models import ProxyProvider
|
||||
|
||||
@ -23,15 +23,16 @@ class TestControllers(TestCase):
|
||||
external_host="http://localhost",
|
||||
authorization_flow=Flow.objects.first(),
|
||||
)
|
||||
service_connection = KubernetesServiceConnection.objects.get(local=True)
|
||||
outpost: Outpost = Outpost.objects.create(
|
||||
name="test",
|
||||
type=OutpostType.PROXY,
|
||||
deployment_type=OutpostDeploymentType.KUBERNETES,
|
||||
service_connection=service_connection,
|
||||
)
|
||||
outpost.providers.add(provider)
|
||||
outpost.save()
|
||||
|
||||
controller = ProxyKubernetesController(outpost)
|
||||
controller = ProxyKubernetesController(outpost, service_connection)
|
||||
manifest = controller.get_static_deployment()
|
||||
self.assertEqual(len(list(yaml.load_all(manifest, Loader=yaml.SafeLoader))), 4)
|
||||
|
||||
@ -43,14 +44,15 @@ class TestControllers(TestCase):
|
||||
external_host="http://localhost",
|
||||
authorization_flow=Flow.objects.first(),
|
||||
)
|
||||
service_connection = KubernetesServiceConnection.objects.get(local=True)
|
||||
outpost: Outpost = Outpost.objects.create(
|
||||
name="test",
|
||||
type=OutpostType.PROXY,
|
||||
deployment_type=OutpostDeploymentType.KUBERNETES,
|
||||
service_connection=service_connection,
|
||||
)
|
||||
outpost.providers.add(provider)
|
||||
outpost.save()
|
||||
|
||||
controller = ProxyKubernetesController(outpost)
|
||||
controller = ProxyKubernetesController(outpost, service_connection)
|
||||
controller.up()
|
||||
controller.down()
|
||||
|
||||
Reference in New Issue
Block a user