Skip to content

Commit 52954d4

Browse files
committed
chore(gateway): listener filter
1 parent 4fb008d commit 52954d4

2 files changed

Lines changed: 33 additions & 19 deletions

File tree

rootfs/api/models/gateway.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def addresses(self):
6464
def listeners(self):
6565
auto_tls = self.app.tls_set.latest().certs_auto_enabled
6666
listeners = []
67-
domains = list(self._get_tls_domain(auto_tls))
67+
domains = list(self.app.domain_set.all())
6868
for item in self.ports:
6969
port, protocol = item["port"], item["protocol"]
7070
if item["protocol"] in HOSTNAME_PROTOCOLS:
@@ -146,12 +146,6 @@ def _check_port(self, port, protocol):
146146
return False
147147
return True
148148

149-
def _get_tls_domain(self, auto_tls):
150-
domains = self.app.domain_set.all()
151-
if not auto_tls:
152-
domains = domains.exclude(certificate=None)
153-
return domains
154-
155149
def _get_listener_name(self, port, protocol, index):
156150
if protocol in ("TCP", "TLS", "HTTP"):
157151
protocol = "TCP"

rootfs/api/tests/test_gateway.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,24 @@ def test_change_tls(self):
328328
app_id = self.create_app_with_domain_and_deploy()
329329
response = self.client.get('/v2/apps/{}/gateways/'.format(app_id))
330330
expect = [{
331-
'allowedRoutes': {
332-
'namespaces': {
333-
'from': 'All'
331+
"allowedRoutes": {
332+
"namespaces": {
333+
"from": "All"
334334
}
335335
},
336-
'name': 'tcp-80-0',
337-
'port': 80,
338-
'protocol': 'HTTP'
336+
"name": "tcp-80-1",
337+
"port": 80,
338+
"hostname": "test-domain.example.com",
339+
"protocol": "HTTP"
340+
}, {
341+
"allowedRoutes": {
342+
"namespaces": {
343+
"from": "All"
344+
}
345+
},
346+
"name": "tcp-80-0",
347+
"port": 80,
348+
"protocol": "HTTP"
339349
}]
340350
self.assertEqual(response.data["count"], 1, response.data)
341351
self.assertEqual(response.data["results"][0]["listeners"], expect, response.data)
@@ -377,14 +387,24 @@ def test_change_tls(self):
377387
self.change_certs_auto(app_id, False)
378388
response = self.client.get('/v2/apps/{}/gateways/'.format(app_id))
379389
expect = [{
380-
'allowedRoutes': {
381-
'namespaces': {
382-
'from': 'All'
390+
"allowedRoutes": {
391+
"namespaces": {
392+
"from": "All"
393+
}
394+
},
395+
"name": "tcp-80-1",
396+
"port": 80,
397+
"hostname": "test-domain.example.com",
398+
"protocol": "HTTP"
399+
}, {
400+
"allowedRoutes": {
401+
"namespaces": {
402+
"from": "All"
383403
}
384404
},
385-
'name': 'tcp-80-0',
386-
'port': 80,
387-
'protocol': 'HTTP'
405+
"name": "tcp-80-0",
406+
"port": 80,
407+
"protocol": "HTTP"
388408
}]
389409
self.assertEqual(response.data["count"], 1, response.data)
390410
self.assertEqual(response.json()["results"][0]["listeners"], expect, response.data)

0 commit comments

Comments
 (0)