diff --git a/extensions/guacamole-auth-quickconnect/pom.xml b/extensions/guacamole-auth-quickconnect/pom.xml index e8d044072..b2fd92286 100644 --- a/extensions/guacamole-auth-quickconnect/pom.xml +++ b/extensions/guacamole-auth-quickconnect/pom.xml @@ -193,6 +193,14 @@ provided + + + junit + junit + 4.10 + test + + diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 4924619f0..c8e954a49 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -167,7 +167,7 @@ public class QCParser { * @throws UnsupportedEncodingException * If Java lacks UTF-8 support. */ - private static Map parseQueryString(String queryStr) + public static Map parseQueryString(String queryStr) throws UnsupportedEncodingException { // Split the query string into the pairs diff --git a/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java new file mode 100644 index 000000000..5567ea3ab --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.guacamole.auth.quickconnect.utility; + +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +/** + * Class to test methods in the QCParser utility class. + */ +public class QCParserTest { + + /** + * Verify that the parseQueryString() method functions as designed. + */ + @Test + public void testParseQueryString() throws UnsupportedEncodingException { + + final String queryString = "param1=value1¶m2=value2=3¶m3=value%3D3¶m4=value%264"; + Map queryMap = QCParser.parseQueryString(queryString); + + assertEquals("value1", queryMap.get("param1")); + assertEquals("value2=3", queryMap.get("param2")); + assertEquals("value=3", queryMap.get("param3")); + assertEquals("value&4", queryMap.get("param4")); + + } + +}