-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unsign modified dependency JARs when filtering
Add test for JarResultBuildStep#filterJarFile (cherry picked from commit 7e229d4)
- Loading branch information
Showing
3 changed files
with
99 additions
and
23 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
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
34 changes: 34 additions & 0 deletions
34
core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/JarResultBuildStepTest.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,34 @@ | ||
package io.quarkus.deployment.pkg.steps; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Set; | ||
import java.util.jar.JarEntry; | ||
import java.util.jar.JarFile; | ||
import java.util.jar.Manifest; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
/** | ||
* Test for {@link JarResultBuildStep} | ||
*/ | ||
class JarResultBuildStepTest { | ||
|
||
@Test | ||
void should_unsign_jar_when_filtered(@TempDir Path tempDir) throws Exception { | ||
Path signedJarFilePath = Path.of(getClass().getClassLoader().getResource("signed.jar").toURI()); | ||
Path jarFilePath = tempDir.resolve("unsigned.jar"); | ||
JarResultBuildStep.filterJarFile(signedJarFilePath, jarFilePath, | ||
Set.of("org/eclipse/jgit/transport/sshd/SshdSessionFactory.class")); | ||
try (JarFile jarFile = new JarFile(jarFilePath.toFile())) { | ||
assertThat(jarFile.stream().map(JarEntry::getName)).doesNotContain("META-INF/ECLIPSE_.RSA", "META-INF/ECLIPSE_.SF"); | ||
// Check that the manifest is still present | ||
Manifest manifest = jarFile.getManifest(); | ||
assertThat(manifest.getMainAttributes()).isNotEmpty(); | ||
assertThat(manifest.getEntries()).isEmpty(); | ||
} | ||
} | ||
|
||
} |