Skip to content

Commit 762339a

Browse files
committed
remove LEGACY_EDGE_PROXY (#7886)
1 parent 30030c8 commit 762339a

File tree

4 files changed

+6
-44
lines changed

4 files changed

+6
-44
lines changed

localstack/services/edge.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,9 @@ def is_trace_logging_enabled(headers) -> bool:
354354

355355

356356
def do_start_edge(bind_address, port, use_ssl, asynchronous=False):
357-
if config.LEGACY_EDGE_PROXY:
358-
serve = do_start_edge_proxy
359-
else:
360-
from localstack.aws.serving.edge import serve_gateway
361-
362-
serve = serve_gateway
357+
from localstack.aws.serving.edge import serve_gateway
363358

364-
return serve(bind_address, port, use_ssl, asynchronous)
359+
return serve_gateway(bind_address, port, use_ssl, asynchronous)
365360

366361

367362
def do_start_edge_proxy(bind_address, port, use_ssl, asynchronous=False):

localstack/services/s3/s3_listener.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ def get_bucket(bucket_name: str) -> FakeBucket:
183183
backend = get_s3_backend()
184184
bucket = backend.buckets.get(bucket_name)
185185
if not bucket:
186-
# note: adding a switch here to be able to handle both, moto's MissingBucket with the
187-
# legacy edge proxy, as well as our custom CommonServiceException with the new Gateway.
188-
if config.LEGACY_EDGE_PROXY:
189-
raise MissingBucket()
190186
raise NoSuchBucket()
191187
return bucket
192188

localstack/services/s3/s3_starter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ def start_s3(port=None, backend_port=None, asynchronous=None, update_listener=No
8282

8383
apply_patches()
8484

85-
if not config.LEGACY_EDGE_PROXY:
86-
add_gateway_compatibility_handlers()
85+
add_gateway_compatibility_handlers()
8786

8887
return start_moto_server(
8988
key="s3",

tests/integration/test_edge.py

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1+
# FIXME: these are remnants of the legacy edge proxy. these tests should somehow be migrated to
2+
# instead either test the LocalstackAwsGateway (integration), or functionality of the http server (unit).
13
import io
24
import json
35
import os
4-
import urllib
56

67
import pytest
78
import requests
89
import xmltodict
9-
from quart import request as quart_request
1010
from requests.models import Request as RequestsRequest
1111

1212
from localstack import config
1313
from localstack.aws.accounts import get_aws_account_id
1414
from localstack.constants import APPLICATION_JSON, HEADER_LOCALSTACK_EDGE_URL
15-
from localstack.http.request import get_full_raw_path
1615
from localstack.services.generic_proxy import (
1716
MessageModifyingProxyListener,
1817
ProxyListener,
@@ -53,9 +52,7 @@ def test_invoke_s3(self):
5352
edge_url = config.get_edge_url()
5453
self._invoke_s3_via_edge(edge_url)
5554

56-
@pytest.mark.xfail(
57-
condition=not config.LEGACY_EDGE_PROXY, reason="failing with new HTTP gateway (only in CI)"
58-
)
55+
@pytest.mark.xfail(reason="failing in CI") # TODO verify this
5956
def test_invoke_s3_multipart_request(self):
6057
edge_url = config.get_edge_url()
6158
self._invoke_s3_via_edge_multipart_form(edge_url)
@@ -361,28 +358,3 @@ def test_request_with_custom_host_header(self):
361358
response = requests.get(f"{url}/2015-03-31/functions", headers=headers)
362359
assert response
363360
assert "Functions" in json.loads(to_str(response.content))
364-
365-
@pytest.mark.skipif(
366-
condition=not config.LEGACY_EDGE_PROXY, reason="only relevant for old edge proxy"
367-
)
368-
def test_forward_raw_path(self, monkeypatch):
369-
class MyListener(ProxyListener):
370-
def forward_request(self, method, path, data, headers):
371-
_path = get_full_raw_path(quart_request)
372-
return {"method": method, "path": _path}
373-
374-
# start listener and configure EDGE_FORWARD_URL
375-
port = get_free_tcp_port()
376-
forward_url = f"http://localhost:{port}"
377-
listener = MyListener()
378-
proxy = start_proxy_server(port, update_listener=listener, use_ssl=True)
379-
monkeypatch.setattr(config, "EDGE_FORWARD_URL", forward_url)
380-
381-
# run test request, assert that raw request path is forwarded
382-
test_arn = "arn:aws:test:resource/test"
383-
raw_path = f"/test/{urllib.parse.quote(test_arn)}/bar?q1=foo&q2=bar"
384-
url = f"{config.get_edge_url()}{raw_path}"
385-
response = requests.get(url)
386-
expected = {"method": "GET", "path": raw_path}
387-
assert json.loads(to_str(response.content)) == expected
388-
proxy.stop()

0 commit comments

Comments
 (0)