This commit is contained in:
parent
dede32bd63
commit
80666c001e
@ -34,6 +34,10 @@ repositories {
|
||||
addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision])-jdk15.[ext]"
|
||||
}
|
||||
}
|
||||
ivy {
|
||||
// URL can refer to a local directory
|
||||
url "./lib"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -54,4 +58,54 @@ dependencies {
|
||||
|
||||
//junit
|
||||
compile 'junit:junit:4.8.2'
|
||||
|
||||
// Logging
|
||||
testCompile 'ch.qos.logback:logback-core:1.0.13@jar'
|
||||
testCompile 'ch.qos.logback:logback-classic:1.0.13@jar'
|
||||
testCompile 'org.slf4j:log4j-over-slf4j:1.7.5@jar'
|
||||
testCompile 'org.slf4j:jcl-over-slf4j:1.7.5@jar'
|
||||
testCompile 'org.slf4j:jul-to-slf4j:1.7.5@jar'
|
||||
compile 'org.slf4j:slf4j-api:1.7.5@jar'
|
||||
compile 'org.apache.commons:commons-lang3:3.1'
|
||||
compile 'commons-codec:commons-codec:1.3'
|
||||
compile 'commons-httpclient:commons-httpclient:3.1'
|
||||
compile 'commons-io:commons-io:1.4'
|
||||
compile 'com.artofsolving:jodconverter:2.2.1'
|
||||
|
||||
compile 'org.apache.geronimo.specs:geronimo-j2ee-connector_1.5_spec:1.0'
|
||||
compile 'org.openoffice:unoil:3.2.1'
|
||||
compile 'org.openoffice:ridl:3.2.1'
|
||||
compile 'org.openoffice:juh:3.2.1'
|
||||
compile 'org.openoffice:jurt:3.2.1'
|
||||
|
||||
compile 'org.codehaus.groovy:groovy-all:1.6.3'
|
||||
|
||||
|
||||
// Testing
|
||||
testCompile 'org.testng:testng:5.8@jar'
|
||||
testCompile 'org.easymock:easymock:2.4@jar'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir 'src/java'
|
||||
}
|
||||
resources {
|
||||
srcDir 'src/resources'
|
||||
}
|
||||
}
|
||||
test {
|
||||
java {
|
||||
srcDir 'test/unit'
|
||||
}
|
||||
resources {
|
||||
srcDir 'test/resources'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
useTestNG()
|
||||
}
|
||||
|
||||
|
39
bigbluebutton-web/src/java/org/bigbluebutton/api/ParamsProcessorUtil.java
Executable file → Normal file
39
bigbluebutton-web/src/java/org/bigbluebutton/api/ParamsProcessorUtil.java
Executable file → Normal file
@ -19,7 +19,6 @@
|
||||
|
||||
package org.bigbluebutton.api;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
@ -31,6 +30,9 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -259,6 +261,31 @@ public class ParamsProcessorUtil {
|
||||
return newParams;
|
||||
}
|
||||
|
||||
private static final Pattern META_VAR_PATTERN = Pattern.compile("meta_[a-zA-Z][a-zA-Z0-9-]*$");
|
||||
public static Boolean isMetaValid(String param) {
|
||||
Matcher metaMatcher = META_VAR_PATTERN.matcher(param);
|
||||
if (metaMatcher.matches()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String removeMetaString(String param) {
|
||||
return StringUtils.removeStart(param, "meta_");
|
||||
}
|
||||
|
||||
public static Map<String, String> processMetaParam(Map<String, String> params) {
|
||||
Map<String, String> metas = new HashMap<String, String>();
|
||||
for (String key: params.keySet()) {
|
||||
if (isMetaValid(key)){
|
||||
String metaName = removeMetaString(key);
|
||||
metas.put(metaName, params.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
return metas;
|
||||
}
|
||||
|
||||
public Meeting processCreateParams(Map<String, String> params) {
|
||||
String meetingName = params.get("name");
|
||||
if(meetingName == null){
|
||||
@ -299,15 +326,7 @@ public class ParamsProcessorUtil {
|
||||
|
||||
// Collect metadata for this meeting that the third-party app wants to store if meeting is recorded.
|
||||
Map<String, String> meetingInfo = new HashMap<String, String>();
|
||||
for (String key: params.keySet()) {
|
||||
if (key.contains("meta")&&key.indexOf("meta")==0){
|
||||
String[] meta = key.split("_");
|
||||
if(meta.length == 2){
|
||||
log.debug("Got metadata {} = {}", key, params.get(key));
|
||||
meetingInfo.put(meta[1].toLowerCase(), params.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
meetingInfo = processMetaParam(params);
|
||||
|
||||
// Create a unique internal id by appending the current time. This way, the 3rd-party
|
||||
// app can reuse the external meeting id.
|
||||
|
15
bigbluebutton-web/test/resources/testng.xml
Normal file
15
bigbluebutton-web/test/resources/testng.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
|
||||
<suite name="BigBlueButton Test Suite">
|
||||
<test name="Conference tests">
|
||||
<groups>
|
||||
<run>
|
||||
<exclude name="broken"/>
|
||||
<include name="unit"/>
|
||||
</run>
|
||||
</groups>
|
||||
|
||||
<packages>
|
||||
<package name="org.bigbluebutton.api"/>
|
||||
</packages>
|
||||
</test>
|
||||
</suite>
|
@ -0,0 +1,76 @@
|
||||
package org.bigbluebutton.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class ParamsProcessorUtilTest {
|
||||
@BeforeMethod
|
||||
public void setUp() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetaParameter() {
|
||||
boolean passed = ParamsProcessorUtil.isMetaValid("meta_foo");
|
||||
Assert.assertTrue(passed, "The meta check should pass.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidMetaParameterUndescore() {
|
||||
boolean failed = ParamsProcessorUtil.isMetaValid("meta_foo-bar_");
|
||||
Assert.assertFalse(failed, "The meta check should fail due to underscore (_).");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidMetaParameterWrongStartsWith() {
|
||||
boolean failed = ParamsProcessorUtil.isMetaValid("notmeta_foo");
|
||||
Assert.assertFalse(failed, "The meta check should fail due to not starting with 'meta'.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidMetaParameterNonAlphaNumChar() {
|
||||
boolean failed = ParamsProcessorUtil.isMetaValid("meta_foo-bar_&");
|
||||
Assert.assertFalse(failed, "The meta check should fail due to & char.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidMetaParameterNonAlphaAfterMeta() {
|
||||
boolean failed = ParamsProcessorUtil.isMetaValid("meta_1");
|
||||
Assert.assertFalse(failed, "The meta check should fail due to 1 char.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringMetaFromParameter() {
|
||||
String result = ParamsProcessorUtil.removeMetaString("meta_foo");
|
||||
Assert.assertEquals(result, "foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringMetaFromParameterWithDash() {
|
||||
String result = ParamsProcessorUtil.removeMetaString("meta_foo-bar");
|
||||
Assert.assertEquals(result, "foo-bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessMetaParameters() {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("meta_foo", "foo");
|
||||
params.put("meta_bar", "bar");
|
||||
Map<String, String> metas = ParamsProcessorUtil.processMetaParam(params);
|
||||
Assert.assertEquals(metas.size(), 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessMetaParametersSkippingInvalid() {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("meta_foo", "foo");
|
||||
params.put("meta_bar", "bar");
|
||||
params.put("invalid_meta", "discarded");
|
||||
Map<String, String> metas = ParamsProcessorUtil.processMetaParam(params);
|
||||
Assert.assertEquals(metas.size(), 2);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user