use of org.jvnet.hudson.test.CreateFileBuilder in project htmlpublisher-plugin by jenkinsci.
the class HtmlFileNameTest method fileNameWithSpecialCharactersAndMultipleSlashes.
@Test
public void fileNameWithSpecialCharactersAndMultipleSlashes() throws Exception {
final String content = "<html><head><title>test</title></head><body>Hello world!</body></html>";
FreeStyleProject job = j.createFreeStyleProject();
job.getBuildersList().add(new CreateFileBuilder("subdir/subdir2/#$&+,;= @.html", content));
job.getPublishersList().add(new HtmlPublisher(Arrays.asList(new HtmlPublisherTarget("report-name", "", "subdir/subdir2/*.html", true, true, false))));
job.save();
j.buildAndAssertSuccess(job);
JenkinsRule.WebClient client = j.createWebClient();
assertEquals(content, client.getPage(job, "report-name/subdir/subdir2/%23%24%26%2B%2C%3B%3D%20%40.html").getWebResponse().getContentAsString());
// published html page(s)
HtmlPage page = client.getPage(job, "report-name");
HtmlInlineFrame iframe = (HtmlInlineFrame) page.getElementById("myframe");
assertEquals("subdir/subdir2/%23%24%26%2B%2C%3B%3D%20%40.html", iframe.getAttribute("src"));
HtmlPage pageInIframe = (HtmlPage) iframe.getEnclosedPage();
assertEquals("Hello world!", pageInIframe.getBody().asNormalizedText());
}
use of org.jvnet.hudson.test.CreateFileBuilder in project htmlpublisher-plugin by jenkinsci.
the class HtmlFileNameTest method fileNameWithSpecialCharactersAndSingleSlash.
@Test
public void fileNameWithSpecialCharactersAndSingleSlash() throws Exception {
final String content = "<html><head><title>test</title></head><body>Hello world!</body></html>";
FreeStyleProject job = j.createFreeStyleProject();
job.getBuildersList().add(new CreateFileBuilder("subdir/#$&+,;= @.html", content));
job.getPublishersList().add(new HtmlPublisher(Arrays.asList(new HtmlPublisherTarget("report-name", "", "subdir/*.html", true, true, false))));
job.save();
j.buildAndAssertSuccess(job);
JenkinsRule.WebClient client = j.createWebClient();
assertEquals(content, client.getPage(job, "report-name/subdir/%23%24%26%2B%2C%3B%3D%20%40.html").getWebResponse().getContentAsString());
// published html page(s)
HtmlPage page = client.getPage(job, "report-name");
HtmlInlineFrame iframe = (HtmlInlineFrame) page.getElementById("myframe");
assertEquals("subdir/%23%24%26%2B%2C%3B%3D%20%40.html", iframe.getAttribute("src"));
HtmlPage pageInIframe = (HtmlPage) iframe.getEnclosedPage();
assertEquals("Hello world!", pageInIframe.getBody().asNormalizedText());
}
use of org.jvnet.hudson.test.CreateFileBuilder in project htmlpublisher-plugin by jenkinsci.
the class Security784Test method security784upgradeTest.
@LocalData
@Test
public void security784upgradeTest() throws Exception {
FreeStyleProject job = j.jenkins.getItemByFullName("thejob", FreeStyleProject.class);
Assert.assertTrue(new File(job.getRootDir(), "htmlreports/foo!!!!bar/index.html").exists());
HtmlPublisherTarget.HTMLAction action = job.getAction(HtmlPublisherTarget.HTMLAction.class);
Assert.assertNotNull(action);
Assert.assertEquals("foo!!!!bar", action.getHTMLTarget().getReportName());
// legacy
Assert.assertEquals("foo!!!!bar", action.getUrlName());
JenkinsRule.WebClient client = j.createWebClient();
HtmlPage page = client.getPage(job, "foo!!!!bar/index.html");
String text = page.getWebResponse().getContentAsString();
Assert.assertEquals("Sun Mar 25 15:42:10 CEST 2018", text.trim());
job.getBuildersList().clear();
String newDate = new Date().toString();
job.getBuildersList().add(new CreateFileBuilder("index.html", newDate));
job.save();
j.buildAndAssertSuccess(job);
Assert.assertTrue(new File(job.getRootDir(), "htmlreports/foo_21_21_21_21bar/index.html").exists());
action = job.getAction(HtmlPublisherTarget.HTMLAction.class);
Assert.assertNotNull(action);
Assert.assertEquals("foo!!!!bar", action.getHTMLTarget().getReportName());
// new
Assert.assertEquals("foo_21_21_21_21bar", action.getUrlName());
text = client.goTo("job/thejob/foo_21_21_21_21bar/index.html").getWebResponse().getContentAsString();
Assert.assertEquals(newDate, text.trim());
// leftovers from legacy naming
Assert.assertTrue(new File(job.getRootDir(), "htmlreports/foo!!!!bar/index.html").exists());
}
Aggregations