diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java b/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java index 5ad085a137..a7c1f7ffb4 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/common/BrowserCommon.java @@ -23,7 +23,7 @@ import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import redis.clients.jedis.Jedis; - +import org.openqa.selenium.JavascriptExecutor; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -115,6 +115,7 @@ public class BrowserCommon { /** * Click button element + * * @param locator By * @return clickButton */ @@ -128,12 +129,13 @@ public class BrowserCommon { /** * Click Navigation Bar element + * * @param locator By * @return clickButton */ public void clickTopElement(By locator) { WebElement element = driver.findElement(locator); - JavascriptExecutor executor = (JavascriptExecutor)driver; + JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", element); } @@ -164,6 +166,7 @@ public class BrowserCommon { inputElement.sendKeys(content); return inputElement; } + /** * clear element * @@ -182,9 +185,8 @@ public class BrowserCommon { * * @param codeMirrorLocator By codeMirror * @param codeMirrorLineLocator By codeMirrorLine - */ - public void inputCodeMirror(By codeMirrorLocator,By codeMirrorLineLocator,String content) { + public void inputCodeMirror(By codeMirrorLocator, By codeMirrorLineLocator, String content) { WebElement codeMirrorElement = locateElement(codeMirrorLocator); WebElement codeMirrorLineElement = locateElement(codeMirrorLineLocator); codeMirrorElement.click(); @@ -193,10 +195,11 @@ public class BrowserCommon { /** * move to element + * * @param locator BY * @return actions */ - public Actions moveToElement(By locator){ + public Actions moveToElement(By locator) { return actions.moveToElement(locateElement(locator)); } @@ -206,14 +209,14 @@ public class BrowserCommon { * @param source_locator BY * @param target_locator BY */ - public void dragAndDrop(By source_locator, By target_locator){ + public void dragAndDrop(By source_locator, By target_locator) { WebElement sourceElement = locateElement(source_locator); WebElement targetElement = locateElement(target_locator); actions.dragAndDrop(sourceElement, targetElement).perform(); actions.release(); } - public void moveToDragElement(By target_locator, int X, int Y){ + public void moveToDragElement(By target_locator, int X, int Y) { WebElement targetElement = locateElement(target_locator); actions.dragAndDropBy(targetElement, X, Y).perform(); actions.release(); @@ -249,9 +252,22 @@ public class BrowserCommon { return driver; } + /** + * select time + * + * @return WebElement + */ + public WebElement selectDate(String js, By locator_time, String date) { + JavascriptExecutor removeAttribute = (JavascriptExecutor) driver; + removeAttribute.executeScript("var setDate=" + js + ";setDate.removeAttribute('readonly');"); + WebElement dateElement = locateElement(locator_time); - - + //input date + dateElement.clear(); + dateElement.sendKeys(Keys.HOME,Keys.chord(Keys.SHIFT,Keys.END)); + dateElement.sendKeys(date); + return dateElement; + } /** * Multi-window switch handle, according to the handle number passed in diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/data/security/QueueManageData.java b/e2e/src/test/java/org/apache/dolphinscheduler/data/security/QueueManageData.java new file mode 100644 index 0000000000..9fa9568a35 --- /dev/null +++ b/e2e/src/test/java/org/apache/dolphinscheduler/data/security/QueueManageData.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dolphinscheduler.data.security; + +public class QueueManageData { + /** + * Create Queue Name + */ + public static final String QUEUE_NAME = "selenium_queue_name"; + + /** + * Create Queue Value + */ + public static final String QUEUE_VALUE = "selenium_queue_value"; + + /** + * Edit Queue Name + */ + public static final String EDIT_QUEUE_NAME = "_edit"; + + /** + * Edit Queue Value + */ + public static final String EDIT_QUEUE_VALUE = "_edit"; + + public static final String QUEUE_MANAGE = "队列管理 - DolphinScheduler"; + +} diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/data/security/TokenManageData.java b/e2e/src/test/java/org/apache/dolphinscheduler/data/security/TokenManageData.java new file mode 100644 index 0000000000..6b6370f550 --- /dev/null +++ b/e2e/src/test/java/org/apache/dolphinscheduler/data/security/TokenManageData.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dolphinscheduler.data.security; + +public class TokenManageData { + public static final String TOKEN_MANAGE = "令牌管理 - DolphinScheduler"; + public static final String DATE = "2038-06-10 00:00:00"; + + +} diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/QueueManageLocator.java b/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/QueueManageLocator.java new file mode 100644 index 0000000000..ee7d3992b5 --- /dev/null +++ b/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/QueueManageLocator.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dolphinscheduler.locator.security; + +import org.openqa.selenium.By; + +public class QueueManageLocator { + //create queue locator + public static final By CLICK_QUEUE_MANAGE = By.xpath("//div[6]/div/a/div/a/span"); + public static final By CLICK_CREATE_QUEUE = By.xpath("//button/span"); + public static final By INPUT_QUEUE_NAME = By.xpath("//div[2]/div/div/div[2]/div/input"); + public static final By INPUT_QUEUE_VALUE = By.xpath("//div[2]/div[2]/div/input"); + public static final By SUBMIT_QUEUE = By.xpath("//button[2]/span"); + + //edit queue locator + public static final By CLICK_EDIT_QUEUE = By.xpath("//td[6]/button/i"); +} diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/TokenManageLocator.java b/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/TokenManageLocator.java new file mode 100644 index 0000000000..e7f7654811 --- /dev/null +++ b/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/TokenManageLocator.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dolphinscheduler.locator.security; + +import org.openqa.selenium.By; + +public class TokenManageLocator { + //create token + public static final By CLICK_TOKEN_MANAGE = By.xpath("//div[7]/div/a/div/a/span"); + + public static final By CLICK_CREATE_TOKEN = By.xpath("//div[2]/div/div[2]/div[2]/div/div[1]/button/span"); + + public static final By SELECT_USER = By.xpath("//div[2]/div[2]/div/div/div/span/i"); + + public static final By CLICK_GENERATE_TOKEN_BUTTON = By.xpath("//div[3]/div[2]/button/span"); + + public static final By CLICK_SUBMIT_BUTTON = By.xpath("//div[3]/button[2]/span"); + + //edit token + public static final By CLICK_EDIT_BUTTON = By.xpath("//div[3]/div[1]/div/table/tr[2]/td[7]/button/i"); + + //delete token + public static final By CLICK_DELETE_BUTTON = By.xpath("//div[3]/div[1]/div/table/tr[2]/td[7]/span/button"); + + public static final By CLICK_CONFIRM_DELETE_BUTTON = By.xpath("//div[2]/div/button[2]/span"); + +} diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/page/security/AlertManagePage.java b/e2e/src/test/java/org/apache/dolphinscheduler/page/security/AlertManagePage.java index eb3fa34bb5..a205723867 100644 --- a/e2e/src/test/java/org/apache/dolphinscheduler/page/security/AlertManagePage.java +++ b/e2e/src/test/java/org/apache/dolphinscheduler/page/security/AlertManagePage.java @@ -38,11 +38,11 @@ public class AlertManagePage extends PageCommon { public boolean createAlert() throws InterruptedException { // click alert manage clickElement(AlertManageLocator.CLICK_ALERT_MANAGE); - Thread.sleep(2000); + Thread.sleep(1000); // click create alert button clickElement(AlertManageLocator.CLICK_CREATE_ALERT); - Thread.sleep(2000); + Thread.sleep(1000); // input alert data sendInput(AlertManageLocator.INPUT_ALERT_NAME, AlertManageData.ALERT_NAME); diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/page/security/QueueManagePage.java b/e2e/src/test/java/org/apache/dolphinscheduler/page/security/QueueManagePage.java new file mode 100644 index 0000000000..33b7627254 --- /dev/null +++ b/e2e/src/test/java/org/apache/dolphinscheduler/page/security/QueueManagePage.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dolphinscheduler.page.security; + +import org.apache.dolphinscheduler.common.PageCommon; +import org.apache.dolphinscheduler.data.security.QueueManageData; +import org.apache.dolphinscheduler.locator.security.QueueManageLocator; +import org.openqa.selenium.WebDriver; + +public class QueueManagePage extends PageCommon { + /** + * Unique constructor + * @param driver driver + */ + public QueueManagePage(WebDriver driver) { + super(driver); + } + + /** + * create queue + * + * @return Whether to enter the specified page after create queue + */ + public boolean createQueue() throws InterruptedException { + // click queue manage + clickElement(QueueManageLocator.CLICK_QUEUE_MANAGE); + Thread.sleep(1000); + + // click create queue button + clickElement(QueueManageLocator.CLICK_CREATE_QUEUE); + Thread.sleep(1000); + + // input queue data + sendInput(QueueManageLocator.INPUT_QUEUE_NAME, QueueManageData.QUEUE_NAME); + + sendInput(QueueManageLocator.INPUT_QUEUE_VALUE, QueueManageData.QUEUE_VALUE); + + // click button + clickButton(QueueManageLocator.SUBMIT_QUEUE); + + // Whether to enter the specified page after submit + return ifTitleContains(QueueManageData.QUEUE_MANAGE); + } + + + /** + * edit queue + * + * @return Whether to enter the specified page after create queue + */ + public boolean editQueue() throws InterruptedException { + // click queue manage + Thread.sleep(1000); + clickElement(QueueManageLocator.CLICK_QUEUE_MANAGE); + Thread.sleep(1000); + + // click edit queue button + clickElement(QueueManageLocator.CLICK_EDIT_QUEUE); + Thread.sleep(1000); + + // input queue data + sendInput(QueueManageLocator.INPUT_QUEUE_NAME, QueueManageData.EDIT_QUEUE_NAME); + sendInput(QueueManageLocator.INPUT_QUEUE_VALUE, QueueManageData.EDIT_QUEUE_VALUE); + + // click button + clickButton(QueueManageLocator.SUBMIT_QUEUE); + + // Whether to enter the specified page after submit + return ifTitleContains(QueueManageData.QUEUE_MANAGE); + } +} diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/page/security/TokenManagePage.java b/e2e/src/test/java/org/apache/dolphinscheduler/page/security/TokenManagePage.java new file mode 100644 index 0000000000..2f8204ac47 --- /dev/null +++ b/e2e/src/test/java/org/apache/dolphinscheduler/page/security/TokenManagePage.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dolphinscheduler.page.security; + +import org.apache.dolphinscheduler.common.PageCommon; +import org.apache.dolphinscheduler.data.security.TokenManageData; +import org.apache.dolphinscheduler.locator.security.TokenManageLocator; +import org.openqa.selenium.WebDriver; + +public class TokenManagePage extends PageCommon { + public TokenManagePage(WebDriver driver) { + super(driver); + } + + /** + * createTenant + * + * @return Whether to enter the specified page after creat tenant + */ + public boolean createToken() throws InterruptedException { + //create token + Thread.sleep(1000); + clickElement(TokenManageLocator.CLICK_TOKEN_MANAGE); + Thread.sleep(1000); + + // click create token button + clickButton(TokenManageLocator.CLICK_CREATE_TOKEN); + Thread.sleep(1000); + + //selectDate(TokenManageLocator.js, TokenManageLocator.CLICK_TIME, TokenManageData.DATE); + + clickButton(TokenManageLocator.SELECT_USER); + + clickButton(TokenManageLocator.CLICK_GENERATE_TOKEN_BUTTON); + Thread.sleep(2500); + + // click button + clickButton(TokenManageLocator.CLICK_SUBMIT_BUTTON); + + // Whether to enter the specified page after submit + return ifTitleContains(TokenManageData.TOKEN_MANAGE); + } + + + //edit token + public boolean editToken() throws InterruptedException { + // click token manage + clickElement(TokenManageLocator.CLICK_TOKEN_MANAGE); + Thread.sleep(1000); + + // click create token button + clickButton(TokenManageLocator.CLICK_EDIT_BUTTON); + Thread.sleep(1000); + + clickButton(TokenManageLocator.SELECT_USER); + + clickButton(TokenManageLocator.CLICK_GENERATE_TOKEN_BUTTON); + Thread.sleep(2500); + + // click button + clickButton(TokenManageLocator.CLICK_SUBMIT_BUTTON); + + // Whether to enter the specified page after submit + return ifTitleContains(TokenManageData.TOKEN_MANAGE); + } + + + //delete token + public boolean deleteToken() throws InterruptedException { + // click token manage + clickElement(TokenManageLocator.CLICK_TOKEN_MANAGE); + Thread.sleep(1000); + + clickButton(TokenManageLocator.CLICK_DELETE_BUTTON); + clickButton(TokenManageLocator.CLICK_CONFIRM_DELETE_BUTTON); + + return ifTitleContains(TokenManageData.TOKEN_MANAGE); + } + +} diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/testcase/testDeleteData/TestDeleteToken.java b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/testDeleteData/TestDeleteToken.java new file mode 100644 index 0000000000..d524f0056f --- /dev/null +++ b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/testDeleteData/TestDeleteToken.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dolphinscheduler.testcase.testDeleteData; + +import org.apache.dolphinscheduler.base.BaseTest; +import org.apache.dolphinscheduler.page.security.TenantManagePage; +import org.apache.dolphinscheduler.page.security.TokenManagePage; +import org.testng.annotations.Test; + +public class TestDeleteToken extends BaseTest { + private TokenManagePage tokenManagePage; + private TenantManagePage tenantManagePage; + + + @Test(groups = {"functionTests"}, dependsOnGroups = {"login", "token"}, description = "TestDeleteToken") + public void testUserManage() throws InterruptedException { + tenantManagePage = new TenantManagePage(driver); + System.out.println("jump to security to delete token"); + tenantManagePage.jumpSecurity(); + + tokenManagePage = new TokenManagePage(driver); + //delete token + System.out.println("start delete token"); + assert tokenManagePage.deleteToken(); + System.out.println("end delete token"); + System.out.println("==================================="); + } +} diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/testcase/testSecurity/TestQueueManage.java b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/testSecurity/TestQueueManage.java new file mode 100644 index 0000000000..3e33bb9ad7 --- /dev/null +++ b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/testSecurity/TestQueueManage.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dolphinscheduler.testcase.testSecurity; + +import org.apache.dolphinscheduler.base.BaseTest; +import org.apache.dolphinscheduler.page.security.QueueManagePage; +import org.testng.annotations.Test; + + +public class TestQueueManage extends BaseTest { + private QueueManagePage queueManagePage; + + @Test(groups={"functionTests","queue"},dependsOnGroups = { "login" },description = "TestQueueManage") + public void testTenantManage() throws InterruptedException { + queueManagePage = new QueueManagePage(driver); + //create queue + System.out.println("start create queue"); + assert queueManagePage.createQueue(); + System.out.println("end create queue"); + System.out.println("==================================="); + + //edit queue + System.out.println("start edit queue"); + assert queueManagePage.editQueue(); + System.out.println("end edit queue"); + System.out.println("==================================="); + } +} diff --git a/e2e/src/test/java/org/apache/dolphinscheduler/testcase/testSecurity/TestTokenManage.java b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/testSecurity/TestTokenManage.java new file mode 100644 index 0000000000..e46cf0d997 --- /dev/null +++ b/e2e/src/test/java/org/apache/dolphinscheduler/testcase/testSecurity/TestTokenManage.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dolphinscheduler.testcase.testSecurity; + +import org.apache.dolphinscheduler.base.BaseTest; +import org.apache.dolphinscheduler.page.security.TokenManagePage; +import org.testng.annotations.Test; + +public class TestTokenManage extends BaseTest { + private TokenManagePage tokenManagePage; + + @Test(groups={"functionTests","token"},dependsOnGroups = { "login" },description = "TestTokenManage") + public void testUserManage() throws InterruptedException { + tokenManagePage = new TokenManagePage(driver); + //generate token + System.out.println("start create token"); + assert tokenManagePage.createToken(); + System.out.println("end create token"); + System.out.println("==================================="); + + + //edit token + System.out.println("start edit token"); + assert tokenManagePage.editToken(); + System.out.println("end edit token"); + System.out.println("==================================="); + + } +} diff --git a/e2e/testng.xml b/e2e/testng.xml index 5bd35bdc78..438d5474d3 100644 --- a/e2e/testng.xml +++ b/e2e/testng.xml @@ -28,6 +28,8 @@ + + @@ -35,6 +37,7 @@ +