Moved packaging develop into its own directory

This commit is contained in:
Chris Shields
2020-07-21 10:44:26 +01:00
parent 66664d40de
commit cd847f8f80
627 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.alfresco.tas</groupId>
<artifactId>content-repository-community-email-test</artifactId>
<name>content-repository-community-email-test</name>
<version>6.2.2-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.2.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<developers>
<developer>
<name>Paul Brodner</name>
<roles>
<role>Test Automation Architect</role>
</roles>
</developer>
</developers>
<properties>
<suiteXmlFile>${project.basedir}/src/test/resources/email-suite.xml</suiteXmlFile>
</properties>
<dependencies>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>email</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
<argLine>
--illegal-access=warn
</argLine>
</configuration>
</plugin>
<!-- Build only test jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,100 @@
package org.alfresco.email;
import java.lang.reflect.Method;
import org.alfresco.email.dsl.ServerConfiguration;
import org.alfresco.utility.LogFactory;
import org.alfresco.utility.data.*;
import org.alfresco.utility.model.*;
import org.alfresco.utility.network.ServerHealth;
import org.alfresco.utility.network.TenantConsole;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.*;
@ContextConfiguration("classpath:alfresco-email-context.xml")
public abstract class EmailTest extends AbstractTestNGSpringContextTests
{
private static Logger LOG = LogFactory.getLogger();
@Autowired
ServerHealth serverHealth;
@Autowired
protected ImapWrapper imapProtocol;
@Autowired
protected SmtpWrapper smtpProtocol;
@Autowired
public DataUser dataUser;
@Autowired
public DataGroup dataGroup;
@Autowired
public DataSite dataSite;
@Autowired
public DataContent dataContent;
@Autowired
public DataLink dataLink;
@Autowired
public DataCalendarEvent dataCalendarEvent;
@Autowired
public DataWiki dataWiki;
@Autowired
public TenantConsole tenantConsole;
protected UserModel adminUser;
protected UserModel testUser;
protected SiteModel adminSite;
protected SiteModel testSite;
protected FolderModel testFolder;
protected FileModel testFile;
protected ContentModel contentModel;
@BeforeSuite(alwaysRun = true)
public void checkServerHealth() throws Exception
{
super.springTestContextPrepareTestInstance();
serverHealth.assertServerIsOnline();
UserModel anonymousUser = new UserModel("anonymous", DataUser.PASSWORD);
if (!dataUser.isUserInRepo(anonymousUser.getUsername()))
{
dataUser.createUser(anonymousUser);
dataGroup.usingUser(anonymousUser).addUserToGroup(GroupModel.getEmailContributorsGroup());
}
String jmxUseJolokiaAgent = System.getProperty("jmx.useJolokiaAgent");
if ("true".equals(jmxUseJolokiaAgent))
{
imapProtocol.assertThat().protocolIsEnabled();
smtpProtocol.assertThat().protocolIsEnabled();
ServerConfiguration.save(smtpProtocol.withJMX(), smtpProtocol.emailProperties);
}
else
{
LOG.warn("*** Jolokia is not used! To use jolokia, please add next system property when running the tests: jmx.useJolokiaAgent=true ***");
}
}
@BeforeMethod(alwaysRun=true)
public void showStartTestInfo(Method method)
{
LOG.info(String.format("*** STARTING Test: [%s] ***",method.getName()));
}
@AfterMethod(alwaysRun=true)
public void showEndTestInfo(Method method)
{
LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
}
}

View File

