Fix URLTest#testAtSignInUserInfo failure
This failure is introduced by libcore change 2e3689a.
The upstream security fix around URLStreamHandler changed behaviour for
URL parsing. Fix the test to match the new behaviour.
Bug: 34722749
Test: libcore.java.net.URLTest#testAtSignInUserInfo
Change-Id: I6a4a362f367e96f0dfe55afa117f201a39afa7cf
(cherry picked from commit eca3a9349803cb699d094772204d8c669fe6640b)
(cherry picked from commit 7e6977749c9b054f91fb216c9dc42d604119483c)
diff --git a/luni/src/test/java/libcore/java/net/URLTest.java b/luni/src/test/java/libcore/java/net/URLTest.java
index 7a323af..0eee1f8 100644
--- a/luni/src/test/java/libcore/java/net/URLTest.java
+++ b/luni/src/test/java/libcore/java/net/URLTest.java
@@ -194,12 +194,12 @@
assertEquals(null, url.getRef());
}
+ // This behavior of URLs with invalid user info changed due to bug http://b/33351987 after
+ // Android security level 1 April 2017.
public void testAtSignInUserInfo() throws Exception {
- try {
- new URL("http://user@userhost.com:password@host");
- fail();
- } catch (MalformedURLException expected) {
- }
+ URL url = new URL("http://user@userhost.com:password@host");
+ assertNull(url.getUserInfo());
+ assertTrue(url.getHost().isEmpty());
}
public void testUserNoPassword() throws Exception {
@@ -785,5 +785,6 @@
final String host = "http://multiple@users@url.com";
URL url = new URL(host);
assertNull(url.getUserInfo());
+ assertTrue(url.getHost().isEmpty());
}
}