diff options
author | Oron Sharabi <oron@bigpanda.io> | 2020-06-29 17:39:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-29 10:39:17 -0400 |
commit | 53f8d96a1faf3b0f97e793b2e4ea86c64c12cbfa (patch) | |
tree | d0517ef072593265d8a96aaec8ad7cc3279f96b3 /std/http/server_test.ts | |
parent | 06f34a1aed2541866f32438d7bbc75e35c1d5dc3 (diff) |
fix(std/http): Support ipv6 parsing (#5263)
Diffstat (limited to 'std/http/server_test.ts')
-rw-r--r-- | std/http/server_test.ts | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/std/http/server_test.ts b/std/http/server_test.ts index 340d9fa73..5a4a48932 100644 --- a/std/http/server_test.ts +++ b/std/http/server_test.ts @@ -13,7 +13,14 @@ import { assertStringContains, assertThrowsAsync, } from "../testing/asserts.ts"; -import { Response, ServerRequest, Server, serve, serveTLS } from "./server.ts"; +import { + Response, + ServerRequest, + Server, + serve, + serveTLS, + _parseAddrFromStr, +} from "./server.ts"; import { BufReader, BufWriter } from "../io/bufio.ts"; import { delay } from "../async/delay.ts"; import { encode, decode } from "../encoding/utf8.ts"; @@ -612,3 +619,43 @@ Deno.test({ } }, }); + +Deno.test({ + name: "server.serve() should be able to parse IPV4 address", + fn: (): void => { + const server = serve("127.0.0.1:8124"); + const expected = { + hostname: "127.0.0.1", + port: 8124, + transport: "tcp", + }; + assertEquals(expected, server.listener.addr); + server.close(); + }, +}); + +Deno.test({ + name: "server.parseAddrFromStr() should be able to parse IPV6 address", + fn: (): void => { + const addr = _parseAddrFromStr("[::1]:8124"); + const expected = { + hostname: "[::1]", + port: 8124, + }; + assertEquals(expected, addr); + }, +}); + +Deno.test({ + name: "server.serve() should be able to parse IPV6 address", + fn: (): void => { + const server = serve("[::1]:8124"); + const expected = { + hostname: "::1", + port: 8124, + transport: "tcp", + }; + assertEquals(expected, server.listener.addr); + server.close(); + }, +}); |