Skip to content

Commit

Permalink
feat: Test if we correctly normalise the tenant and room name.
Browse files Browse the repository at this point in the history
  • Loading branch information
gpolitis committed Jul 22, 2021
1 parent 3f75b33 commit 817b90c
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
57 changes: 57 additions & 0 deletions src/test/java/org/jitsi/meet/test/UrlNormalisationTest.java
Original file line number Diff line number Diff line change
@@ -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]);
}
}
33 changes: 31 additions & 2 deletions src/test/java/org/jitsi/meet/test/base/JitsiMeetUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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.
*
Expand Down Expand Up @@ -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))
{
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/desktop/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,9 @@
<class name="org.jitsi.meet.test.RestTests" />
</classes>
</test>
<test name="UrlNormalisationTest">
<classes>
<class name="org.jitsi.meet.test.UrlNormalisationTest" />
</classes>
</test>
</suite>

0 comments on commit 817b90c

Please sign in to comment.