100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Skip the mTLS test when test.mosquitto.org fails the signing request (with HTTP 502). (#1451)
Panos Kalogeropoulos85538faf2d14
diff --git a/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovyindex 63ec11e9e..c27278435 100644--- a/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/mqtt/MQTTClientProtocolTest.groovy@@ -29,7 +29,6 @@ import org.bouncycastle.pkcs.PKCS10CertificationRequestimport org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilderimport org.bouncycastle.util.io.pem.PemObjectimport org.bouncycastle.util.io.pem.PemWriter-import org.junit.AssumptionViolatedExceptionimport org.openremote.agent.protocol.mqtt.MQTTAgentimport org.openremote.agent.protocol.mqtt.MQTTAgentLinkimport org.openremote.agent.protocol.mqtt.MQTTProtocol@@ -54,6 +53,7 @@ import org.openremote.model.util.UniqueIdentifierGeneratorimport org.openremote.setup.integration.KeycloakTestSetupimport org.openremote.setup.integration.ManagerTestSetupimport org.openremote.test.ManagerContainerTrait+import org.opentest4j.TestAbortedExceptionimport spock.lang.Specificationimport spock.util.concurrent.PollingConditions@@ -185,13 +185,21 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTrgiven: "expected conditions"def conditions = new PollingConditions(timeout: 100, delay: 0.2)- and: "External connectivity has been assured"- try {- assert new Socket("test.mosquitto.org", 8884) != null- assert new Socket("test.mosquitto.org", 443) != null- } catch (Exception e) {- throw new AssumptionViolatedException("No connectivity to external hosts, skip test");- }+ when:+ Socket webSocket = new Socket("test.mosquitto.org", 443)+ Socket mqttSocket = new Socket("test.mosquitto.org", 8884)+ HttpClient testClient = HttpClient.newHttpClient()+ HttpRequest testRequest = HttpRequest.newBuilder()+ .GET()+ .uri(new URI("https://test.mosquitto.org/ssl/index.php"))+ .build()++ HttpResponse<String> testResponse = testClient.send(testRequest, HttpResponse.BodyHandlers.ofString())++ then:+ if(webSocket == null) throw new TestAbortedException("Mosquitto web server unavailable");+ if(mqttSocket == null) throw new TestAbortedException("Mosquitto MQTT broker unavailable");+ if(testResponse.statusCode() != 200) throw new TestAbortedException("Mosquitto signing service unavailable");and: "the container starts"def container = startContainer(defaultConfig(), defaultServices())@@ -207,7 +215,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTrdef aliasName = "testalias"def keyAlias = Constants.MASTER_REALM + "." + aliasName-+ when:KeyStore clientKeystore = keyStoreService.getKeyStore()KeyStore clientTruststore = keyStoreService.getTrustStore()@@ -244,7 +252,7 @@ class MQTTClientProtocolTest extends Specification implements ManagerContainerTrkeyStoreService.storeKeyStore(clientKeystore)keyStoreService.storeTrustStore(clientTruststore)- when: "an MQTT client agent is created to connect to this tests manager"+ and: "an MQTT client agent is created to connect to this tests manager"def clientId = UniqueIdentifierGenerator.generateId()def agent = new MQTTAgent("Test agent").setRealm(Constants.MASTER_REALM)