8000 Unify hostnames in returned URLs by simonrw · Pull Request #7774 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Unify hostnames in returned URLs #7774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Mar 20, 2023
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5637712
Start tests for url returning
simonrw Feb 23, 2023
0325017
Add patch_hostnames fixture
simonrw Feb 27, 2023
480bb2f
Add test for s3 location
simonrw Feb 27, 2023
61c4994
Add helpers for configuring the hostname
simonrw Mar 1, 2023
3ede981
Use host utils in opensearch
simonrw Mar 1, 2023
dd812b5
Update S3 to use new host config
simonrw Mar 2, 2023
fe4d980
Cover more cases with SQS tests
simonrw Mar 3, 2023
74abbfb
Partially update SQS to use the new config
simonrw Mar 3, 2023
1a1df4e
Add `assert_host_customisation` fixture
simonrw Mar 3, 2023
91e483f
Update lambda function urls to use new localstack_host function
simonrw Mar 7, 2023
2b5d625
Correct typo with localstack-hostname value
simonrw Mar 8, 2023
c94c3f1
Set localstack_hostname to the hostname of the host
simonrw Mar 8, 2023
edad51b
Handle S3 201 response hostname returning
simonrw Mar 8, 2023
a912dc9
S3 vpath: handle HOSTNAME_EXTERNAL if supplied
simonrw Mar 9, 2023
bae2c59
Update s3 vhosts to use new localstack_host config
simonrw Mar 9, 2023
888059a
Run ASF tests correctly
simonrw Mar 10, 2023
fef6b5c
Run ASF lambda tests correctly
simonrw Mar 10, 2023
53dab3a
Add explanation comment for socket.gethostname
simonrw Mar 10, 2023
9845857
Update `s3_listener._update_location`
simonrw Mar 10, 2023
600d22f
Make suggested changes to sqs tests
simonrw Mar 10, 2023
75176fe
Remove outdated comment
simonrw Mar 13, 2023
fa16a0d
Merge branch 'master' into network-unification
simonrw Mar 15, 2023
263bacb
Merge branch 'master' into network-unification
simonrw Mar 16, 2023
a75d3e1
Merge branch 'master' into network-unification
simonrw Mar 17, 2023
2c5899f
Fix pro integration test with s3
simonrw Mar 17, 2023
46ea0e9
Fix issue with legacy s3 provider
simonrw Mar 17, 2023
ba95b63
Increase timeout of tests
simonrw Mar 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cover more cases with SQS tests
These combine the existing hostname changes with external port changes.
  • Loading branch information
simonrw committed Mar 10, 2023
commit fe4d980d094c29cd4928cafe3727e292003e75f1
63 changes: 45 additions & 18 deletions tests/integration/test_network_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,45 +159,72 @@ def test_presigned_post(self, patch_hostnames, s3_bucket, s3_client):


class TestSQS:
def test_off_strategy(self, monkeypatch, sqs_create_queue, patch_hostnames):
external_port = "12345"
"""
Test all combinations of:

monkeypatch.setattr(config, "SQS_ENDPOINT_STRATEGY", "off")
monkeypatch.setattr(config, "SQS_PORT_EXTERNAL", external_port)
* endpoint_strategy
* sqs_port_external
* hostname_external
"""

external_hostname, localstack_hostname = patch_hostnames
def test_off_strategy_without_external_port(
self, monkeypatch, sqs_create_queue, patch_hostnames
):
monkeypatch.setattr(config, "SQS_ENDPOINT_STRATEGY", "off")

queue_url = sqs_create_queue()
queue_name = f"queue-{short_uid()}"
queue_url = sqs_create_queue(QueueName=queue_name)

assert external_hostname in queue_url
hostname_external, localstack_hostname = patch_hostnames
assert constants.LOCALHOST in queue_url
assert queue_name in queue_url

assert hostname_external not in queue_url
assert constants.LOCALHOST_HOSTNAME not in queue_url
assert localstack_hostname not in queue_url

def test_domain_strategy(self, monkeypatch, sqs_create_queue, patch_hostnames):
external_port = "12345"
def test_off_strategy_with_external_port(self, monkeypatch, sqs_create_queue, patch_hostnames):
external_port = 12345
monkeypatch.setattr(config, "SQS_ENDPOINT_STRATEGY", "off")
monkeypatch.setattr(config, "SQS_PORT_EXTERNAL", external_port)

queue_name = f"queue-{short_uid()}"
queue_url = sqs_create_queue(QueueName=queue_name)

hostname_external, localstack_hostname = patch_hostnames
assert hostname_external in queue_url
assert str(external_port) in queue_url
assert queue_name in queue_url

assert localstack_hostname not in queue_url

@pytest.mark.parametrize("external_port", [0, 12345])
def test_domain_strategy(self, external_port, monkeypatch, sqs_create_queue, patch_hostnames):
monkeypatch.setattr(config, "SQS_ENDPOINT_STRATEGY", "domain")
monkeypatch.setattr(config, "SQS_PORT_EXTERNAL", external_port)

external_hostname, localstack_hostname = patch_hostnames
queue_url = sqs_create_queue()
queue_name = f"queue-{short_uid()}"
queue_url = sqs_create_queue(QueueName=queue_name)

hostname_external, localstack_hostname = patch_hostnames
assert constants.LOCALHOST_HOSTNAME in queue_url
assert queue_name in queue_url

assert external_hostname not in queue_url
assert hostname_external not in queue_url
assert localstack_hostname not in queue_url

def test_path_strategy(self, monkeypatch, sqs_create_queue, patch_hostnames):
external_port = "12345"

@pytest.mark.parametrize("external_port", [0, 12345])
def test_path_strategy(self, external_port, monkeypatch, sqs_create_queue, patch_hostnames):
monkeypatch.setattr(config, "SQS_ENDPOINT_STRATEGY", "path")
monkeypatch.setattr(config, "SQS_PORT_EXTERNAL", external_port)

external_hostname, localstack_hostname = patch_hostnames
queue_url = sqs_create_queue()
queue_name = f"queue-{short_uid()}"
queue_url = sqs_create_queue(QueueName=queue_name)

hostname_external, localstack_hostname = patch_hostnames
assert "localhost" in queue_url
assert queue_name in queue_url

assert constants.LOCALHOST_HOSTNAME not in queue_url
assert external_hostname not in queue_url
assert hostname_external not in queue_url
assert localstack_hostname not in queue_url
0