Merge pull request #3573 from nextcloud/crashOnLoginURL

Remove exception
This commit is contained in:
Andy Scherzinger 2019-02-06 14:19:03 +01:00 committed by GitHub
commit ac4bcc7a72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 15 deletions

View file

@ -573,9 +573,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
} else if (value.startsWith("server" + LOGIN_URL_DATA_KEY_VALUE_SEPARATOR)) {
loginUrlInfo.serverAddress = URLDecoder.decode(
value.substring(("server" + LOGIN_URL_DATA_KEY_VALUE_SEPARATOR).length()));
} else {
// error illegal URL element detected
throw new IllegalArgumentException("Illegal magic login URL element detected: " + value);
}
}

View file

@ -1,4 +1,4 @@
/**
/*
* Nextcloud Android client application
*
* @author Andy Scherzinger
@ -157,17 +157,24 @@ public class AuthenticatorDataUrlTest {
}
}
@Test(expected = IllegalArgumentException.class)
public void noDataUrlElements() {
AuthenticatorActivity.parseLoginDataUrl(schemeUrl, "");
}
@Test
public void tooLittleDataUrlElements() {
for (String urlStart : urlStarts) {
try {
System.out.println(urlStart);
AuthenticatorActivity.parseLoginDataUrl(urlStart, urlStart);
Assert.fail("Illegal Argument Exception expected!");
} catch (IllegalArgumentException e) {
// all well
System.out.println("Expected Illegal Argument Exception caught.");
}
}
public void onlyOneDataUrlElements() {
LoginUrlInfo loginUrlInfo = AuthenticatorActivity.parseLoginDataUrl(schemeUrl, schemeUrl + userUrlPart);
Assert.assertEquals(userValue, loginUrlInfo.username);
}
@Test
public void onlyTwoDataUrlElements() {
LoginUrlInfo loginUrlInfo = AuthenticatorActivity.parseLoginDataUrl(schemeUrl, schemeUrl + userUrlPart +
plus + addressUrlPart);
Assert.assertEquals(userValue, loginUrlInfo.username);
Assert.assertEquals(addressValue, loginUrlInfo.serverAddress);
}
}