mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-14 20:42:21 +00:00
Test for absolute URIs with authorities
This commit is contained in:
1 parent
eca11dfcfc
commit
e24cd27f16
1 file changed
+24
-4
@@ -31,12 +31,32 @@ import org.jvnet.hudson.test.Bug;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class FunctionsTest {
|
||||
@Test
|
||||
public void testGetActionUrl_absoluteUriWithAuthority(){
|
||||
String[] uris = {
|
||||
"http://example.com/foo/bar",
|
||||
"https://example.com/foo/bar",
|
||||
"ftp://example.com/foo/bar",
|
||||
"svn+ssh://nobody@example.com/foo/bar",
|
||||
};
|
||||
for(String uri : uris) {
|
||||
String result = Functions.getActionUrl(null, createMockAction(uri));
|
||||
assertEquals(uri, result);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Bug(7725)
|
||||
public void testGetActionUrl_mailto(){
|
||||
String mailto = "mailto:nobody@example.com";
|
||||
String result = Functions.getActionUrl(null, createMockAction(mailto));
|
||||
assertEquals(mailto, result);
|
||||
public void testGetActionUrl_absoluteUriWithoutAuthority(){
|
||||
String[] uris = {
|
||||
"mailto:nobody@example.com",
|
||||
"mailto:nobody@example.com?subject=hello",
|
||||
"javascript:alert('hello')",
|
||||
};
|
||||
for(String uri : uris) {
|
||||
String result = Functions.getActionUrl(null, createMockAction(uri));
|
||||
assertEquals(uri, result);
|
||||
}
|
||||
}
|
||||
|
||||
private static Action createMockAction(String uri) {
|
||||
|
||||
Reference in new issue
Block a user