From 817b90c99ce81d221207a282ab1578fa5c94050d Mon Sep 17 00:00:00 2001 From: George Politis Date: Fri, 16 Jul 2021 16:06:07 +0100 Subject: [PATCH] feat: Test if we correctly normalise the tenant and room name. --- .../jitsi/meet/test/UrlNormalisationTest.java | 57 +++++++++++++++++++ .../jitsi/meet/test/base/JitsiMeetUrl.java | 33 ++++++++++- src/test/resources/desktop/testng.xml | 5 ++ 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/jitsi/meet/test/UrlNormalisationTest.java diff --git a/src/test/java/org/jitsi/meet/test/UrlNormalisationTest.java b/src/test/java/org/jitsi/meet/test/UrlNormalisationTest.java new file mode 100644 index 000000000..6dac44dca --- /dev/null +++ b/src/test/java/org/jitsi/meet/test/UrlNormalisationTest.java @@ -0,0 +1,57 @@ +/* + * Copyright @ 2018 8x8 Pty Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jitsi.meet.test; + +import org.jitsi.meet.test.base.*; +import org.jitsi.meet.test.web.*; +import org.openqa.selenium.*; +import org.testng.annotations.*; + +import java.net.*; + +import static junit.framework.Assert.assertEquals; + +/** + * Test if we correctly normalise the tenant and room name. + */ +public class UrlNormalisationTest + extends WebTestBase +{ + @Override + public void setupClass() + { + super.setupClass(); + + JitsiMeetUrl jitsiMeetUrl = participants.getJitsiMeetUrl(); + + jitsiMeetUrl.setRoomName(currentRoomName + "@example.com"); + jitsiMeetUrl.setTenantName("tenant@example.com"); + ensureTwoParticipants(jitsiMeetUrl, jitsiMeetUrl); + } + + /** + * Hang up the call and check if we're redirected to the main page. + */ + @Test + public void test() throws MalformedURLException { + final WebDriver driver1 = getParticipant1().getDriver(); + final URL url = new URL(driver1.getCurrentUrl()); + String[] path = url.getPath().split("/"); + + assertEquals("tenantexample.com", path[1]); + assertEquals(currentRoomName + "example.com", path[2]); + } +} diff --git a/src/test/java/org/jitsi/meet/test/base/JitsiMeetUrl.java b/src/test/java/org/jitsi/meet/test/base/JitsiMeetUrl.java index afdc5fe86..2c106ee93 100644 --- a/src/test/java/org/jitsi/meet/test/base/JitsiMeetUrl.java +++ b/src/test/java/org/jitsi/meet/test/base/JitsiMeetUrl.java @@ -47,6 +47,12 @@ public class JitsiMeetUrl */ private String roomName; + /** + * In the example URL: + * "https://server.com/tenant1/room1?login=true#config.debug=true" it's "tenant1". + */ + private String tenantName; + /** * In the example URL: * "https://server.com/room1?login=true#config.debug=true" @@ -299,7 +305,9 @@ public String getServerUrl() /** * Sets the {@link #roomName} part of the conference URL. * - * @param roomName a room name without any special characters. + * @param roomName a room name. Note that the provided string is not going to be URL-encoded, it's simply going to + * be appended to the URL string as is. + * * @return a reference to this object. */ public JitsiMeetUrl setRoomName(String roomName) @@ -308,6 +316,20 @@ public JitsiMeetUrl setRoomName(String roomName) return this; } + /** + * Sets the {@link #tenantName} part of the conference URL. + * + * @param tenantName a tenant name. Note that the provided string is not going to be URL-encoded, it's simply going + * to be appended to the URL string as is. + * + * @return a reference to this object. + */ + public JitsiMeetUrl setTenantName(String tenantName) + { + this.tenantName = tenantName; + return this; + } + /** * Sets the {@link #roomParameters} part of the conference URL. * @@ -349,7 +371,14 @@ public void setServerUrl(String serverUrl) @Override public String toString() { - String url = serverUrl + "/" + roomName; + String url = serverUrl; + + if (StringUtils.isNotBlank(tenantName)) + { + url += "/" + tenantName; + } + + url += "/" + roomName; if (StringUtils.isNotBlank(roomParameters)) { diff --git a/src/test/resources/desktop/testng.xml b/src/test/resources/desktop/testng.xml index b9ba21348..4e32492b4 100644 --- a/src/test/resources/desktop/testng.xml +++ b/src/test/resources/desktop/testng.xml @@ -269,4 +269,9 @@ + + + + +