Merge lp:~cjwatson/launchpad/test-apachelogparser-ipv6 into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 19026
Proposed branch: lp:~cjwatson/launchpad/test-apachelogparser-ipv6
Merge into: lp:launchpad
Diff against target: 22 lines (+12/-0)
1 file modified
lib/lp/services/apachelogparser/tests/test_apachelogparser.py (+12/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/test-apachelogparser-ipv6
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+370769@code.launchpad.net

Commit message

Test that apachelogparser can handle IPv6 addresses.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/apachelogparser/tests/test_apachelogparser.py'
2--- lib/lp/services/apachelogparser/tests/test_apachelogparser.py 2019-05-24 11:10:38 +0000
3+++ lib/lp/services/apachelogparser/tests/test_apachelogparser.py 2019-07-30 14:51:58 +0000
4@@ -82,6 +82,18 @@
5 self.assertEqual(
6 request, 'GET /10133748/cramfsswap_1.4.1.tar.gz HTTP/1.0')
7
8+ def test_parsing_line_with_ipv6_address(self):
9+ # IPv6 addresses in the hostname field are parsed.
10+ line = (r'2001:67c:1560:8003::8003 - - [25/Jan/2009:15:48:07 +0000] '
11+ r'"GET /10133748/cramfsswap_1.4.1.tar.gz HTTP/1.0" 200 12341 '
12+ r'"http://foo.bar/baz" "Mozilla/5.0"')
13+ host, date, status, request = get_host_date_status_and_request(line)
14+ self.assertEqual(host, '2001:67c:1560:8003::8003')
15+ self.assertEqual(date, '[25/Jan/2009:15:48:07 +0000]')
16+ self.assertEqual(status, '200')
17+ self.assertEqual(
18+ request, 'GET /10133748/cramfsswap_1.4.1.tar.gz HTTP/1.0')
19+
20 def test_day_extraction(self):
21 date = '[13/Jun/2008:18:38:57 +0100]'
22 self.assertEqual(get_day(date), datetime(2008, 6, 13))