Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/org/labkey/test/tests/elispotassay/ElispotAssayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ public void testMeanAndMedian()
List<String> expected4FMedians = Arrays.asList("0.0", "0.0", "6666.7", "0.0");
List<String> expected6FMeans = Arrays.asList("0.0", "0.0", "0.0", "0.0");
List<String> expected6FMedians = Arrays.asList("0.0", "0.0", "0.0", "0.0");
Bag<List<String>> expectedRows = new HashBag<>(DataRegionTable.collateColumnsIntoRows(
MultiSet<List<String>> expectedRows = new HashMultiSet<>(DataRegionTable.collateColumnsIntoRows(
expectedPtids,
expected2FMeans,
expected2FMedians,
Expand All @@ -766,7 +766,7 @@ public void testMeanAndMedian()
expected6FMeans,
expected6FMedians));

Bag<List<String>> actualRows = new HashBag<>(table.getRows(
MultiSet<List<String>> actualRows = new HashMultiSet<>(table.getRows(
"ParticipantID",
"Atg2FMean",
"Atg2FMedian",
Expand Down
31 changes: 16 additions & 15 deletions src/org/labkey/test/util/CspLogUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
public class CspLogUtil
{
private static final List<String> ignoredViolations = List.of(
"/_rstudio/",
"/_rstudioReport/"
"/_rstudio/",
"/_rstudioReport/"
);
private static final Set<String> ignoredDirectives = Collections.emptySet();

Expand Down Expand Up @@ -124,7 +124,7 @@ public static void checkNewCspWarnings(ArtifactCollector artifactCollector)
}

boolean foundVioloation = false;
MultiValuedMap<Crawler.ControllerActionId, String> violoations = new HashSetValuedHashMap<>();
MultiValuedMap<Crawler.ControllerActionId, String> violations = new HashSetValuedHashMap<>();
List<CspReport> cspReports = new ArrayList<>();
StringBuilder sb = new StringBuilder();
for (String line : warningLines)
Expand All @@ -148,7 +148,7 @@ public static void checkNewCspWarnings(ArtifactCollector artifactCollector)

for (CspReport cspReport : cspReports)
{
String url = cspReport.getDocumentUri();
String url = cspReport.getDocumentUrl();
String violatedDirective = cspReport.getViolatedDirective();
if (ignoredViolations.stream().anyMatch(url::contains) || ignoredDirectives.contains(violatedDirective))
{
Expand All @@ -157,20 +157,20 @@ public static void checkNewCspWarnings(ArtifactCollector artifactCollector)
else
{
Crawler.ControllerActionId actionId = new Crawler.ControllerActionId(url);
violoations.put(actionId, cspReport.toString());
violations.put(actionId, cspReport.toString());
}
}

if (!violoations.isEmpty())
if (!violations.isEmpty())
{
StringBuilder errorMessage = new StringBuilder()
.append("Detected CSP violations on the following actions (See log for more detail: ")
.append(recentWarningsFile.getAbsolutePath())
.append("):");
for (Crawler.ControllerActionId actionId : violoations.keySet())
for (Crawler.ControllerActionId actionId : violations.keySet())
{
errorMessage.append("\n\t");
Collection<String> urls = violoations.get(actionId);
Collection<String> urls = violations.get(actionId);
errorMessage.append(actionId);
if (urls.size() > 1)
{
Expand Down Expand Up @@ -221,28 +221,29 @@ public CspWarningDetectedException(Object detailMessage)
class CspReport
{
private final String _violatedDirective;
private final String _documentUri;
private final String _documentUrl;

CspReport(String reportStr)
{
JSONObject report = new JSONObject(reportStr).getJSONObject("csp-report");
_violatedDirective = report.getString("violated-directive");
_documentUri = report.getString("document-uri");
// Support report-to reports only. GitHub Issue #900
JSONObject report = new JSONObject(reportStr).getJSONObject("body");
_violatedDirective = report.getString("effectiveDirective");
_documentUrl = report.getString("documentURL");
}

public String getViolatedDirective()
{
return _violatedDirective;
}

public String getDocumentUri()
public String getDocumentUrl()
{
return _documentUri;
return _documentUrl;
}

@Override
public String toString()
{
return getViolatedDirective() + ": " + getDocumentUri();
return getViolatedDirective() + ": " + getDocumentUrl();
}
}