Extract out contruction of Web Key Directory URLs
Moves `toWebKeyDirectoryURL` to a separate class adding unit tests for URL correctness as well as support for spaces at the beginning and end of the e-mail. Spaces are frequently automatically inserted by soft keyboards.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package org.sufficientlysecure.keychain.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
|
||||
public class WebKeyDirectoryUtilTest {
|
||||
|
||||
@Test
|
||||
public void testWkd() {
|
||||
URL url = WebKeyDirectoryUtil.toWebKeyDirectoryURL("test-wkd@openkeychain.org");
|
||||
assertNotNull(url);
|
||||
assertEquals("openkeychain.org", url.getHost());
|
||||
assertEquals("https", url.getProtocol());
|
||||
assertEquals("/.well-known/openpgpkey/hu/4hg7tescnttreaouu4z1izeuuyibwww1", url.getPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWkdWithSpaces() {
|
||||
URL url = WebKeyDirectoryUtil.toWebKeyDirectoryURL(" test-wkd@openkeychain.org ");
|
||||
assertNotNull(url);
|
||||
assertEquals("openkeychain.org", url.getHost());
|
||||
assertEquals("https", url.getProtocol());
|
||||
assertEquals("/.well-known/openpgpkey/hu/4hg7tescnttreaouu4z1izeuuyibwww1", url.getPath());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user