Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NMS-16983 : File name field in System Reports is not working. (#7563) #7567

Merged
merged 4 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public String getFileName(final HttpServletRequest request) {
final String outputParameter = request.getParameter("output");
String fileName = null;
if (outputParameter != null && !outputParameter.matches("^[\\s]*$")) {
fileName = new File(outputParameter).getName().replaceAll("[^[:alnum:]\\.]", "");
fileName = new File(outputParameter).getName().replaceAll("[^\\w\\.]", "");
} else {
fileName = "opennms-system-report." + m_formatter.getExtension();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Licensed to The OpenNMS Group, Inc (TOG) under one or more
* contributor license agreements. See the LICENSE.md file
* distributed with this work for additional information
* regarding copyright ownership.
*
* TOG licenses this file to You under the GNU Affero General
* Public License Version 3 (the "License") or (at your option)
* any later version. You may not use this file except in
* compliance with the License. You may obtain a copy of the
* License at:
*
* https://www.gnu.org/licenses/agpl-3.0.txt
*
* 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.opennms.smoketest;

import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.IOException;
import java.time.Duration;
import java.util.Objects;


public class SystemReportPageIT extends UiPageTest {


private Page uiPage;

@Before
public void setUp() throws Exception {
uiPage = new SystemReportPageIT.Page(getBaseUrlInternal());
uiPage.open();
}

@Test
public void systemReport() throws IOException, InterruptedException {


WebElement filenameInput = driver.findElement(By.id("filename"));
filenameInput.sendKeys("abc@!321.txt");
WebElement generateButton = driver.findElement(By.xpath("//input[@class='btn btn-secondary' and @value='Generate System Report']"));
generateButton.click();
execute(() -> {
pageContainsText("abc321.txt");
return null;
});

}

private class Page {
private final String url;

public Page(String baseUrl) {
this.url = Objects.requireNonNull(baseUrl) + "opennms/admin/support/systemReport.htm";
}
public Page open() {
driver.get(url);
System.out.println(url);
new WebDriverWait(driver, Duration.ofSeconds(10)).until(pageContainsText("Choose which plugins to enable:"));
return this;
}



}
}
Loading