Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ https://github.com/elastic/apm-agent-python/compare/v5.3.1\...master[Check the d
// Unreleased changes go here
// When the next release happens, nest these changes under the "Python Agent version 5.x" heading

[float]
===== Bug fixes

* Added support for IPv6 address format when parsing urls {pull}649[#649]

[[release-notes-5.x]]
=== Python Agent version 5.x

Expand Down
128 changes: 73 additions & 55 deletions tests/utils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,61 +52,79 @@ def test_deprecation():
deprecated_function()


def test_get_url_dict():
data = {
"http://example.com": {
"protocol": "http:",
"hostname": "example.com",
"pathname": "",
"full": "http://example.com",
},
"http://example.com:443": {
"protocol": "http:",
"hostname": "example.com",
"port": "443",
"pathname": "",
"full": "http://example.com:443",
},
"http://example.com:443/a/b/c": {
"protocol": "http:",
"hostname": "example.com",
"port": "443",
"pathname": "/a/b/c",
"full": "http://example.com:443/a/b/c",
},
"https://example.com:443/": {
"protocol": "https:",
"hostname": "example.com",
"port": "443",
"pathname": "/",
"full": "https://example.com:443/",
},
"https://example.com:443/a/b/c?de": {
"protocol": "https:",
"hostname": "example.com",
"port": "443",
"pathname": "/a/b/c",
"search": "?de",
"full": "https://example.com:443/a/b/c?de",
},
"https://[::ffff:a9fe:a9fe]/a/b/c?de": {
"protocol": "https:",
"hostname": "::ffff:a9fe:a9fe",
"pathname": "/a/b/c",
"search": "?de",
"full": "https://[::ffff:a9fe:a9fe]/a/b/c?de",
},
"http://[::ffff:a9fe:a9fe]:80/a/b/c?de": {
"protocol": "http:",
"hostname": "::ffff:a9fe:a9fe",
"port": "80",
"pathname": "/a/b/c",
"search": "?de",
"full": "http://[::ffff:a9fe:a9fe]:80/a/b/c?de",
},
}
for url, expected in data.items():
assert get_url_dict(url) == expected
@pytest.mark.parametrize(
"url,expected",
[
(
"http://example.com",
{"protocol": "http:", "hostname": "example.com", "pathname": "", "full": "http://example.com"},
),
(
"http://example.com:443",
{
"protocol": "http:",
"hostname": "example.com",
"port": "443",
"pathname": "",
"full": "http://example.com:443",
},
),
(
"http://example.com:443/a/b/c",
{
"protocol": "http:",
"hostname": "example.com",
"port": "443",
"pathname": "/a/b/c",
"full": "http://example.com:443/a/b/c",
},
),
(
"https://example.com:443/",
{
"protocol": "https:",
"hostname": "example.com",
"port": "443",
"pathname": "/",
"full": "https://example.com:443/",
},
),
(
"https://example.com:443/a/b/c?de",
{
"protocol": "https:",
"hostname": "example.com",
"port": "443",
"pathname": "/a/b/c",
"search": "?de",
"full": "https://example.com:443/a/b/c?de",
},
),
(
"https://[::ffff:a9fe:a9fe]/a/b/c?de",
{
"protocol": "https:",
"hostname": "::ffff:a9fe:a9fe",
"pathname": "/a/b/c",
"search": "?de",
"full": "https://[::ffff:a9fe:a9fe]/a/b/c?de",
},
),
(
"http://[::ffff:a9fe:a9fe]:80/a/b/c?de",
{
"protocol": "http:",
"hostname": "::ffff:a9fe:a9fe",
"port": "80",
"pathname": "/a/b/c",
"search": "?de",
"full": "http://[::ffff:a9fe:a9fe]:80/a/b/c?de",
},
),
],
)
def test_get_url_dict(url, expected):
assert get_url_dict(url) == expected


def test_get_name_from_func():
Expand Down