Skip to content

Commit 43c9d55

Browse files
pjeanjeantmortagne
authored andcommitted
XWIKI-21471: Improve escaping in Solr Space Faucet
(cherry picked from commit acba74c)
1 parent 296a1be commit 43c9d55

File tree

10 files changed

+366
-4
lines changed

10 files changed

+366
-4
lines changed

xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
<profile>
120120
<id>integration-tests</id>
121121
<modules>
122-
<module>xwiki-platform-search-solr-test-utils</module>
122+
<module>xwiki-platform-search-solr-test</module>
123123
</modules>
124124
</profile>
125125
</profiles>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
* See the NOTICE file distributed with this work for additional
4+
* information regarding copyright ownership.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
-->
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<parent>
26+
<groupId>org.xwiki.platform</groupId>
27+
<artifactId>xwiki-platform-search-solr</artifactId>
28+
<version>15.5.4-SNAPSHOT</version>
29+
</parent>
30+
<artifactId>xwiki-platform-search-solr-test</artifactId>
31+
<name>XWiki Platform - Search - Solr - Tests - Parent POM</name>
32+
<packaging>pom</packaging>
33+
<description>XWiki Platform - Search - Solr - Tests - Parent POM</description>
34+
<properties>
35+
<!-- Don't run backward-compatibility checks in test modules since we don't consider them as public APIs -->
36+
<xwiki.revapi.skip>true</xwiki.revapi.skip>
37+
<!-- Don't run Checkstyle in test modules -->
38+
<xwiki.checkstyle.skip>true</xwiki.checkstyle.skip>
39+
</properties>
40+
<modules>
41+
<module>xwiki-platform-search-solr-test-pageobjects</module>
42+
</modules>
43+
<profiles>
44+
<profile>
45+
<id>integration-tests</id>
46+
<modules>
47+
<module>xwiki-platform-search-solr-test-utils</module>
48+
</modules>
49+
</profile>
50+
<profile>
51+
<id>docker</id>
52+
<modules>
53+
<module>xwiki-platform-search-solr-test-docker</module>
54+
</modules>
55+
</profile>
56+
</profiles>
57+
</project>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
* See the NOTICE file distributed with this work for additional
4+
* information regarding copyright ownership.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
-->
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<parent>
26+
<groupId>org.xwiki.platform</groupId>
27+
<artifactId>xwiki-platform-search-solr-test</artifactId>
28+
<version>15.5.4-SNAPSHOT</version>
29+
</parent>
30+
<artifactId>xwiki-platform-search-solr-test-docker</artifactId>
31+
<name>XWiki Platform - Search - Solr - Tests - Functional Docker Tests</name>
32+
<packaging>jar</packaging>
33+
<description>XWiki Platform - Search - Solr - Tests - Functional Tests in Docker</description>
34+
<properties>
35+
<!-- Functional tests are allowed to output content to the console -->
36+
<xwiki.surefire.captureconsole.skip>true</xwiki.surefire.captureconsole.skip>
37+
</properties>
38+
<dependencies>
39+
<dependency>
40+
<groupId>org.xwiki.platform</groupId>
41+
<artifactId>xwiki-platform-search-solr-ui</artifactId>
42+
<version>${project.version}</version>
43+
<type>xar</type>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.xwiki.platform</groupId>
47+
<artifactId>xwiki-platform-test-docker</artifactId>
48+
<version>${project.version}</version>
49+
<scope>test</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.xwiki.platform</groupId>
53+
<artifactId>xwiki-platform-search-solr-test-utils</artifactId>
54+
<version>${project.version}</version>
55+
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.xwiki.platform</groupId>
59+
<artifactId>xwiki-platform-search-solr-test-pageobjects</artifactId>
60+
<version>${project.version}</version>
61+
<scope>test</scope>
62+
</dependency>
63+
</dependencies>
64+
<build>
65+
<testSourceDirectory>src/test/it</testSourceDirectory>
66+
<plugins>
67+
<!-- We need to explicitly include the failsafe plugin since it's not part of the default maven lifecycle -->
68+
<plugin>
69+
<groupId>org.apache.maven.plugins</groupId>
70+
<artifactId>maven-failsafe-plugin</artifactId>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
<profiles>
75+
<profile>
76+
<id>clover</id>
77+
<!-- Add the Clover JAR to the WAR so that it's available at runtime when XWiki executes.
78+
It's needed because instrumented jars in the WAR will call Clover APIs at runtime when they execute. -->
79+
<dependencies>
80+
<dependency>
81+
<groupId>org.openclover</groupId>
82+
<artifactId>clover</artifactId>
83+
</dependency>
84+
</dependencies>
85+
<build>
86+
<plugins>
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-failsafe-plugin</artifactId>
90+
<configuration>
91+
<systemPropertyVariables>
92+
<!-- Tell the Docker-based test to activate the Clover profile so that the Clover JAR is added to
93+
WEB-INF/lib -->
94+
<xwiki.test.ui.profiles>clover</xwiki.test.ui.profiles>
95+
</systemPropertyVariables>
96+
</configuration>
97+
</plugin>
98+
</plugins>
99+
</build>
100+
</profile>
101+
</profiles>
102+
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.search.solr.test.ui;
21+
22+
import org.junit.jupiter.api.Nested;
23+
import org.xwiki.test.docker.junit5.UITest;
24+
25+
/**
26+
* All UI tests for the Solr Search feature.
27+
*
28+
* @version $Id$
29+
*/
30+
@UITest
31+
class AllIT
32+
{
33+
@Nested
34+
class NestedSolrSearchIT extends SolrSearchIT
35+
{
36+
}
37+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.search.solr.test.ui;
21+
22+
import org.junit.jupiter.api.Test;
23+
import org.xwiki.repository.test.SolrTestUtils;
24+
import org.xwiki.search.solr.test.po.SolrSearchPage;
25+
import org.xwiki.test.docker.junit5.TestConfiguration;
26+
import org.xwiki.test.docker.junit5.UITest;
27+
import org.xwiki.test.docker.junit5.servletengine.ServletEngine;
28+
import org.xwiki.test.integration.XWikiExecutor;
29+
import org.xwiki.test.ui.TestUtils;
30+
31+
import static org.junit.jupiter.api.Assertions.assertEquals;
32+
33+
/**
34+
* Tests Solr search features.
35+
*
36+
* @version $Id$
37+
*/
38+
@UITest
39+
class SolrSearchIT
40+
{
41+
@Test
42+
void verifySpaceFaucetEscaping(TestUtils setup, TestConfiguration testConfiguration) throws Exception {
43+
setup.loginAsSuperAdmin();
44+
45+
String testDocumentLocation = "{{/html}}";
46+
setup.createPage(testDocumentLocation, "WebHome", "Test Document", testDocumentLocation);
47+
48+
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
49+
50+
SolrSearchPage searchPage = SolrSearchPage.gotoPage();
51+
searchPage.search("\"Test Document\"");
52+
searchPage.toggleSpaceFaucet();
53+
assertEquals(testDocumentLocation + "\n1", searchPage.getSpaceFaucetContent());
54+
}
55+
56+
private String computedHostURL(TestConfiguration testConfiguration)
57+
{
58+
ServletEngine servletEngine = testConfiguration.getServletEngine();
59+
return String.format("http://%s:%d%s", servletEngine.getIP(), servletEngine.getPort(),
60+
XWikiExecutor.DEFAULT_CONTEXT);
61+
}
62+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
* See the NOTICE file distributed with this work for additional
4+
* information regarding copyright ownership.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
-->
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<parent>
26+
<groupId>org.xwiki.platform</groupId>
27+
<artifactId>xwiki-platform-search-solr-test</artifactId>
28+
<version>15.5.4-SNAPSHOT</version>
29+
</parent>
30+
<artifactId>xwiki-platform-search-solr-test-pageobjects</artifactId>
31+
<name>XWiki Platform - Search - Solr - Tests - Page Objects</name>
32+
<packaging>jar</packaging>
33+
<description>XWiki Platform - Search - Solr - Tests - Page Objects</description>
34+
<properties>
35+
<!-- None of the classes is valid -->
36+
<xwiki.checkstyle.skip>true</xwiki.checkstyle.skip>
37+
</properties>
38+
<dependencies>
39+
<dependency>
40+
<groupId>org.xwiki.platform</groupId>
41+
<artifactId>xwiki-platform-test-ui</artifactId>
42+
<version>${project.version}</version>
43+
</dependency>
44+
</dependencies>
45+
</project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.search.solr.test.po;
21+
22+
import org.openqa.selenium.WebElement;
23+
import org.openqa.selenium.support.FindBy;
24+
import org.xwiki.test.ui.po.ViewPage;
25+
26+
public class SolrSearchPage extends ViewPage
27+
{
28+
@FindBy(id = "search-page-bar-input")
29+
private WebElement searchInput;
30+
31+
@FindBy(xpath = "//div[@class = 'search-ui']//button[@type = 'submit']")
32+
private WebElement searchButton;
33+
34+
@FindBy(xpath = "//div[@class = 'search-ui']//button[@aria-controls = 'space_facet-dropdown']")
35+
private WebElement spaceFaucetDropdownButton;
36+
37+
@FindBy(xpath = "//div[@id = 'space_facet-dropdown']")
38+
private WebElement spaceFaucetDropdownContent;
39+
40+
public static SolrSearchPage gotoPage()
41+
{
42+
getUtil().gotoPage("Main", "SolrSearch", "view");
43+
return new SolrSearchPage();
44+
}
45+
46+
public void search(String terms) {
47+
this.searchInput.clear();
48+
this.searchInput.sendKeys(terms);
49+
this.searchButton.click();
50+
}
51+
52+
public void toggleSpaceFaucet() {
53+
this.spaceFaucetDropdownButton.click();
54+
}
55+
56+
public String getSpaceFaucetContent() {
57+
return this.spaceFaucetDropdownContent.getText();
58+
}
59+
}

xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-test-utils/pom.xml renamed to xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-test/xwiki-platform-search-solr-test-utils/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<modelVersion>4.0.0</modelVersion>
2525
<parent>
2626
<groupId>org.xwiki.platform</groupId>
27-
<artifactId>xwiki-platform-search-solr</artifactId>
27+
<artifactId>xwiki-platform-search-solr-test</artifactId>
2828
<version>15.5.4-SNAPSHOT</version>
2929
</parent>
3030
<artifactId>xwiki-platform-search-solr-test-utils</artifactId>
File renamed without changes.

0 commit comments

Comments
 (0)