1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.gpg.it;
20
21 import java.io.File;
22
23 import org.apache.maven.shared.invoker.InvocationRequest;
24 import org.apache.maven.shared.invoker.InvocationResult;
25 import org.codehaus.plexus.util.FileUtils;
26 import org.junit.jupiter.api.Test;
27
28 import static org.junit.jupiter.api.Assertions.assertNotEquals;
29 import static org.junit.jupiter.api.Assertions.assertTrue;
30
31 public class GpgSignAttachedMojoIT extends ITSupport {
32 @Test
33 void testInteractiveWithoutPassphrase() throws Exception {
34
35 final File pomFile =
36 InvokerTestUtils.getTestResource("/it/sign-release-without-passphrase-interactive/pom.xml");
37 final InvocationRequest request =
38 InvokerTestUtils.createRequest(pomFile, mavenUserSettings, gpgHome, "gpg", false);
39
40
41 request.setBatchMode(false);
42
43
44 final BuildResult result = InvokerTestUtils.executeRequest(request, mavenHome, localRepository);
45
46 final InvocationResult invocationResult = result.getInvocationResult();
47 final String buildLogContent = FileUtils.fileRead(result.getBuildLog());
48
49
50 assertNotEquals(0, invocationResult.getExitCode(), "Maven execution must fail");
51 assertTrue(
52 buildLogContent.contains("[GNUPG:] FAILURE sign 67108949"),
53 "Maven execution failed because no pinentry program is available");
54 }
55 }