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
Increase test coverage
Wouter Bornbbb01d5fdad9
diff --git a/test/src/test/groovy/org/openremote/test/users/UserSessionResourceTest.groovy b/test/src/test/groovy/org/openremote/test/users/UserSessionResourceTest.groovyindex 277f61b78..3c72787b0 100644--- a/test/src/test/groovy/org/openremote/test/users/UserSessionResourceTest.groovy+++ b/test/src/test/groovy/org/openremote/test/users/UserSessionResourceTest.groovy@@ -34,6 +34,7 @@ import static java.nio.charset.StandardCharsets.UTF_8import static java.util.concurrent.TimeUnit.SECONDSimport static org.openremote.manager.mqtt.MQTTBrokerService.MQTT_SERVER_LISTEN_HOSTimport static org.openremote.manager.mqtt.MQTTBrokerService.MQTT_SERVER_LISTEN_PORT+import static org.openremote.model.Constants.KEYCLOAK_CLIENT_IDimport static org.openremote.model.Constants.MASTER_REALMimport static org.openremote.model.util.MapAccess.getIntegerimport static org.openremote.model.util.MapAccess.getString@@ -52,11 +53,13 @@ class UserSessionResourceTest extends Specification implements ManagerContainerTdef uri = serverUri(serverPort)def ownerToken = authenticate(container, realm, owner.username, owner.secret)def otherToken = authenticate(container, realm, other.username, other.secret)+ def crossRealmToken = authenticate(container, MASTER_REALM, KEYCLOAK_CLIENT_ID, setup.testuser1.username, "testuser1")def superuserToken = authenticate(container, MASTER_REALM, superuser.username, superuser.secret)def ownerTarget = getClientApiTarget(uri, realm, ownerToken)def superuserTarget = getClientApiTarget(uri, MASTER_REALM, superuserToken)def ownerResource = ownerTarget.proxy(UserResource)def otherResource = getClientApiTarget(uri, realm, otherToken).proxy(UserResource)+ def crossRealmResource = getClientApiTarget(uri, MASTER_REALM, crossRealmToken).proxy(UserResource)def anonymousResource = getClientApiTarget(uri, realm).proxy(UserResource)def superuserResource = superuserTarget.proxy(UserResource)def conditions = new PollingConditions(timeout: 15, initialDelay: 0.1, delay: 0.2)@@ -102,6 +105,15 @@ class UserSessionResourceTest extends Specification implements ManagerContainerTclient.state == MqttClientState.CONNECTEDbroker.getConnectionUserId(sessionId) == owner.id+ when: "a non-superuser from another realm supplies the session owner's realm"+ crossRealmResource.disconnectUserSession(null, realm, sessionId)++ then:+ def crossRealmException = thrown(WebApplicationException)+ crossRealmException.response.status == 405+ client.state == MqttClientState.CONNECTED+ broker.getConnectionUserId(sessionId) == owner.id+when: "a superuser supplies the wrong realm"superuserResource.disconnectUserSession(null, MASTER_REALM, sessionId)