-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce that there are no CSP violations when
csp.rule
is defined (#…
- Loading branch information
Showing
10 changed files
with
155 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/org/jenkinsci/test/acceptance/plugins/csp/ContentSecurityPolicyReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.jenkinsci.test.acceptance.plugins.csp; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.jenkinsci.test.acceptance.po.Jenkins; | ||
import org.jenkinsci.test.acceptance.po.PageObject; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
|
||
public class ContentSecurityPolicyReport extends PageObject { | ||
public ContentSecurityPolicyReport(Jenkins context) { | ||
super(context, context.url("content-security-policy-reports/")); | ||
} | ||
|
||
public List<String> getReport() { | ||
List<String> lines = new ArrayList<>(); | ||
WebElement table = find(By.className("bigtable")); | ||
List<WebElement> headers = table.findElements(By.tagName("th")); | ||
StringBuilder sb = new StringBuilder(); | ||
for (WebElement header : headers) { | ||
sb.append(header.getText()).append("\t"); | ||
} | ||
lines.add(sb.toString()); | ||
sb = new StringBuilder(); | ||
List<WebElement> rows = table.findElements(By.tagName("tr")); | ||
for (WebElement row : rows) { | ||
List<WebElement> cells = row.findElements(By.tagName("td")); | ||
for (WebElement cell : cells) { | ||
sb.append(cell.getText()).append("\t"); | ||
} | ||
lines.add(sb.toString()); | ||
sb = new StringBuilder(); | ||
} | ||
return lines; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.openqa.selenium.By; | ||
|
||
@WithPlugins("mailer") | ||
@Category(DockerTest.class) | ||
|
@@ -41,6 +42,14 @@ public void send_test_mail() throws IOException { | |
Pattern.compile("Test email #1"), | ||
"[email protected]", | ||
Pattern.compile("This is test email #1 sent from Jenkins")); | ||
|
||
/* | ||
* Navigate back to the dashboard first to dismiss the alert so that CspRule can check for violations (see | ||
* FormValidationTest). | ||
*/ | ||
jenkins.runThenConfirmAlert(() -> driver.findElement(By.xpath("//ol[@id=\"breadcrumbs\"]/li[1]/a")) | ||
.click()); | ||
sleep(1000); | ||
} | ||
|
||
@Test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters