@BeforeClass(alwaysRun = true) public void setUp() throws Exception { super.init(userMode); driver = new ESWebDriver(BrowserManager.getWebDriver()); currentUserName = userInfo.getUserName(); currentUserPwd = userInfo.getPassword(); baseUrl = getStorePublisherUrl(); AutomationContext automationContext = new AutomationContext(PRODUCT_GROUP_NAME, TestUserMode.TENANT_ADMIN); adminUserName = automationContext.getContextTenant().getTenantAdmin().getUserName(); adminUserPwd = automationContext.getContextTenant().getTenantAdmin().getPassword(); String resourceLocation = getResourceLocation(); backendURL = automationContext.getContextUrls().getBackEndUrl(); resourceAdminServiceClient = new ResourceAdminServiceClient(backendURL, adminUserName, adminUserPwd); providerName = currentUserName.split("@")[0]; resourcePath = GADGET_REGISTRY_BASE_PATH + providerName + "/" + assetName + "/" + VERSION; LCNotificationSubject += resourcePath; updateNotificationSubject += resourcePath; smtpPropertyLocation = resourceLocation + SMTP_PROPERTY_FILE; // Update user profiles through Admin console ESUtil.loginToAdminConsole(driver, baseUrl, adminUserName, adminUserPwd); ESUtil.setupUserProfile(driver, baseUrl, currentUserName, FIRST_NAME, LAST_NAME, EMAIL); // login to publisher & add a new gadget ESUtil.login(driver, baseUrl, PUBLISHER_APP, currentUserName, currentUserPwd); AssetUtil.addNewAsset(driver, baseUrl, ASSET_TYPE, assetName, VERSION, "", "", ""); }
@AfterClass(groups = "wso2.es.notification", alwaysRun = true) public void tearDown() throws Exception { // delete gadget and email, logout from admin console and publisher resourceAdminServiceClient.deleteResource(resourcePath); ESUtil.logoutFromAdminConsole(driver, baseUrl); driver.get(baseUrl + PUBLISHER_LOGOUT_URL); driver.quit(); }
@Test( groups = "wso2.es.notification", description = "Testing mails for LC state " + "change event") public void testLCNotification() throws Exception { // check notification for initial LC state change driver.findElementPoll(By.linkText(assetName), MAX_POLL_COUNT); // read email using smtp boolean hasMail = ESUtil.containsEmail(smtpPropertyLocation, EMAIL_PWD, EMAIL, LCNotificationSubject); assertTrue(hasMail, "LC Notification failed for user:" + currentUserName); }
@Test( groups = "wso2.es.notification", description = "Testing mails for asset update event", dependsOnMethods = "testLCNotification") public void testUpdateNotification() throws Exception { // Update gadget and check lC state change notification driver.get(baseUrl + PUBLISHER_GADGET_LIST_PAGE); AssetUtil.updateAsset(driver, baseUrl, ASSET_TYPE, assetName, ASSET_DESCRIPTION); driver.get(baseUrl + PUBLISHER_GADGET_LIST_PAGE); // read email using smtp boolean hasMail = ESUtil.containsEmail(smtpPropertyLocation, EMAIL_PWD, EMAIL, updateNotificationSubject); assertTrue(hasMail, "Asset Update Notification failed for user:" + currentUserName); }
@Test(groups = "wso2.es.common", description = "Testing password recovery through email") public void testPasswordRecoveryEmail() throws Exception { driver.get(baseUrl + STORE_URL); driver.findElement(By.id("btn-signin")).click(); driver.findElement(By.linkText("Forgot your password?")).click(); driver.findElement(By.id("username")).clear(); driver.findElement(By.id("username")).sendKeys(USER); driver.findElement(By.id("validationSubmit")).click(); String resourceLocation = getResourceLocation(); smtpPropertyLocation = resourceLocation + SMTP_PROPERTY_FILE; // TODO:avoid waiting // waiting for email to receive Thread.sleep(10000); String message = ESUtil.readEmail(smtpPropertyLocation, EMAIL_PWD, EMAIL, RESET_MAIL_TITLE); String resetUrl = message.split("\r")[5].trim().substring("https://localhost:9443".length()); driver.get(baseUrl + resetUrl); driver.findElement(By.id("password")).clear(); driver.findElement(By.id("password")).sendKeys(NEW_PASSWORD); driver.findElement(By.id("password2")).clear(); driver.findElement(By.id("password2")).sendKeys(NEW_PASSWORD); driver.findElement(By.id("resetPassword")).click(); ESUtil.login(driver, baseUrl, STORE_APP, USER, NEW_PASSWORD); }