QuakeWang commented on a change in pull request #8161: URL: https://github.com/apache/dolphinscheduler/pull/8161#discussion_r793237284
########## File path: dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TokenE2ETest.java ########## @@ -0,0 +1,98 @@ +/* + * Licensed to 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. Apache Software Foundation (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.e2e.cases; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; + +import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; +import org.apache.dolphinscheduler.e2e.pages.LoginPage; +import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; +import org.apache.dolphinscheduler.e2e.pages.security.TokenPage; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.RemoteWebDriver; + +@DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") +public class TokenE2ETest { + + private static final String userName = "admin"; + + private static RemoteWebDriver browser; + + @BeforeAll + public static void setup() { + new LoginPage(browser) + .login("admin", "dolphinscheduler123") + .goToNav(SecurityPage.class) + .goToTab(TokenPage.class) + ; + } + + @Test + @Order(10) + void testCreateToken() { + final TokenPage page = new TokenPage(browser); + page.create(); + + await().untilAsserted(() -> { + browser.navigate().refresh(); + + assertThat(page.tokenList()) + .as("Token list should contain newly-created token") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(userName)); + }); + } + + @Test + @Order(30) + void testEditToken() { + final TokenPage page = new TokenPage(browser); + page.update(userName); Review comment: > > > Can you get the original token and assert the token is updated after this method? > > > > > > The token is randomly generated, so the original token will be lost when it is updated. > > The token is randomly generated when you create a new token, after that, you can get the generated token and save in a variable, when you re-generate the token, you can compare the previous one with the updated one, and assert that they are different. Good idea! I have tried to accept randomly generated tokens before, but it failed. Do you have a good method? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
