aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/scala
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-11-27 11:36:45 +0100
committeradamw <adam@warski.org>2017-11-27 11:36:45 +0100
commit54722c73e472178f96416fbff8929d9a699d3e03 (patch)
tree3d812a94d4a909270f9a6335d0966f536cab549c /core/src/test/scala
parent01b1d2b9dc062ab004f096ffb6fcb175f28d95aa (diff)
downloadsttp-54722c73e472178f96416fbff8929d9a699d3e03.tar.gz
sttp-54722c73e472178f96416fbff8929d9a699d3e03.tar.bz2
sttp-54722c73e472178f96416fbff8929d9a699d3e03.zip
Properly encoding ipv6 addresses
Diffstat (limited to 'core/src/test/scala')
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/UriTests.scala19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala
index 3c54fd2..23fe3d5 100644
--- a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala
@@ -50,8 +50,7 @@ class UriTests extends FunSuite with Matchers {
"http://example.com#f:g/h%20i",
Uri("http", None, "example.com", None, List("key=value"), Nil, None) ->
"http://example.com/key=value",
- Uri("http", "www.mikołak.net") ->
- "http://www.xn--mikoak-6db.net"
+ Uri("2001:db8::ff00:42:8329", 8080) -> "http://[2001:db8::ff00:42:8329]:8080"
)
for {
@@ -112,6 +111,22 @@ class UriTests extends FunSuite with Matchers {
}
}
+ val hostTestData = List(
+ "www.mikołak.net" -> "http://www.xn--mikoak-6db.net",
+ "192.168.1.0" -> "http://192.168.1.0",
+ "::1" -> "http://[::1]",
+ "2001:db8::ff00:42:8329" -> "http://[2001:db8::ff00:42:8329]",
+ "2001:0db8:0000:0000:0000:ff00:0042:8329" -> "http://[2001:0db8:0000:0000:0000:ff00:0042:8329]"
+ )
+
+ for {
+ (host, expected) <- hostTestData
+ } {
+ test(s"host $host should serialize to $expected") {
+ Uri(host).toString should be(s"$expected")
+ }
+ }
+
test("should convert from java URI") {
val uriAsString = "https://sub.example.com:8080/a/b/xyz?p1=v1&p2=v2#f"
Uri(URI.create(uriAsString)).toString should be(uriAsString)