Skip to content

Commit

Permalink
Add functional tests xwikisas#16
Browse files Browse the repository at this point in the history
* removed unnecessary code
* code refactoring
  • Loading branch information
ChiuchiuSorin committed Mar 28, 2024
1 parent 292a560 commit eec7de8
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public Map<String, String> getDataAsJSON() throws Exception
systemInfo.put("databaseName", dbMetadata.get(METADATA_NAME));
systemInfo.put("databaseVersion", dbMetadata.get(METADATA_VERSION));
systemInfo.put("xwikiCfgPath", getCurrentServer().getXwikiCfgFolderPath());
systemInfo.put("serverPath", getCurrentServer().getServerPath());
systemInfo.put("tomcatConfPath", this.getCurrentServer().getServerCfgPath());
systemInfo.put("javaVersion", this.getJavaVersion());
Map<String, String> serverMetadata = this.usageDataProvider.getServerMetadata();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@
$escapetool.xml($services.localization.render('adminTools.dashboard.download.view.description'))
<ul>
<li>
<a href="$adminToolsFilesPath/xwikiConfig"
target="_blank">
<a href="$adminToolsFilesPath/xwikiConfig" id="xwiki-config-file" target="_blank">
$escapetool.xml($services.localization.render('adminTools.dashboard.download.view.configuration'))
</a>
</li>
<li>
<a href="$adminToolsFilesPath/xwikiProperties"
target="_blank">
<a href="$adminToolsFilesPath/xwikiProperties" id="xwiki-properties-file" target="_blank">
$escapetool.xml($services.localization.render('adminTools.dashboard.download.view.properties'))
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>com.xwiki.admintools</groupId>
<artifactId>application-admintools-test</artifactId>
<version>1.0-rc-2-SNAPSHOT</version>
<version>1.0-rc-3-SNAPSHOT</version>
</parent>
<artifactId>application-admintools-test-docker</artifactId>
<name>Admin Tools Application - Tests - Functional Docker Tests</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,9 @@ void adminToolsHomePageFilesNotAdmin(TestUtils testUtils)
{
testUtils.login(USER_NAME, PASSWORD);

DashboardFilesSectionView filesSectionView = AdminToolsHomePage.getFilesSection();
WebElement filesSectionNonAdminView = filesSectionView.getNonAdminUserView();
WebElement filesSectionNonAdminView = AdminToolsHomePage.gotoPage().getNonAdminUserView();
assertTrue(filesSectionNonAdminView.getText().contains(
"[Access denied when checking [admin] access to [xwiki:AdminTools.WebHome] for user [xwiki:XWiki."
+ USER_NAME + "]]"));

DashboardConfigurationSectionView configurationSectionView = AdminToolsHomePage.getConfigurationSection();
WebElement configurationSectionNonAdminView = configurationSectionView.getNonAdminUserView();
assertTrue(configurationSectionNonAdminView.getText().contains(
"[Access denied when checking [admin] access to [xwiki:AdminTools.WebHome] for user [xwiki:XWiki."
+ USER_NAME + "]]"));
"Access denied due to missing admin rights!"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>com.xwiki.admintools</groupId>
<artifactId>application-admintools-test</artifactId>
<version>1.0-rc-2-SNAPSHOT</version>
<version>1.0-rc-3-SNAPSHOT</version>
</parent>
<artifactId>application-admintools-test-pageobjects</artifactId>
<name>Admin Tools Application - Tests - Page Objects</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package com.xwiki.admintools.test.po;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.xwiki.test.ui.po.ViewPage;

/**
Expand Down Expand Up @@ -69,5 +70,12 @@ public static boolean isCurrentPage(ViewPage vp)
.equals(ADMIN_TOOLS_SPACE);
}

/**
* Get the view for a user that does not have admin rights.
*/
public WebElement getNonAdminUserView()
{
return this.getDriver().findElement(By.cssSelector(".errormessage"));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,4 @@ public LastNLinesModalView clickViewLastLogsModal()
return new LastNLinesModalView(By.id("configurationViewLastNLinesModal"),
BACKEND_SECTION_VIEW_LAST_LOGS_MODAL_ID);
}

public WebElement getNonAdminUserView()
{
return this.getDriver().findElement(By.cssSelector(".gadget-content .xwikirenderingerror"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,14 @@ public DownloadArchiveModalView clickDownloadModalHyperlink()
*/
public void clickPropertiesHyperlink()
{
filesContent.findElement(By.id("filesProperties")).click();
filesContent.findElement(By.id("xwiki-properties-file")).click();
}

/**
* Navigate and click the link for viewing XWiki configuration file.
*/
public void clickConfigurationHyperlink()
{
filesContent.findElement(By.id("filesConfig")).click();
}

public WebElement getNonAdminUserView()
{
return this.getDriver().findElement(By.cssSelector(".gadget-content .xwikirenderingerror"));
filesContent.findElement(By.id("xwiki-config-file")).click();
}
}
2 changes: 1 addition & 1 deletion application-admintools-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>com.xwiki.admintools</groupId>
<artifactId>application-admintools</artifactId>
<version>1.0-rc-2-SNAPSHOT</version>
<version>1.0-rc-3-SNAPSHOT</version>
</parent>
<artifactId>application-admintools-test</artifactId>
<name>Admin Tools Application - Tests - Parent POM</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@
<syntaxId>xwiki/2.1</syntaxId>
<hidden>true</hidden>
<content>{{velocity output='false'}}
#macro (databaseIsSupported $databaseName $isSupported)
#set ($supportedDatabases = $services.admintools.getSupportedDatabases())
#set ($isSupported = false)
#set($lowercaseDBName = $databaseName.toLowerCase())
#foreach ($database in $supportedDatabases)
#if ($lowercaseDBName.contains($database.toLowerCase()))
#set ($isSupported = true)
#break
#end
#end
#end
#macro (viewLastNLinesMoldal $id)
#set ($modalId = $id + 'ViewLastNLinesModal')
&lt;div class="modal fade" id="${modalId}" tabindex="-1" role="dialog" aria-labelledby="${modalId}Label"&gt;
Expand Down

0 comments on commit eec7de8

Please sign in to comment.