@@ -0,0 +1,189 @@
package org.alfresco.email.imap;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.mail.FolderNotFoundException;
import javax.mail.MessagingException;
public class ImapCheckFolderTests extends EmailTest
{
UserModel managerUser;
SiteModel managerTestSite;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
managerUser = dataUser.createRandomTestUser();
managerTestSite = dataSite.usingUser(managerUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Returns the current working directory with admin user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void adminShouldGetCurrentWorkingDirectory() throws Exception
{
testUser = dataUser.getAdminUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).assertThat().existsInRepo()
.then().assertThat().currentDirectoryIs(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify in IMAP client current directory/list of directories for site manager")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldGetCurrentWorkingDirectory() throws Exception
{
testFolder = dataContent.usingUser(managerUser).usingSite(managerTestSite).createFolder();
imapProtocol.authenticateUser(managerUser).usingSite(managerTestSite).usingResource(testFolder).assertThat().existsInRepo()
.then().assertThat().currentDirectoryIs(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Returns the directories list of the root for site manager")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldGetDirectoriesListOfRoot() throws Exception
{
testUser = dataUser.createRandomTestUser();
FolderModel alfrescoImap = FolderModel.getRandomFolderModel();
alfrescoImap.setName("Alfresco IMAP");
FolderModel inbox = FolderModel.getRandomFolderModel();
inbox.setName("INBOX");
imapProtocol.authenticateUser(testUser).usingRoot()
.then().assertThat().contains(alfrescoImap, inbox);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "User finds all its folders for IMAP Sites in Alfresco IMAP > Sites folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void userShouldFindAllIMAPSitesFoldersInAlfrescoIMAPFolder() throws Exception
{
testUser = dataUser.createRandomTestUser();
SiteModel imapSite1 = dataSite.usingUser(testUser).createIMAPSite();
SiteModel imapSite2 = dataSite.usingUser(testUser).createIMAPSite();
imapProtocol.authenticateUser(testUser).usingSites().assertThat().existsInImap()
.then().assertThat().contains(imapSite1, imapSite2);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify in IMAP client current directory/list of directories for COLLABORATOR user - folder created by other user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void collaboratorShouldGetCurrentWorkingDirectory() throws Exception
{
UserModel collaborator = dataUser.createRandomTestUser();
dataUser.usingUser(managerUser).addUserToSite(collaborator, managerTestSite, UserRole.SiteCollaborator);
testFolder = dataContent.usingUser(managerUser).usingSite(managerTestSite).createFolder();
imapProtocol.authenticateUser(collaborator).usingSite(managerTestSite).usingResource(testFolder).assertThat().existsInRepo()
.then().assertThat().currentDirectoryIs(testFolder);
dataSite.usingUser(collaborator).usingSite(managerTestSite).setIMAPFavorite();
FolderModel testFolder1 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
.usingResource(testFolder).createFolder();
FolderModel testFolder2 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
.usingResource(testFolder).createFolder();
imapProtocol.authenticateUser(collaborator).usingSite(managerTestSite)
.usingResource(testFolder)
.then().assertThat().contains(testFolder1,testFolder2);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify in IMAP client current directory/list of directories for CONTRIBUTOR user - folder created by other user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void contributorShouldGetCurrentWorkingDirectory() throws Exception
{
UserModel contributor = dataUser.createRandomTestUser();
dataUser.usingUser(managerUser).addUserToSite(contributor, managerTestSite, UserRole.SiteContributor);
testFolder = dataContent.usingUser(managerUser).usingSite(managerTestSite).createFolder();
imapProtocol.authenticateUser(contributor).usingSite(managerTestSite).usingResource(testFolder).assertThat().existsInRepo()
.then().assertThat().currentDirectoryIs(testFolder);
dataSite.usingUser(contributor).usingSite(managerTestSite).setIMAPFavorite();
FolderModel testFolder1 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
.usingResource(testFolder).createFolder();
FolderModel testFolder2 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
.usingResource(testFolder).createFolder();
imapProtocol.authenticateUser(contributor).usingSite(managerTestSite)
.usingResource(testFolder)
.then().assertThat().contains(testFolder1,testFolder2);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify in IMAP client current directory/list of directories for CONSUMER user - folder created by other user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void consumerShouldGetCurrentWorkingDirectory() throws Exception
{
UserModel consumer = dataUser.createRandomTestUser();
dataUser.usingUser(managerUser).addUserToSite(consumer, managerTestSite, UserRole.SiteConsumer);
testFolder = dataContent.usingUser(managerUser).usingSite(managerTestSite).createFolder();
imapProtocol.authenticateUser(consumer).usingSite(managerTestSite).usingResource(testFolder).assertThat().existsInRepo()
.then().assertThat().currentDirectoryIs(testFolder);
dataSite.usingUser(consumer).usingSite(managerTestSite).setIMAPFavorite();
FolderModel testFolder1 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
.usingResource(testFolder).createFolder();
FolderModel testFolder2 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
.usingResource(testFolder).createFolder();
imapProtocol.authenticateUser(consumer).usingSite(managerTestSite)
.usingResource(testFolder)
.then().assertThat().contains(testFolder1,testFolder2);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify unauthorized is not able to access document library section ( PUBLIC imap SITE)")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
public void unAuthorizedUserCannotAccessPublicImapSiteDocumentLibrary() throws Exception
{
testUser = dataUser.createRandomTestUser();
UserModel unauthorizedUser = dataUser.createRandomTestUser();
SiteModel publicImapSite = dataSite.usingUser(testUser).createPublicRandomSite();
dataSite.usingUser(unauthorizedUser).usingSite(publicImapSite).setIMAPFavorite();
imapProtocol.authenticateUser(unauthorizedUser).usingSite(publicImapSite).assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify unauthorized is not able to access document library section ( Moderated imap SITE)")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
public void unAuthorizedUserCannotAccessModeratedImapSiteDocumentLibrary() throws Exception
{
testUser = dataUser.createRandomTestUser();
UserModel unauthorizedUser = dataUser.createRandomTestUser();
SiteModel moderatedImapSite = dataSite.usingUser(testUser).createModeratedRandomSite();
dataSite.usingUser(unauthorizedUser).usingSite(moderatedImapSite).setIMAPFavorite();
imapProtocol.authenticateUser(unauthorizedUser).usingSite(moderatedImapSite).assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify unauthorized is not able to access document library section ( Private imap SITE)")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = MessagingException.class,
expectedExceptionsMessageRegExp = ".*Access Denied.*You do not have the appropriate permissions to perform this operation.*")
public void unAuthorizedUserCannotAccessPrivateImapSiteDocumentLibrary() throws Exception
{
testUser = dataUser.createRandomTestUser();
UserModel unauthorizedUser = dataUser.createRandomTestUser();
SiteModel privateImapSite = dataSite.usingUser(testUser).createPrivateRandomSite();
dataSite.usingUser(unauthorizedUser).usingSite(privateImapSite).setIMAPFavorite();
imapProtocol.authenticateUser(unauthorizedUser).usingSite(privateImapSite).assertThat().doesNotContain(testFolder);
}
}

View File

@@ -0,0 +1,79 @@
package org.alfresco.email.imap;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.exception.TestConfigurationException;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Tests for Connection to Imap
*
* @author Cristina Axinte
*
*/
public class ImapConnectionTests extends EmailTest
{
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify user can connect successfully to IMAP")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void correctUserConnectsToIMAPSuccessfully() throws Exception
{
imapProtocol.authenticateUser(testUser).then().assertThat().userIsConnected();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify user fails to connect to IMAP on different port")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY }, expectedExceptions = TestConfigurationException.class)
public void userFailsConnectToIMAPOnDifferentPort() throws Exception
{
imapProtocol.authenticateUser(testUser, 43).then().assertThat().userIsNotConnected();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify user can disconnect successfully from IMAP Server")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void userDisconnectsFromImapServerSuccessfully() throws Exception
{
imapProtocol.authenticateUser(testUser)
.disconnect().then().assertThat().userIsNotConnected();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user fails to connect to IMAP on different host")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = TestConfigurationException.class)
public void userFailsConnectToIMAPOnDifferentHost() throws Exception
{
imapProtocol.authenticateUser(testUser, "172.29.101.1256").then().assertThat().userIsNotConnected();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify existing user with wrong password fails to connect to IMAP")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = TestConfigurationException.class,
expectedExceptionsMessageRegExp =".*You missed some configuration settings in your tests: User failed to connect to IMAP server LOGIN failed. Invalid login/password$" )
public void userFailsConnectToIMAPWithWrongPassword() throws Exception
{
testUser = dataUser.createRandomTestUser();
testUser.setPassword("invalid");
imapProtocol.authenticateUser(testUser);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify a non existing user fails to connect to IMAP.")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = TestConfigurationException.class,
expectedExceptionsMessageRegExp =".*You missed some configuration settings in your tests: User failed to connect to IMAP server LOGIN failed. Invalid login/password")
public void nonExistentUserFailsConnectToIMAP() throws Exception
{
imapProtocol.authenticateUser(new UserModel("nonExistingUser", "pass"));
}
}

View File

@@ -0,0 +1,124 @@
package org.alfresco.email.imap;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.Utility;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.mail.FolderNotFoundException;
import javax.mail.MessagingException;
public class ImapCopyFolderTests extends EmailTest
{
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
testUser = dataUser.createRandomTestUser();
adminSite = dataSite.usingAdmin().createIMAPSite();
testSite = dataSite.usingUser(testUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify copy non-empty folder to a different location by admin user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void adminShouldCopyNonEmptyFolder() throws Exception
{
testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
FolderModel copyFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
FolderModel copiedFolder = testFolder;
copiedFolder.setProtocolLocation(Utility.buildPath(copyFolder.getProtocolLocation(), testFolder.getName()));
dataContent.usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(adminUser).usingSite(adminSite).usingResource(testFolder)
.copyTo(copyFolder).then().usingResource(copiedFolder).assertThat().countMessagesIs(1);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify copy folder with Manager")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldCopyFolder() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel copyFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel copiedFolder = testFolder;
copiedFolder.setCmisLocation(Utility.buildPath(copyFolder.getCmisLocation(), testFolder.getName()));
copiedFolder.setProtocolLocation(Utility.buildPath(copyFolder.getProtocolLocation(), testFolder.getName()));
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
.copyTo(copyFolder).then().usingResource(copiedFolder).assertThat().existsInRepo().assertThat().existsInImap();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify copy folder that has been deleted with Manager")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
public void siteManagerShouldNotCopyFolderThatHasBeenDeleted() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel folderModel = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder).createFolder();
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(folderModel).delete()
.and().assertThat().doesNotExistInRepo().assertThat().doesNotContain(folderModel)
.then().copyTo(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify copy folder with Contributor user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void contributorShouldCopyFolder() throws Exception
{
UserModel contributorUser = dataUser.createRandomTestUser();
dataUser.addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel copyFolder = dataContent.usingUser(contributorUser).usingSite(testSite).createFolder();
FolderModel copiedFolder = testFolder;
copiedFolder.setProtocolLocation(Utility.buildPath(copyFolder.getProtocolLocation(), testFolder.getName()));
dataContent.usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(contributorUser).usingSite(testSite).usingResource(testFolder)
.copyTo(copyFolder).then().usingResource(copiedFolder).assertThat().countMessagesIs(1);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify copy folder with Collaborator user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void collaboratorShouldCopyFolder() throws Exception
{
UserModel collaboratorUser = dataUser.createRandomTestUser();
dataUser.addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel copyFolder = dataContent.usingUser(collaboratorUser).usingSite(testSite).createFolder();
FolderModel copiedFolder = testFolder;
copiedFolder.setProtocolLocation(Utility.buildPath(copyFolder.getProtocolLocation(), testFolder.getName()));
dataContent.usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(collaboratorUser).usingSite(testSite).usingResource(testFolder)
.copyTo(copyFolder).then().usingResource(copiedFolder).assertThat().countMessagesIs(1);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that copy folder with Consumer user is not possible")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
public void consumerShouldNotCopyFolder() throws Exception
{
UserModel consumerUser = dataUser.createRandomTestUser();
dataUser.addUserToSite(consumerUser, testSite, UserRole.SiteConsumer);
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel copyFolder = new FolderModel("copyFolder");
imapProtocol.authenticateUser(consumerUser).usingSite(testSite).createFolder(copyFolder).usingResource(testFolder)
.copyTo(copyFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify copy folder to a location for which the user does not have permission")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class)
public void userCopyFolderToALocationThatHeDoesNotHaveAccess() throws Exception
{
SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite();
testFolder = dataContent.usingAdmin().usingSite(testSite).createFolder();
FolderModel copyFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
dataContent.usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingResource(testFolder)
.copyTo(copyFolder);
}
}

View File

@@ -0,0 +1,111 @@
package org.alfresco.email.imap;
import javax.mail.MessagingException;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.SkipException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class ImapCopyMessagesTests extends EmailTest
{
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify site manager can copy non-empty file via IMAP client to a different location")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldCopyNonEmptyFile() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FileModel fileModel = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.then().copyMessageTo(testFolder).assertThat().containsMessages(fileModel);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify site manager can copy non-empty files via IMAP client to a different location")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldCopyNonEmptyFiles() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FileModel fileModel1 = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
FileModel fileModel2 = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel1).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.then().usingSite(testSite).copyMessagesTo(testFolder).assertThat().containsMessages(fileModel1, fileModel2);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can copy empty file via IMAP client to a different location")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerShouldCopyEmptyFile() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FileModel fileModel = new FileModel("EmptyFile.txt", FileType.TEXT_PLAIN, "");
fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(fileModel);
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.then().copyMessageTo(testFolder).assertThat().containsMessages(fileModel);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user can copy file via IMAP client to a location where the message already exists")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void userShouldCopyFileWhereAlreadyExists() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FileModel fileModel = new FileModel("CopyFile.txt", FileType.TEXT_PLAIN, "content of copied file");
dataContent.usingSite(testSite).usingResource(testFolder).createContent(fileModel);
FileModel fileToBeCopied = dataContent.usingSite(testSite).createContent(fileModel);
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileToBeCopied).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.then().copyMessageTo(testFolder).assertThat().containsMessages(fileToBeCopied);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user cannot copy a file via IMAP client if it was already deleted from repository")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class,
expectedExceptionsMessageRegExp ="There are no messages to be copied")
public void userCannotCopyDeletedFile() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FileModel fileModel = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel).assertThat().existsInImap();
dataContent.usingResource(fileModel).deleteContent();
imapProtocol.copyMessageTo(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user cannot copy file via IMAP client to a location where you don't have permissions")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class,
expectedExceptionsMessageRegExp = ".*NO APPEND failed. Can't append message - Permission denied.*")
public void userCannotCopyFileWhereNoPermissions() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
UserModel user = dataUser.createRandomTestUser();
SiteModel site = dataSite.usingUser(user).createIMAPSite();
FileModel file = dataContent.usingUser(user).usingSite(site).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
dataSite.usingUser(user).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(user).usingSite(site).usingResource(file).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.then().copyMessageTo(testFolder);
}
}

View File

@@ -0,0 +1,217 @@
package org.alfresco.email.imap;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.mail.FolderNotFoundException;
/**
* Tests for Create Folder action using IMAP client
*
* @author Cristina Axinte
*
*/
public class ImapCreateFolderTests extends EmailTest
{
private UserModel adminUser;
private SiteModel imapSite;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
testUser = dataUser.createRandomTestUser();
imapSite = dataSite.usingUser(testUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify admin can create a folder in Afresco IMAP root folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void adminCanCreateFolderInAlfrescoImapRoot() throws Exception
{
FolderModel folderToCreate = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(adminUser).usingAlfrescoImap().createFolder(folderToCreate)
.assertThat().existsInImap()
.assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify user can create a folder in Afresco IMAP root folder, but it is not displayed in Alfresco Repository")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void userCanCreateFolderInAlfrescoImapRootButNotDisplayedInRepo() throws Exception
{
FolderModel folderToCreate = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingAlfrescoImap().createFolder(folderToCreate)
.assertThat().existsInImap()
.assertThat().doesNotExistInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify admin can create a folder in Sites folder and it will be displayed in Alfresco Repository/Sites")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void adminCanCreateFolderInSitesFolder() throws Exception
{
FolderModel folderToCreate = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(adminUser)
.usingSites().createFolder(folderToCreate)
.assertThat().existsInImap()
.assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify manager can create a folder in IMAP Site > documentLibrary")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void managerCanCreateFolderInIMAPSite() throws Exception
{
UserModel managerUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(managerUser, imapSite, UserRole.SiteManager);
FolderModel folderToCreate = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(managerUser)
.usingSite(imapSite).createFolder(folderToCreate)
.assertThat().existsInImap()
.assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify manager can create a folder with spaces in name in IMAP Site > documentLibrary")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void managerCanCreateFolderWithSpacesInIMAPSite() throws Exception
{
UserModel managerUser = dataUser.createRandomTestUser();
imapSite = dataSite.usingUser(managerUser).createIMAPSite();
FolderModel folderToCreate = new FolderModel("Folder with spaces in name");
imapProtocol.authenticateUser(managerUser)
.usingSite(imapSite).createFolder(folderToCreate)
.assertThat().existsInImap()
.assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify collaborator can create a folder in IMAP Site > documentLibrary")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void collaboratorCanCreateFolderInImapSite() throws Exception
{
UserModel collaboratorUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(collaboratorUser, imapSite, UserRole.SiteCollaborator);
FolderModel folderToCreate = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(collaboratorUser)
.usingSite(imapSite).createFolder(folderToCreate)
.assertThat().existsInImap()
.assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify contributor can create a folder in IMAP Site > documentLibrary")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void contributorCanCreateFolderInImapSite() throws Exception
{
UserModel contributorUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(contributorUser, imapSite, UserRole.SiteCollaborator);
FolderModel folderToCreate = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(contributorUser)
.usingSite(imapSite).createFolder(folderToCreate)
.assertThat().existsInImap()
.assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify consumer cannot create a folder in IMAP Site > documentLibrary")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void consumerCannotCreateFolderInImapSite() throws Exception
{
UserModel consumerUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(consumerUser, imapSite, UserRole.SiteConsumer);
dataSite.usingUser(consumerUser).usingSite(imapSite).setIMAPFavorite();
FolderModel folderToCreate = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(consumerUser).usingSite(imapSite).createFolder(folderToCreate)
.and()
.assertThat().doesNotExistInRepo()
.then().usingSite(imapSite)
.assertThat().doesNotContain(folderToCreate);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user can create folder successfully with name that contains special characters")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void userCanCreateFolderWithSpecialCharacters() throws Exception
{
testSite = dataSite.usingUser(testUser).createIMAPSite();
FolderModel folderToCreate = new FolderModel("(a)[b]!#%^");
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(folderToCreate)
.then()
.assertThat().existsInImap()
.assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user can create folder successfully with name that contains symbols")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void userCanCreateFolderWithSymbols() throws Exception
{
testSite = dataSite.usingUser(testUser).createIMAPSite();
FolderModel folderToCreate = new FolderModel("a£¥€$♊♎ ♏ ♐ ♑ ♒ ♓");
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(folderToCreate)
.then()
.assertThat().existsInImap()
.assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user cannot create folder with name omegaΩ_<>./?")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void userCannotCreateFolderWithNameThatContainsRestrictedCharacters() throws Exception
{
testSite = dataSite.usingUser(testUser).createIMAPSite();
FolderModel folderToCreate = new FolderModel("omegaΩ_<>./?");
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(folderToCreate)
.and()
.assertThat().doesNotExistInRepo()
.then().usingSite(testSite)
.assertThat().doesNotContain(folderToCreate);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify create folder using an user and check folder can be view by another user with access to the same location/site")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void verifyUserCanViewTheFolderCreatedByAnotherUser() throws Exception
{
testSite = dataSite.usingUser(testUser).createIMAPSite();
UserModel collaboratorUser = dataUser.createRandomTestUser();
dataUser.addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
FolderModel folderToCreate = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(collaboratorUser).usingSite(testSite).createFolder(folderToCreate).disconnect();
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(folderToCreate)
.assertThat().existsInImap()
.assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify error is returned for unauthenticated user on creating folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = IllegalStateException.class,
expectedExceptionsMessageRegExp = "Not connected")
public void verifyErrorIsReturnedForUnauthenticatedUserTryingToCreateFolder() throws Exception
{
imapProtocol.authenticateUser(testUser).usingSite(imapSite).disconnect().then().createFolder(FolderModel.getRandomFolderModel());
}
}

View File

@@ -0,0 +1,259 @@
package org.alfresco.email.imap;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.*;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.mail.FolderNotFoundException;
public class ImapDeleteFolderTests extends EmailTest
{
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
testUser = dataUser.createRandomTestUser();
adminSite = dataSite.usingAdmin().createIMAPSite();
testSite = dataSite.usingUser(testUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify admin can delete folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void adminShouldDeleteFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(adminUser).usingSite(adminSite).createFolder(testFolder)
.assertThat().existsInRepo()
.assertThat().existsInImap()
.delete()
.assertThat().doesNotExistInRepo()
.usingSite(adminSite).assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify site Manager can delete a folder with a message(file)")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldDeleteNonEmptyFolder() throws Exception
{
UserModel user = dataUser.createRandomTestUser();
SiteModel site = dataSite.usingUser(user).createIMAPSite();
FolderModel folder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(user).usingSite(site).createFolder(folder)
.assertThat().existsInImap()
.assertThat().existsInRepo();
dataContent.usingUser(user).usingSite(site).usingResource(folder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.usingSite(site).usingResource(folder).assertThat().countMessagesIs(1)
.delete()
.assertThat().doesNotExistInRepo()
.usingSite(site).assertThat().doesNotContain(folder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager can delete a empty folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerShouldDeleteFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInRepo()
.assertThat().existsInImap()
.delete()
.assertThat().doesNotExistInRepo()
.usingSite(testSite).assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager can delete a folder that contains collaborator user messages")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, enabled = false)//disable since it's failing intermitent
public void siteManagerShouldDeleteFolderWithCollaboratorMessages() throws Exception
{
UserModel collaboratorUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInImap()
.assertThat().existsInRepo();
testFile = dataContent.usingUser(collaboratorUser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.usingSite(testSite).usingResource(testFolder)
.assertThat().countMessagesIs(1)
.delete()
.assertThat().doesNotExistInRepo()
.usingSite(testSite).assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager can delete a folder that contains contributor user messages")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, enabled = false)//disable since it's failing intermitent
public void siteManagerShouldDeleteFolderWithContributorMessages() throws Exception
{
UserModel contributorUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInImap()
.assertThat().existsInRepo();
dataContent.usingUser(contributorUser).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.usingSite(testSite).usingResource(testFolder).assertThat().countMessagesIs(1)
.delete()
.assertThat().doesNotExistInRepo()
.usingSite(testSite).assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that an unauthorized user can not delete folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
public void unauthorizedUserShouldNotDeleteFolder() throws Exception
{
UserModel unauthorizedUser = dataUser.createRandomTestUser();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
imapProtocol.authenticateUser(unauthorizedUser).usingResource(testFolder).delete();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager can delete a folder that contains consumer user messages")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void siteManagerShouldDeleteFolderWithConsumerMessages() throws Exception
{
UserModel consumerUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(consumerUser, testSite, UserRole.SiteContributor);
testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInImap()
.assertThat().existsInRepo();
dataContent.usingUser(consumerUser).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
dataUser.usingUser(testUser).removeUserFromSite(consumerUser, testSite);
dataUser.usingUser(testUser).addUserToSite(consumerUser, testSite, UserRole.SiteConsumer);
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).assertThat().countMessagesIs(1)
.delete()
.assertThat().doesNotExistInRepo()
.usingSite(testSite).assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user cannot delete folder that no longer exists")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
public void userCannotDeleteFolderThatNoLongerExists() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInImap()
.assertThat().existsInRepo()
.delete()
.assertThat().doesNotExistInRepo()
.usingSite(testSite).assertThat().doesNotContain(testFolder)
.usingResource(testFolder)
.delete();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify deleting folder that contains messages by COLLABORATOR user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void collaboratorTriesToDeleteFolderContainingMessagesByCollaborator() throws Exception
{
UserModel collaboratorUser1 = dataUser.createRandomTestUser();
UserModel collaboratorUser2 = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(collaboratorUser1, testSite, UserRole.SiteCollaborator);
dataUser.usingUser(testUser).addUserToSite(collaboratorUser2, testSite, UserRole.SiteCollaborator);
testFolder = FolderModel.getRandomFolderModel();
dataSite.usingUser(collaboratorUser1).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(collaboratorUser1).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInImap()
.assertThat().existsInRepo()
.disconnect();
testFile = dataContent.usingUser(collaboratorUser1).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
dataSite.usingUser(collaboratorUser2).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(collaboratorUser2).usingSite(testSite).usingResource(testFolder)
.delete()
.assertThat().existsInRepo()
.usingSite(testSite).assertThat().contains(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify deleting folder that contains messages by CONTRIBUTOR user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void contributorTriesToDeleteFolderContainingMessagesByContributor() throws Exception
{
UserModel contributorUser1 = dataUser.createRandomTestUser();
UserModel contributorUser2 = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(contributorUser1, testSite, UserRole.SiteContributor);
dataUser.usingUser(testUser).addUserToSite(contributorUser2, testSite, UserRole.SiteContributor);
testFolder = FolderModel.getRandomFolderModel();
dataSite.usingUser(contributorUser1).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(contributorUser1).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInImap()
.assertThat().existsInRepo()
.disconnect();
testFile = dataContent.usingUser(contributorUser1).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
dataSite.usingUser(contributorUser2).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(contributorUser2).usingSite(testSite).usingResource(testFolder)
.delete()
.assertThat().existsInRepo()
.usingSite(testSite).assertThat().contains(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify deleting folder that contains messages by CONSUMER user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void consumerTriesToDeleteFolderContainingMessagesByConsumer() throws Exception
{
UserModel consumerUser1 = dataUser.createRandomTestUser();
UserModel consumerUser2 = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(consumerUser1, testSite, UserRole.SiteCollaborator);
dataUser.usingUser(testUser).addUserToSite(consumerUser2, testSite, UserRole.SiteConsumer);
testFolder = FolderModel.getRandomFolderModel();
dataSite.usingUser(consumerUser1).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(consumerUser1).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInImap()
.assertThat().existsInRepo()
.disconnect();
testFile = dataContent.usingUser(consumerUser1).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
dataUser.usingUser(testUser).removeUserFromSite(consumerUser1, testSite);
dataUser.usingUser(testUser).addUserToSite(consumerUser1, testSite, UserRole.SiteConsumer);
dataSite.usingUser(consumerUser2).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(consumerUser2).usingSite(testSite).usingResource(testFolder)
.delete()
.assertThat().existsInRepo()
.usingSite(testSite).assertThat().contains(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify delete folder from a location where you don't have permission")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
public void userTriesToDeleteFolderFromALocationToWhichHeDoesNotHavePermissionToDelete() throws Exception
{
UserModel userModel = dataUser.createRandomTestUser();
SiteModel privateSite = dataSite.usingAdmin().createIMAPSite();
testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite).createFolder(testFolder)
.assertThat().existsInImap()
.assertThat().existsInRepo()
.disconnect();
dataSite.usingUser(userModel).usingSite(privateSite).setIMAPFavorite();
imapProtocol.authenticateUser(userModel).usingSite(testSite).usingResource(testFolder).delete();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify admin cannot delete a open folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = IllegalStateException.class,
expectedExceptionsMessageRegExp = "This operation is not allowed on an open folder")
public void adminTriesToDeleteOpenFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(adminUser).usingSite(adminSite).createFolder(testFolder)
.assertThat().existsInRepo()
.assertThat().existsInImap()
.attemptToDeleteOpenFolder();
}
}

View File

@@ -0,0 +1,95 @@
package org.alfresco.email.imap;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.mail.MessagingException;
public class ImapDeleteMessagesTests extends EmailTest
{
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
adminSite = dataSite.usingAdmin().createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify message can be deleted from IMAP client by admin")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void adminShouldDeleteMessage() throws Exception
{
testFile = dataContent.usingAdmin().usingSite(adminSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(dataUser.getAdminUser()).usingSite(adminSite).assertThat().containsMessages(testFile)
.and().usingResource(testFile).assertThat().existsInRepo().deleteMessage()
.and().assertThat().doesNotContainMessages(testFile)
.then().usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify deleting message via IMAP client by user with MANAGER role")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldDeleteMessage() throws Exception
{
testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingResource(testFile).assertThat().existsInRepo()
.and().usingSite(testSite).assertThat().containsMessages(testFile).deleteMessage(testFile.getName())
.and().assertThat().doesNotContainMessages(testFile);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify message has been deleted via REPOSITORU by user with MANAGER role")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerVerifyMessageHasBeenDeletedFromRepository() throws Exception
{
testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
dataContent.usingUser(testUser).usingResource(testFile).deleteContent();
imapProtocol.authenticateUser(testUser).usingResource(testFile).assertThat().doesNotExistInRepo()
.and().usingSite(testSite).assertThat().doesNotContainMessages(testFile);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify deleting message via IMAP client by user with CONTRIBUTOR role")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteContributorShouldDeleteMessage() throws Exception
{
UserModel contributorUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
testFile = dataContent.usingUser(contributorUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(contributorUser).usingResource(testFile).deleteMessage()
.usingResource(testFile).assertThat().doesNotExistInRepo()
.and().usingSite(testSite).assertThat().doesNotContainMessages(testFile);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify deleting message via IMAP client by user with COLLABORATOR role")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteCollaboratorShouldDeleteMessage() throws Exception
{
UserModel collaboratorUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
testFile = dataContent.usingUser(collaboratorUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(collaboratorUser).usingResource(testFile).deleteMessage()
.usingResource(testFile).assertThat().doesNotExistInRepo()
.and().usingSite(testSite).assertThat().doesNotContainMessages(testFile);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify deleting message via IMAP client by user with CONSUMER role is not permitted")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class,
expectedExceptionsMessageRegExp = ".*No permission to set DELETED flag")
public void siteConsumerShouldNotDeleteMessage() throws Exception
{
UserModel consumerUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(consumerUser, testSite, UserRole.SiteConsumer);
testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(consumerUser).usingResource(testFile).deleteMessage();
}
}

View File

@@ -0,0 +1,58 @@
package org.alfresco.email.imap;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.Test;
import javax.mail.Flags;
public class ImapMessageFlagsTests extends EmailTest
{
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify site manager can set flags action to a content(message) through IMAP Client")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldSetFlagsToAContent() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingResource(fileModel).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.and().withMessage().setAnsweredFlag().setSeenFlag().updateFlags()
.then().assertThat().messageContainsFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can set flags to a content(message) through IMAP Client")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerShouldSetFlagsToContent() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingResource(fileModel).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.and().withMessage().setFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN).updateFlags()
.then().assertThat().messageContainsFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can remove flags from a content(message) through IMAP Client")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerShouldRemoveFlagsFromContent() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingResource(fileModel).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.and().withMessage().setFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN).updateFlags()
.and().assertThat().messageContainsFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN)
.and().withMessage().removeFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN).updateFlags()
.then().assertThat().messageDoesNotContainFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN);
}
}

View File

@@ -0,0 +1,146 @@
package org.alfresco.email.imap;
import javax.mail.FolderNotFoundException;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class ImapMoveFolderTests extends EmailTest
{
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
testUser = dataUser.createRandomTestUser();
adminSite = dataSite.usingAdmin().createIMAPSite();
testSite = dataSite.usingUser(testUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify move non-empty folder to a different location by admin user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void adminShouldMoveNonEmptyFolder() throws Exception
{
testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
FolderModel moveToFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
dataContent.usingAdmin().usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(adminUser).usingSite(adminSite).usingResource(testFolder).moveTo(moveToFolder)
.and().usingResource(testFolder).assertThat().doesNotExistInRepo()
.then().usingResource(moveToFolder).assertThat().contains(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify move folder with Manager")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldMoveFolder() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
.and().usingResource(testFolder).assertThat().doesNotExistInRepo()
.then().usingResource(moveToFolder).assertThat().contains(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify move folder at location where the folder already exists is successful")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void userShouldMoveFolderWhereAlreadyExists() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
dataContent.usingUser(testUser).usingSite(testSite)
.usingResource(moveToFolder)
.createFolder(testFolder);
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
.and().usingResource(testFolder).assertThat().doesNotExistInRepo()
.then().usingResource(moveToFolder).assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify move folder with Contributor will create the new folder, but is NOT able to delete the current one")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteContributorCannotMoveFolder() throws Exception
{
UserModel siteContributor = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(siteContributor, testSite, UserRole.SiteContributor);
dataSite.usingUser(siteContributor).usingSite(testSite).setIMAPFavorite();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
imapProtocol.authenticateUser(siteContributor).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
.usingResource(moveToFolder).assertThat().contains(testFolder)
.and().usingResource(testFolder).assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify move folder with Collaborator will create the new folder, but is NOT able to delete the current one")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteCollaboratorCannotMoveFolder() throws Exception
{
UserModel siteCollaborator = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(siteCollaborator, testSite, UserRole.SiteContributor);
dataSite.usingUser(siteCollaborator).usingSite(testSite).setIMAPFavorite();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
imapProtocol.authenticateUser(siteCollaborator).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
.usingResource(moveToFolder).assertThat().contains(testFolder)
.and().usingResource(testFolder).assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify move folder with Consumer will create the new folder, but is NOT able to delete the current one")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteConsumerCannotMoveFolder() throws Exception
{
UserModel siteConsumer = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(siteConsumer, testSite, UserRole.SiteContributor);
dataSite.usingUser(siteConsumer).usingSite(testSite).setIMAPFavorite();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
imapProtocol.authenticateUser(siteConsumer).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
.usingResource(moveToFolder).assertThat().contains(testFolder)
.and().usingResource(testFolder).assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify move folder fails using user that doesn't have permission to the IMAP site")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
public void unauthorizedUserCannotMoveFolder() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
UserModel unauthorizedUser = dataUser.createRandomTestUser();
dataSite.usingUser(unauthorizedUser).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(unauthorizedUser).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
.usingResource(moveToFolder).assertThat().doesNotContain(testFolder)
.and().usingResource(testFolder).assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify move folder with Manager")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
public void siteManagerShouldNotMoveDeletedFolder() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
.assertThat().existsInImap()
.assertThat().existsInRepo()
.delete()
.moveTo(moveToFolder);
}
}

View File

@@ -0,0 +1,27 @@
package org.alfresco.email.imap;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.Test;
public class ImapMoveMessagesTests extends EmailTest
{
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify site manager can move message via IMAP client to a different location")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldMoveNonEmptyFile() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FileModel fileModel = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.then().moveMessageTo(testFolder).assertThat().containsMessages(fileModel)
.and().usingSite(testSite).assertThat().doesNotContainMessages(fileModel);
}
}

View File

@@ -0,0 +1,180 @@
package org.alfresco.email.imap;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.mail.Flags;
import javax.mail.MessagingException;
import java.io.IOException;
public class ImapReadMessagesTests extends EmailTest
{
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
adminUser = dataUser.getAdminUser();
adminSite = dataSite.usingAdmin().createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify folders created in repository in other folder via IMAP client by admin user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void adminShouldGetFoldersCreatedInRepositoryViaImap() throws Exception
{
testFolder = dataContent.usingAdmin().usingSite(testSite).createFolder();
FolderModel testFolder1 = FolderModel.getRandomFolderModel();
FolderModel testFolder2 = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(adminUser).usingSite(adminSite).usingResource(testFolder).createFolder(testFolder1)
.and().assertThat().existsInRepo()
.and().assertThat().existsInImap()
.then().usingResource(testFolder).createFolder(testFolder2).assertThat().existsInRepo()
.and().assertThat().existsInImap();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify file and its content are displayed via IMAP client when the file is created by site manager")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldGetFileAndItsContentsViaImap() throws Exception
{
FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().containsMessages(fileModel)
.and().usingResource(fileModel).assertThat().existsInRepo()
.then().assertThat().fileContentIsDisplayed();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify that file content in IMAP client contains creator, title, description, created date, " +
"modifier, modified date, size, three links to content folder, to content url, to download url")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldVerifyFileContent() throws Exception
{
FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().containsMessages(fileModel)
.and().usingResource(fileModel).assertThat().existsInRepo()
.then().assertThat().messageContentMatchesFileModelData(fileModel);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that the admin user can mark a message as read")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void adminCanMarkMessageAsRead() throws Exception
{
testFile = dataContent.usingUser(adminUser).usingSite(adminSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
imapProtocol.authenticateUser(adminUser).usingResource(testFile).withMessage().setSeenFlag().updateFlags()
.then().assertThat().messageContainsFlags(Flags.Flag.SEEN);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager can see wiki pages via IMAP")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerCanViewWikiPages() throws Exception
{
dataWiki.usingUser(testUser).usingSite(testSite).createRandomWiki();
imapProtocol.authenticateUser(testUser).usingSiteWikiContainer(testSite).assertThat().countMessagesIs(1);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that collaborator can see files created by self")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void collaboratorCanViewFileCreatedBySelf() throws Exception
{
UserModel collaboratorUser = dataUser.createRandomTestUser();
dataUser.addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
testFile = dataContent.usingUser(collaboratorUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
imapProtocol.authenticateUser(collaboratorUser).usingSite(testSite).assertThat().containsMessages(testFile);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that contributor can see files created by self")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void contributorCanViewFileCreatedBySelf() throws Exception
{
UserModel contributorUser = dataUser.createRandomTestUser();
dataUser.addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
testFile = dataContent.usingUser(contributorUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
imapProtocol.authenticateUser(contributorUser).usingSite(testSite).assertThat().containsMessages(testFile);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify file created with spaces in the name is displayed in IMAP client")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void fileWithSpacesInNameIsDisplayedInImap() throws Exception
{
testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(new FileModel("name with spaces.txt", FileType.TEXT_PLAIN));
imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().containsMessages(testFile);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that a file created with name which contains special characters is visible in IMAP")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void userCanViewFileWithSpecialCharactersInNameViaIMAP() throws Exception
{
testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(new FileModel("(a)[b]!#%^.txt", FileType.TEXT_PLAIN));
imapProtocol.authenticateUser(testUser)
.usingSite(testSite).assertThat().containsMessages(testFile)
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that a file created with name which contains symbols is visible in IMAP")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void userCanViewFileWithSymbolsInNameViaIMAP() throws Exception
{
testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(new FileModel("a£¥€$♊♎♏♐♑♒♓Ω.txt", FileType.TEXT_PLAIN));
imapProtocol.authenticateUser(testUser)
.usingSite(testSite).assertThat().containsMessages(testFile)
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager can see links via IMAP")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void siteManagerCanViewLinks() throws Exception
{
dataLink.usingUser(testUser).usingSite(testSite).createRandomLink();
imapProtocol.authenticateUser(testUser).usingSiteLinksContainer(testSite).assertThat().countMessagesIs(1);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager can see calendar events via IMAP")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void siteManagerCanViewCalendarEvents() throws Exception
{
dataCalendarEvent.usingUser(testUser).usingSite(testSite).createRandomCalendarEvent();
imapProtocol.authenticateUser(testUser).usingSiteCalendarContainer(testSite).assertThat().countMessagesIs(1);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager cannot read file via IMAP if it is already deleted from repository")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = MessagingException.class,
expectedExceptionsMessageRegExp = "No message with subject .* has been found")
public void siteManagerCannotReadFileInImapIfItWasDeletedFromRepository() throws Exception
{
testFile = dataContent.usingUser(testUser).usingSite(testSite)
.createContent(new FileModel(RandomData.getRandomName("File"), FileType.TEXT_PLAIN));
dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFile).deleteContent();
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).assertThat().fileContentIsDisplayed();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager cannot read file via IMAP client if it is locked by an user in repository")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = IOException.class,
expectedExceptionsMessageRegExp = "No content")
public void siteManagerCannotReadFileInImapIfItsLocked() throws Exception
{
String content = RandomData.getRandomAlphanumeric();
testFile = dataContent.usingUser(testUser).usingSite(testSite)
.createContent(new FileModel(RandomData.getRandomName("File"), FileType.TEXT_PLAIN, content));
dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFile).checkOutDocument();
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).assertThat().fileContentIsDisplayed();
}
}

View File

@@ -0,0 +1,361 @@
package org.alfresco.email.imap;
import javax.mail.FolderNotFoundException;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.exception.TestConfigurationException;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.commons.lang3.RandomStringUtils;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class ImapRenameFolderTests extends EmailTest
{
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
testUser = dataUser.createRandomTestUser();
adminSite = dataSite.usingAdmin().createIMAPSite();
testSite = dataSite.usingUser(testUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify rename folder by admin user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void adminShouldRenameFolder() throws Exception
{
testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(adminUser).usingSite(adminSite).usingResource(testFolder).rename(newFolderName)
.usingSite(adminSite)
.assertThat().contains(new FolderModel(newFolderName))
.assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify renaming folder by user with MANAGER role")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldRenameFolder() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).rename(newFolderName)
.usingSite(testSite)
.assertThat().contains(new FolderModel(newFolderName))
.assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user with MANAGER role is not able to rename an nonexistent folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
public void siteManagerShouldNotRenameNonExistentFolder() throws Exception
{
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(FolderModel.getRandomFolderModel())
.rename(newFolderName)
.assertThat().contains(testFolder)
.and().assertThat().doesNotContain(new FolderModel(newFolderName));
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user with MANAGER role is able to rename a folder with long name")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerShouldRenameFolderWithLongName() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
String longName = RandomStringUtils.randomAlphabetic(200);
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
.rename(longName)
.usingSite(testSite)
.assertThat().contains(new FolderModel(longName))
.assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify unauthorized user is not able to rename a folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
public void unauthorizedUserShouldNotRenameFolder() throws Exception
{
UserModel unauthorizedUser = dataUser.createRandomTestUser();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
dataSite.usingUser(unauthorizedUser).usingSite(testSite).setIMAPFavorite();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(unauthorizedUser).usingResource(testFolder)
.rename(newFolderName)
.then().assertThat().doesNotExistInRepo()
.assertThat().contains(testFolder)
.and().assertThat().doesNotContain(new FolderModel(newFolderName));
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify inexistent user is not able to rename a folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = TestConfigurationException.class,
expectedExceptionsMessageRegExp = ".*You missed some configuration settings in your tests: User failed to connect to IMAP server LOGIN failed. Invalid login/password$")
public void nonexistentUserShouldNotRenameFolder() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(UserModel.getRandomUserModel()).usingResource(testFolder)
.rename(newFolderName)
.then().assertThat().doesNotExistInRepo()
.and().assertThat().contains(testFolder)
.and().assertThat().doesNotContain(new FolderModel(newFolderName));
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify disconnected user is not able to rename a folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = IllegalStateException.class,
expectedExceptionsMessageRegExp= "Not connected")
public void disconnectedUserShouldNotRenameFolder() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(testUser).usingResource(testFolder).assertThat().existsInImap().then()
.disconnect().usingResource(testFolder)
.rename(newFolderName)
.then().assertThat().doesNotExistInRepo()
.and().assertThat().contains(testFolder)
.and().assertThat().doesNotContain(new FolderModel(newFolderName));
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify renaming folder by user with COLLABORATOR role - folder created by self")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void collaboratorShouldRenameFolderCreatedBySelf() throws Exception
{
UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
dataSite.usingUser(collaboratorUser).usingSite(testSite).setIMAPFavorite();
testFolder = dataContent.usingUser(collaboratorUser).usingSite(testSite).createFolder();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(collaboratorUser).usingSite(testSite).usingResource(testFolder)
.rename(newFolderName)
.usingSite(testSite)
.assertThat().contains(new FolderModel(newFolderName))
.assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user with COLLABORATOR role is not able to rename a folder created by other user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void collaboratorShouldNotRenameFolderCreatedByOtherUser() throws Exception
{
UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
dataSite.usingUser(collaboratorUser).usingSite(testSite).setIMAPFavorite();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(collaboratorUser).usingResource(testFolder).rename(newFolderName)
.usingSite(testSite)
.assertThat().contains(testFolder)
.assertThat().doesNotContain(new FolderModel(newFolderName));
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user with CONTRIBUTOR role is able to rename a folder created by self")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void contributorShouldRenameFolderCreatedBySelf() throws Exception
{
UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
dataSite.usingUser(contributorUser).usingSite(testSite).setIMAPFavorite();
testFolder = dataContent.usingUser(contributorUser).usingSite(testSite).createFolder();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(contributorUser).usingSite(testSite).usingResource(testFolder)
.rename(newFolderName)
.usingSite(testSite)
.assertThat().contains(new FolderModel(newFolderName))
.assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user with CONTRIBUTOR role is NOT able to rename a folder created by other user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void contributorShouldNotRenameFolderCreatedByOtherUser() throws Exception
{
UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
dataSite.usingUser(contributorUser).usingSite(testSite).setIMAPFavorite();
FolderModel testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(contributorUser).usingSite(testSite).usingResource(testFolder)
.rename(newFolderName).usingSite(testSite).then().assertThat().contains(testFolder)
.and().assertThat().doesNotContain(new FolderModel(newFolderName));
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user with CONSUMER role is not able to rename a folder created by other user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void consumerShouldNotRenameFolderCreatedByOtherUser() throws Exception
{
UserModel consumer = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(consumer, testSite, UserRole.SiteConsumer);
dataSite.usingUser(consumer).usingSite(testSite).setIMAPFavorite();
FolderModel testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
String newFolderName = RandomData.getRandomName("Folder");
imapProtocol.authenticateUser(consumer).usingSite(testSite).usingResource(testFolder)
.rename(newFolderName).usingSite(testSite).then()
.assertThat().contains(testFolder)
.and().assertThat().doesNotContain(new FolderModel(newFolderName));
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify renaming folder fails when it was deleted by another user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
public void userCannotRenameFolderDeletedByAnotherUser() throws Exception
{
UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
FolderModel testFolder = FolderModel.getRandomFolderModel();
dataSite.usingUser(contributorUser).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(contributorUser).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInRepo()
.assertThat().existsInImap()
.delete().disconnect();
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).rename("deletedFolderRename");
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user can rename folder to a name that contains white spaces")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void userCanRenameFolderToAFolderThatContainsWhiteSpaces() throws Exception
{
FolderModel testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and()
.assertThat().existsInRepo()
.assertThat().existsInImap()
.rename("folder with name that contains spaces")
.then().usingSite(testSite)
.assertThat().contains(new FolderModel("folder with name that contains spaces"))
.assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user can rename folder successfully with name that contains special characters")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void userCanRenameFolderWithSpecialCharacters() throws Exception
{
FolderModel testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and()
.assertThat().existsInRepo()
.assertThat().existsInImap()
.rename("(a)[b]!#%^")
.then().usingSite(testSite)
.assertThat().contains(new FolderModel("(a)[b]!#%^"))
.assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user can rename folder successfully with name that contains symbols")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void userCanRenameFolderWithSymbols() throws Exception
{
FolderModel testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and()
.assertThat().existsInRepo()
.assertThat().existsInImap()
.rename("a£¥€$♊♎ ♏ ♐ ♑ ♒ ♓")
.then().usingSite(testSite)
.assertThat().contains(new FolderModel("a£¥€$♊♎ ♏ ♐ ♑ ♒ ♓"))
.assertThat().doesNotContain(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify user cannot create folder with name omegaΩ_<>./?")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void userCannotRenameFolderWithNameThatContainsRestrictedCharacters() throws Exception
{
FolderModel testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and()
.assertThat().existsInRepo()
.assertThat().existsInImap()
.rename("omegaΩ_<>./?")
.then().usingSite(testSite)
.assertThat().contains(testFolder)
.assertThat().doesNotContain(new FolderModel("omegaΩ_<>./?"));
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify renaming folder fails when it was renamed by another user")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
public void userCannotRenameFolderRenamedByAnotherUser() throws Exception
{
UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
FolderModel testFolder = FolderModel.getRandomFolderModel();
dataSite.usingUser(contributorUser).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(contributorUser).usingSite(testSite).createFolder(testFolder)
.assertThat().existsInRepo()
.assertThat().existsInImap()
.rename("folderRenamedByUser").disconnect();
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).rename("deletedFolderRename");
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify a site folder cannot be renamed via IMAP client")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void verifyASiteFolderCannotBeRenamedViaImap() throws Exception
{
SiteModel siteModel = dataSite.usingUser(testUser).createIMAPSite();
imapProtocol.authenticateUser(testUser).usingSiteRoot(siteModel).rename("new site name")
.and()
.assertThat().doesNotExistInRepo()
.then().usingSites()
.assertThat().doesNotContain(new FolderModel("new site name"));
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify renaming folder by changing the case")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
public void verifyFolderCanBeRenamedByChangingTheCase() throws Exception
{
FolderModel testFolder = FolderModel.getRandomFolderModel();
imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and()
.assertThat().existsInRepo()
.assertThat().existsInImap()
.rename(testFolder.getName().toUpperCase())
.then().usingSite(testSite)
.assertThat().contains(new FolderModel(testFolder.getName().toUpperCase()))
.assertThat().doesNotContain(testFolder);
}
}

View File

@@ -0,0 +1,34 @@
package org.alfresco.email.imap;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class ImapRenameMessagesTests extends EmailTest
{
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify the renamed file from repository is still preset in IMAP client with the old name for site manager")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void siteManagerShouldVerifyFileContentForRenamedFileViaImap() throws Exception
{
testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
FileModel renamedFile = testFile;
renamedFile.setName(FileModel.getRandomFileModel(FileType.TEXT_PLAIN).getName());
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).assertThat().existsInRepo()
.and().assertThat().existsInImap()
.then().renameMessageTo(renamedFile).assertThat().messageContentMatchesFileModelData(testFile);
}
}

View File

@@ -0,0 +1,118 @@
package org.alfresco.email.imap;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.Test;
/**
* Tests for Search for Messages in IMAP client
*
* @author Cristina Axinte
*
*/
public class ImapSearchMessagesTests extends EmailTest
{
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify that no results are returned when searching for a message name term with no match")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void noResultsReturnedWhenSearchingForNotExistingMessage() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
String fileName1="File-new1";
FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder)
.createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
String fileName2="File2";
FileModel fileModel2 = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder)
.createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
.searchSubjectFor("new").assertThat().resultsContainMessage(fileModel1)
.assertThat().resultsDoNotContainMessage(fileModel2);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
description = "Verify that searched message is returned when searching for full message name")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
public void searchedMessageIsReturnedWhenSearchingForFullMessageName() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
String fileName1="File-new1";
FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder)
.createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
String fileName2="File2";
FileModel fileModel2 = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder)
.createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
.searchSubjectFor("File2").assertThat().resultsContainMessage(fileModel2)
.assertThat().resultsDoNotContainMessage(fileModel1);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that search results are returned for search term containing white spaces")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerVerifySearchResultsForWhiteSpaces() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
String fileName1="File new";
FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite)
.createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
String fileName2="File new1";
FileModel fileModel2 = dataContent.usingSite(testSite)
.createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
imapProtocol.authenticateUser(testUser).usingSite(testSite).searchSubjectFor("File new")
.assertThat().resultsContainMessage(fileModel1, fileModel2);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that search results are returned for search term containing wildcards")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerVerifySearchResultsForWildcards() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
String fileName1="File new 1";
FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite)
.createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
String fileName2="File presentation 2";
FileModel fileModel2 = dataContent.usingSite(testSite)
.createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
imapProtocol.authenticateUser(testUser).usingSite(testSite).searchSubjectWithWildcardsFor("File.*1.*")
.assertThat().resultsContainMessage(fileModel1)
.assertThat().resultsDoNotContainMessage(fileModel2);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that search results are returned for search term containing special characters")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerVerifySearchResultsForSpecialCharacters() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
String fileName1="File@#$%^&()-_=+-[]{};'";
FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite)
.createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
String fileName2="File";
FileModel fileModel2 = dataContent.usingSite(testSite)
.createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
imapProtocol.authenticateUser(testUser).usingSite(testSite)
.searchSubjectFor("=").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
.searchSubjectFor("@").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
.searchSubjectFor("#").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
.searchSubjectFor("$").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
.searchSubjectFor("@#").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
.searchSubjectFor("[]").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2);
}
}

View File

@@ -0,0 +1,81 @@
package org.alfresco.email.imap;
import org.alfresco.email.EmailTest;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.mail.FolderNotFoundException;
import javax.mail.MessagingException;
public class ImapSitesTests extends EmailTest
{
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createIMAPSite();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager can unsubscribe from a folder")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerCanUnSubscribeFromAFolder() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().isSubscribed()
.usingResource(testFolder).assertThat().isSubscribed()
.unsubscribe().assertThat().isNotSubscribed()
.usingSite(testSite).assertThat().isSubscribed();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that site manager is subscribed to folders created by self")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
public void siteManagerIsSubscribedToFoldersCreatedBySelf() throws Exception
{
testFolder = new FolderModel("newFolder");
imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().isSubscribed()
.createFolder(testFolder).assertThat().existsInRepo().assertThat().existsInImap()
.assertThat().isSubscribed();
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that operations on a private site are not permitted")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class,
expectedExceptionsMessageRegExp = ".* Access Denied.*You do not have the appropriate permissions to perform this operation.*")
public void verifyOperationsOnPrivateSiteAreNotPermitted() throws Exception
{
adminUser = dataUser.getAdminUser();
adminSite = dataSite.usingAdmin().createPrivateRandomSite();
testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
dataSite.usingUser(testUser).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(testUser).usingSite(adminSite).assertThat().contains(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify that operations on a moderated site are not permitted")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
public void verifyOperationsOnModeratedSiteAreNotPermitted() throws Exception
{
adminUser = dataUser.getAdminUser();
adminSite = dataSite.usingAdmin().createModeratedRandomSite();
testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
dataSite.usingUser(testUser).usingSite(testSite).setIMAPFavorite();
imapProtocol.authenticateUser(testUser).usingSite(adminSite).assertThat().contains(testFolder);
}
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
description = "Verify site cannot be accessed in IMAP client if it is no longer an IMAP site or marked as IMAP favorite")
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
public void userCannotAccessSiteThatIsNoLongerAnImapSiteOrMarkedAsImapFavorite() throws Exception
{
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().contains(testFolder);
dataSite.usingUser(testUser).usingSite(testSite).unsetIMAPFavorite();
imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().contains(testFolder);
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="org.alfresco" />
<import resource="classpath:dataprep-context.xml" />
<import resource="classpath*:alfresco-tester-context.xml" />
</beans>

View File

@@ -0,0 +1,97 @@
# dataprep related
alfresco.scheme=http
alfresco.server=localhost
alfresco.port=8082
# credentials
admin.user=admin
admin.password=admin
# in containers we cannot access directly JMX, so we will use http://jolokia.org agent
# disabling this we will use direct JMX calls to server
jmx.useJolokiaAgent=false
# Server Health section
# in ServerHealth#isServerReachable() - could also be shown.
# enable this option to view if on server there are tenants or not
serverHealth.showTenants=true
# IMAP Service settings from admin console
imap.server=${alfresco.server}
imap.port=143
imaps.port=993
# Inbound Email settings from admin console
smtp.server=${alfresco.server}
smtp.port=25
smtp.authentication.enabled=true
smtp.tsl.enabled=false
# Outbound Email settings from admin console
mail.encoding=UTF-8
mail.from.default=alfresco.cloud@gmail.com
mail.from.enabled=true
mail.host=smtp.gmail.com
mail.password=eiWei6vieiWei6vieiWei6vieiWei6vi
mail.port=465
mail.protocol=smtps
mail.smtp.auth=true
mail.smtp.debug=false
mail.smtp.starttls.enable=true
mail.smtp.timeout=30000
mail.smtps.auth=true
mail.smtps.starttls.enable=true
mail.username=alfresco.cloud@gmail.com
# TEST MANAGEMENT SECTION - Test Rail
#
# (currently supporting Test Rail v5.2.1.3472 integration)
#
# Example of configuration:
# ------------------------------------------------------
# if testManagement.enabled=true we enabled TestRailExecutorListener (if used in your suite xml file)
# testManagement.updateTestExecutionResultsOnly=true (this will just update the results of a test: no step will be updated - good for performance)
# testManagement.endPoint=https://alfresco.testrail.com/
# testManagement.username=<username>
# testManagement.apiKey=<api-key>
# testManagement.project=<id-of-your-project
# testManagement.testRun=<test-run-name>
# testManagement.includeOnlyTestCasesExecuted=true #if you want to include in your run ONLY the test cases that you run, then set this value to false
# testManagement.rateLimitInSeconds=1 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit
# testManagement.suiteId=23 (the id of the Master suite)
# ------------------------------------------------------
testManagement.enabled=false
testManagement.endPoint=
testManagement.username=
testManagement.apiKey=
testManagement.project=7
testManagement.includeOnlyTestCasesExecuted=true
testManagement.rateLimitInSeconds=1
testManagement.testRun=MyTestRunInTestRail
testManagement.suiteId=12
# The location of the reports path
reports.path=./target/reports
#
# Database Section
# You should provide here the database URL, that can be a differed server as alfresco.
# https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html
#
# Current supported db.url:
#
# MySQL:
# db.url = jdbc:mysql://${alfresco.server}:3306/alfresco
#
# PostgreSQL:
# db.url = jdbc:postgresql://<your-DB-IP>:3306/alfresco
#
# Oracle:
# db.url = jdbc:oracle://<your-DB-IP>:3306/alfresco
#
# MariaDB:
# db.url = jdbc:mariadb://<your-DB-IP>:3306/alfresco
#
db.url = jdbc:mysql://${alfresco.server}:3306/alfresco
db.username = alfresco
db.password = alfresco

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EMAIL API" preserve-order="true">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"/>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"/>
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"/>
</listeners>
<test name="Email tests">
<packages>
<package name="org.alfresco.email.*"/>
</packages>
</test>
</suite>

View File

@@ -0,0 +1,26 @@
# Root logger option
log4j.rootLogger=INFO, file, stdout
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=./target/reports/alfresco-tas.log
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
# TestRail particular log file
# Direct log messages to a log file
log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender
log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log
log4j.appender.testrailLog.MaxBackupIndex=10
log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout
log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.category.testrail=INFO, testrailLog
log4j.additivity.testrail=false

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EMAILProtocol" parallel="classes" preserve-order="true" thread-count="1">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener>
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"></listener>
</listeners>
<test name="EMAIL">
<method-selectors>
<!-- -DincludeGroups=sanity,comments,people -DexcludeGroups=networks,othergroup -DrunBugs=true -DupdateTestRail=true-->
<method-selector>
<script language="beanshell"><![CDATA[
includedGroups = System.getProperty("includeGroups");
excludedGroups = System.getProperty("excludeGroups");
runBugs = System.getProperty("runBugs");
if((runBugs != null))
{
bugAnnotated = method.getAnnotation(org.alfresco.utility.report.Bug.class);
if (bugAnnotated != null && runBugs.equals("false") )
{
return false;
}
}
if ((includedGroups == null) || (includedGroups.isEmpty())) {
return false;
} else
{
StringTokenizer includedGroupsList = new StringTokenizer(includedGroups, ",");
if ((excludedGroups != null)) {
StringTokenizer excludedGroupsList = new StringTokenizer(excludedGroups, ",");
while (excludedGroupsList.hasMoreTokens()) {
exG = excludedGroupsList.nextToken();
if (groups.containsKey(exG))
{
return false;
}
}
}
while (includedGroupsList.hasMoreTokens()) {
grp = includedGroupsList.nextToken();
if ((groups.containsKey(grp)))
{
return true;
}
}
}
return false;
]]>
</script>
</method-selector>
</method-selectors>
<packages>
<package name="org.alfresco.email.*" />
</packages>
</test>
</suite>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EMAILProtocol" preserve-order="true">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener>
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"></listener>
</listeners>
<test name="Email-Sanity">
<groups>
<run>
<include name="sanity" />
<exclude name="demo"></exclude>
<exclude name="unit"></exclude>
<!-- networks is related to tenant tests -->
<exclude name="networks"></exclude>
</run>
</groups>
<packages>
<package name="org.alfresco.email.*"></package>
</packages>
</test>
</suite> <!-- Suite -->

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EMAIL API" preserve-order="true">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener>
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"></listener>
</listeners>
<test name="Sanity">
<groups>
<run>
<include name="sanity" />
<exclude name="demo"></exclude>
<exclude name="unit"></exclude>
<!-- networks is related to tenant tests -->
<exclude name="networks"></exclude>
</run>
</groups>
<packages>
<package name="org.alfresco.email.imap.*"></package>
<package name="org.alfresco.email.smtp.*"></package>
</packages>
</test>
<test name="Core">
<groups>
<run>
<include name="core" />
<exclude name="demo"></exclude>
<exclude name="unit"></exclude>
<!-- networks is related to tenant tests -->
<exclude name="networks"></exclude>
</run>
</groups>
<packages>
<package name="org.alfresco.email.imap.*"></package>
<package name="org.alfresco.email.smtp.*"></package>
</packages>
</test>
<test name="Full">
<groups>
<run>
<include name="full" />
<exclude name="demo"></exclude>
<exclude name="unit"></exclude>
<!-- networks is related to tenant tests -->
<exclude name="networks"></exclude>
</run>
</groups>
<packages>
<package name="org.alfresco.email.imap.*"></package>
<package name="org.alfresco.email.smtp.*"></package>
</packages>
</test>
<test name="Tenant">
<groups>
<run>
<!-- networks is related to tenant tests -->
<include name="networks" />
</run>
</groups>
<packages>
<package name="org.alfresco.email.imap.*"></package>
<package name="org.alfresco.email.smtp.*"></package>
</packages>
</test>
</suite> <!-- Suite -->

View File

@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Tests for Test Group = sanity" verbose="1">
<listeners>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener" />
<listener class-name="org.alfresco.utility.report.HtmlReportListener" />
</listeners>
<test name="Tas email sanity suite">
<classes>
<class name="org.alfresco.email.imap.ImapMoveMessagesTests">
<methods>
<include name="siteManagerShouldMoveNonEmptyFile" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapMessageFlagsTests">
<methods>
<include name="siteManagerShouldSetFlagsToAContent" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapCopyFolderTests">
<methods>
<include name="adminShouldCopyNonEmptyFolder" />
<include name="siteManagerShouldCopyFolder" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapDeleteMessagesTests">
<methods>
<include name="adminShouldDeleteMessage" />
<include name="siteManagerShouldDeleteMessage" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapRenameFolderTests">
<methods>
<include name="adminShouldRenameFolder" />
<include name="siteManagerShouldRenameFolder" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapRenameMessagesTests">
<methods>
<include name="siteManagerShouldVerifyFileContentForRenamedFileViaImap" />
</methods>
</class>
<!-- <class name="org.alfresco.email.imap.ImapSearchMessagesTests">
<methods>
<include name="noResultsReturnedWhenSearchingForNotExistingMessage" />
<include name="searchedMessageIsReturnedWhenSearchingForFullMessageName" />
</methods>
</class> -->
<class name="org.alfresco.email.smtp.SmtpOverwriteDuplicatesTests">
<methods>
<include name="overwriteFileWhenOverwriteDuplicatesIsDisabled" />
<include name="overwriteFileWhenOverwriteDuplicatesIsEnabled" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapDeleteFolderTests">
<methods>
<include name="adminShouldDeleteFolder" />
<include name="siteManagerShouldDeleteNonEmptyFolder" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapReadMessagesTests">
<methods>
<include name="adminShouldGetFoldersCreatedInRepositoryViaImap" />
<include name="siteManagerShouldGetFileAndItsContentsViaImap" />
<include name="siteManagerShouldVerifyFileContent" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapConnectionTests">
<methods>
<include name="correctUserConnectsToIMAPSuccessfully" />
<include name="userDisconnectsFromImapServerSuccessfully" />
<include name="userFailsConnectToIMAPOnDifferentPort" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapCopyMessagesTests">
<methods>
<include name="siteManagerShouldCopyNonEmptyFile" />
<include name="siteManagerShouldCopyNonEmptyFiles" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpConnectionTests">
<methods>
<include name="adminShouldConnectToSMTP" />
<include name="adminShouldNotConnectToDisabledServer" />
<!-- <include name="updateSmtpServerPort" /> -->
</methods>
</class>
<class name="org.alfresco.email.imap.ImapCheckFolderTests">
<methods>
<include name="adminShouldGetCurrentWorkingDirectory" />
<include name="siteManagerShouldGetCurrentWorkingDirectory" />
<include name="siteManagerShouldGetDirectoriesListOfRoot" />
<include name="userShouldFindAllIMAPSitesFoldersInAlfrescoIMAPFolder" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpUnknownUserTests">
<methods>
<include name="emailSentSuccessfullyWithAnExistingUser" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpAllowedSendersTests">
<methods>
<include name="sendMailIsSuccessfulForAllowedUser" />
<include name="sendingMailIsSuccessfulForAllUsers" />
<include name="sendingMailIsSuccessfulForUsersBelongingToDomain" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapMoveFolderTests">
<methods>
<include name="adminShouldMoveNonEmptyFolder" />
<include name="siteManagerShouldMoveFolder" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpBlockedSendersTests">
<methods>
<include name="emailSentSuccessfullyWithUserAddedToEmailContributorsGroup" />
<include name="sendMailIsDeniedForAllUsers" />
<include name="sendMailIsDeniedForBlockedUser" />
<include name="sendMailIsDeniedForUsersBelongingToDomain" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapCreateFolderTests">
<methods>
<include name="adminCanCreateFolderInAlfrescoImapRoot" />
<include name="adminCanCreateFolderInSitesFolder" />
<include name="managerCanCreateFolderInIMAPSite" />
<include name="userCanCreateFolderInAlfrescoImapRootButNotDisplayedInRepo" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpDisableInboundEmailTests">
<methods>
<include name="randomUserCannotConnectWithInboundDisabled" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpFolderAliasTests">
<methods>
<include name="randomUserWithAliasFolderReceivesEmail" />
</methods>
</class>
</classes>
</test>
</suite>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EmailTests">
<listeners>
<listener class-name="org.alfresco.utility.report.TestCountListener"></listener>
</listeners>
<test name="EmailTests">
<groups>
<run>
<exclude name="demo" />
<exclude name="unit" />
</run>
</groups>
<packages>
<package name="org.alfresco.email.*"></package>
</packages>
</test> <!-- Test -->
</suite> <!-- Suite -->

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<inputtestdata>
<sites>
<site id="11" name="site1" />
<site id="12" name="test2" />
<site id="13" name="test3" />
</sites>
<folders>
<folder id="11" name="folderA" />
<folder id="111" name="folder1">
<path>/Sites/site1/documentLibrary</path>
<file name="file1" />
</folder>
<folder id="112" name="folder2" />
<folder id="113" name="folder3" />
</folders>
<files>
<file id="11" name="file1" />
<file id="115" name="file2" />
<file id="116" name="file3" />
</files>
<sites>
<site id="221" name="site1" />
<file id="222" name="test2" />
<file id="223" name="test3" />
</sites>
<users>
<user id="331" name="user1" />
<user id="332" name="user2" />
<user id="333" name="1~#a" />
</users>
</inputtestdata>