From 144aea47911cc017595dc27995a96c901cb154a1 Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Sat, 18 Aug 2018 17:08:08 +0100
Subject: [PATCH v1 3/5] appveyor: RemoteControlTest: mock out
PlatformHookWindows.setupHttpsCertificate()
appveyor test run hangs if root keystore access is attempted
---
.../josm/io/remotecontrol/RemoteControlTest.java | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java b/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
index ad73e835a..9a580dfce 100644
a
|
b
|
import java.nio.charset.StandardCharsets;
|
13 | 13 | import java.nio.file.Files; |
14 | 14 | import java.nio.file.Paths; |
15 | 15 | import java.security.GeneralSecurityException; |
| 16 | import java.security.KeyStore; |
16 | 17 | import java.security.SecureRandom; |
17 | 18 | import java.security.cert.X509Certificate; |
18 | 19 | |
… |
… |
import org.junit.After;
|
26 | 27 | import org.junit.Before; |
27 | 28 | import org.junit.Test; |
28 | 29 | import org.openstreetmap.josm.JOSMFixture; |
| 30 | import org.openstreetmap.josm.TestUtils; |
29 | 31 | import org.openstreetmap.josm.spi.preferences.Config; |
30 | 32 | import org.openstreetmap.josm.tools.Logging; |
| 33 | import org.openstreetmap.josm.tools.PlatformHookWindows; |
| 34 | import org.openstreetmap.josm.tools.PlatformManager; |
| 35 | |
| 36 | import mockit.Mock; |
| 37 | import mockit.MockUp; |
31 | 38 | |
32 | 39 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
33 | 40 | |
… |
… |
public class RemoteControlTest {
|
49 | 56 | RemoteControl.PROP_REMOTECONTROL_HTTPS_ENABLED.put(true); |
50 | 57 | deleteKeystore(); |
51 | 58 | |
| 59 | if (PlatformManager.isPlatformWindows() && "True".equals(System.getenv("APPVEYOR"))) { |
| 60 | // appveyor doesn't like us tinkering with the root keystore, so mock this out |
| 61 | TestUtils.assumeWorkingJMockit(); |
| 62 | new MockUp<PlatformHookWindows>() { |
| 63 | @Mock |
| 64 | public boolean setupHttpsCertificate( |
| 65 | String entryAlias, |
| 66 | KeyStore.TrustedCertificateEntry trustedCert |
| 67 | ) { |
| 68 | return true; |
| 69 | } |
| 70 | }; |
| 71 | } |
| 72 | |
52 | 73 | RemoteControl.start(); |
53 | 74 | disableCertificateValidation(); |
54 | 75 | httpBase = "http://127.0.0.1:"+Config.getPref().getInt("remote.control.port", 8111); |