Skip to content
Permalink
Browse files
[JENKINS-51179] - Reproduce the issue in Test
  • Loading branch information
oleg-nenashev committed May 13, 2018
1 parent 68ded5c commit cc9425039aa2f8f46153e404c226cf98b0e65659
Showing with 18 additions and 0 deletions.
  1. +18 −0 test/src/test/java/hudson/model/FingerprintTest.java
@@ -23,13 +23,16 @@
*/
package hudson.model;

import hudson.XmlFile;
import hudson.security.ACL;
import hudson.security.ACLContext;
import hudson.security.AuthorizationMatrixProperty;
import hudson.security.Permission;
import hudson.security.ProjectMatrixAuthorizationStrategy;
import hudson.tasks.ArtifactArchiver;
import hudson.tasks.Fingerprinter;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
@@ -50,6 +53,7 @@
import org.jvnet.hudson.test.SecuredMockFolder;
import org.jvnet.hudson.test.WorkspaceCopyFileBuilder;

import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
@@ -115,6 +119,20 @@ public void shouldCreateUsageLinks() throws Exception {
assertTrue("Usages do not have a reference to " + project, usages.containsKey(project.getName()));
assertTrue("Usages do not have a reference to " + project2, usages.containsKey(project2.getName()));
}

@Test
@Issue("JENKINS-51179")
public void shouldThrowIOExceptionWhenFileIsInvalid() throws Exception {
XmlFile f = new XmlFile(new File(rule.jenkins.getRootDir(), "foo.xml"));
f.write("Hello, world!");
try {
Fingerprint.load(f.getFile());
} catch (IOException ex) {
assertThat(ex.getMessage(), containsString("Unexpected Fingerprint type"));
return;
}
fail("Expected IOException");
}

@Test
@Issue("SECURITY-153")

0 comments on commit cc94250

Please sign in to comment.