Skip to content

Commit

Permalink
Prevent artifact locations that are directories from being opened as …
Browse files Browse the repository at this point in the history
…zip files
  • Loading branch information
JagoGyselinck committed Jun 2, 2021
1 parent 3f2750e commit 4879ea8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ class LicensesTask extends DefaultTask {
}

protected void addGooglePlayServiceLicenses(File artifactFile) {
if (artifactFile.isDirectory()) {
return
}

ZipFile licensesZip = new ZipFile(artifactFile)
JsonSlurper jsonSlurper = new JsonSlurper()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ public void testAddGooglePlayServiceLicenses_withoutDuplicate() throws IOExcepti
assertTrue(licensesTask.licensesMap.containsKey("JSR 305"));
}

@Test
public void testAddGooglePlayServiceLicenses_artifactLocationIsDirectory() throws IOException {
try {
licensesTask.addGooglePlayServiceLicenses(licensesTask.getOutputDir());
} catch (Exception e) {
fail("This test should not throw an Exception.");
}
}

@Test
public void testAppendLicense() throws IOException {
licensesTask.appendLicense("license1", "test".getBytes(UTF_8));
Expand Down

0 comments on commit 4879ea8

Please sign in to comment.