Commit 258b73a9 authored by Matija Obreza's avatar Matija Obreza
Browse files

Sanitizer test

parent ecf4fc8e
......@@ -47,12 +47,11 @@
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="${db.showSql}" />
<property name="generateDdl" value="false" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">do-nothing</prop>
<prop key="hibernate.hbm2ddl.auto">${db.hbm2ddl}</prop>
<prop key="hibernate.search.default.indexBase">${lucene.indexDir}</prop>
</props>
</property>
......
......@@ -25,6 +25,7 @@ db.driverClassName = com.mysql.jdbc.Driver
db.username = root
db.password =
db.showSql=false
db.hbm2ddl=do-nothing
c3p0.acquireIncrement=1
c3p0.minPoolSize=5
......
package org.genesys2.server.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.genesys2.server.service.HtmlSanitizer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring/servlet.xml", "classpath:spring/spring-common.xml", "classpath:spring/spring-db.xml",
"classpath:spring/spring-security.xml", "classpath:spring/spring-security-acl.xml", "classpath:spring/spring-cache.xml" })
public class HtmlSanitizerTest {
@Autowired
private HtmlSanitizer htmlSanitizer;
@Test
public void test1() {
assertNotNull(htmlSanitizer);
assertNull(htmlSanitizer.sanitize(null));
assertEquals("", htmlSanitizer.sanitize(""));
assertEquals("genesys 1 2 3", htmlSanitizer.sanitize("genesys 1 2 3"));
assertEquals("<p>genesys 1 2 3</p>", htmlSanitizer.sanitize("<p>genesys 1 2 3</p>"));
assertEquals("<p>genesys 1 2 3</p>", htmlSanitizer.sanitize("<p>genesys 1 2 3<script>alert('haha!');</script></p>"));
assertEquals("<p>genesys 1<br />2 3</p>", htmlSanitizer.sanitize("<p>genesys 1<br />2 3</p>"));
assertEquals("<p>genesys 1 2 3</p>", htmlSanitizer.sanitize("<p>genesys 1 <span>2</span> 3</p>"));
assertEquals("<p>genesys 1</p><p>genesys 1</p>", htmlSanitizer.sanitize("<p>genesys 1</p><p>genesys 1</p>"));
assertEquals(
"GENESYS is the result of collaboration between <a href=\"http://www.bioversityinternational.org/\" rel=\"nofollow\">Bioversity International</a>",
htmlSanitizer
.sanitize("GENESYS is the result of collaboration between <a target='_blank' href='http://www.bioversityinternational.org/'>Bioversity International</a>"));
}
}
......@@ -14,20 +14,19 @@
# limitations under the License.
#-------------------------------------------------------------------------------
#DB connection properties
db.url=jdbc:mysql://localhost/aimprosoft?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
db.driverClassName = com.mysql.jdbc.Driver
db.username = root
db.password =
#In-memory HSQLDB
#db.url=jdbc:hsqldb:mem:test
#db.driverClassName = org.hsqldb.jdbc.JDBCDriver
#db.username = sa
#db.password =
db.url=jdbc:hsqldb:mem:test
db.driverClassName = org.hsqldb.jdbc.JDBCDriver
db.username = sa
db.password =
db.showSql=true
db.hbm2ddl=create
# reCAPTCHA API
captcha.privateKey=A
captcha.publicKey=B
lucene.indexDir=./lucene/
# paths
download.files.dir=/Users/mobreza/Downloads
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment