Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage;
import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage.Tab;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

import lombok.Getter;
Expand All @@ -33,6 +35,7 @@
import org.openqa.selenium.support.FindBys;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.google.common.base.Strings;

Expand Down Expand Up @@ -69,6 +72,7 @@ public TokenPage create(String userName) {

WebDriverWaitFactory.createWebDriverWait(driver)
.until(ExpectedConditions.elementToBeClickable(createTokenForm().selectUserNameDropdown()));
setExpireTime(30);
createTokenForm().selectUserNameDropdown().click();
WebDriverWaitFactory.createWebDriverWait(driver)
.until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName(
Expand Down Expand Up @@ -161,4 +165,25 @@ public class TokenForm {
private WebElement buttonCancel;

}

private void setExpireTime(int daysAfter) {
try {
By dateTimePickerInputLocator = By.cssSelector(".n-date-picker input[type='text']");
WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(driver);
WebElement dateTimeInput = wait.until(ExpectedConditions.elementToBeClickable(dateTimePickerInputLocator));

LocalDateTime futureDateTime = LocalDateTime.now().plusDays(daysAfter);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String futureDateTimeStr = futureDateTime.format(dateTimeFormatter);

((JavascriptExecutor) driver).executeScript(
"arguments[0].value = arguments[1]; " +
"arguments[0].dispatchEvent(new Event('input')); " +
"arguments[0].dispatchEvent(new Event('change')); ",
dateTimeInput, futureDateTimeStr);
} catch (Exception e) {
throw new RuntimeException(
"Failed to set expire time after " + daysAfter + " days. Error: " + e.getMessage(), e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const TokenModal = defineComponent({
(userStore.getUserInfo as UserInfoRes).userType === 'GENERAL_USER'
? (userStore.getUserInfo as UserInfoRes).id
: null
variables.model.expireTime = Date.now()
variables.model.expireTime = null
variables.model.token = ''
} else {
variables.model.userId = props.row.userId
Expand Down Expand Up @@ -110,7 +110,7 @@ const TokenModal = defineComponent({
(userStore.getUserInfo as UserInfoRes).userType === 'GENERAL_USER'
? (userStore.getUserInfo as UserInfoRes).id
: null
variables.model.expireTime = Date.now()
variables.model.expireTime = null
variables.model.token = ''
} else {
variables.model.id = props.row.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
? (userStore.getUserInfo as UserInfoRes).id
: null
),
expireTime: ref(Date.now()),
expireTime: null as number | null,
token: ref(''),
generalOptions: []
},
Expand Down Expand Up @@ -101,7 +101,7 @@
const getToken = () => {
const data = {
userId: (userStore.getUserInfo as UserInfoRes).id,
expireTime: format(variables.model.expireTime, 'yyyy-MM-dd HH:mm:ss')
expireTime: format(variables.model.expireTime!, 'yyyy-MM-dd HH:mm:ss')

Check warning on line 104 in dolphinscheduler-ui/src/views/security/token-manage/components/use-modal.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This assertion is unnecessary since the receiver accepts the original type of the expression.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZyePEsvaebX4kp8Mvjn&open=AZyePEsvaebX4kp8Mvjn&pullRequest=17907
}

useAsyncState(
Expand Down Expand Up @@ -129,7 +129,7 @@
const submitTokenModal = () => {
const data = {
userId: Number(variables.model.userId),
expireTime: format(variables.model.expireTime, 'yyyy-MM-dd HH:mm:ss'),
expireTime: format(variables.model.expireTime!, 'yyyy-MM-dd HH:mm:ss'),

Check warning on line 132 in dolphinscheduler-ui/src/views/security/token-manage/components/use-modal.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This assertion is unnecessary since the receiver accepts the original type of the expression.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZyePEsvaebX4kp8Mvjo&open=AZyePEsvaebX4kp8Mvjo&pullRequest=17907
token: variables.model.token
}

Expand All @@ -138,7 +138,7 @@
(userStore.getUserInfo as UserInfoRes).userType === 'GENERAL_USER'
? (userStore.getUserInfo as UserInfoRes).id
: null
variables.model.expireTime = Date.now()
variables.model.expireTime = null
variables.model.token = ''
ctx.emit('confirmModal', props.showModalRef)
})
Expand All @@ -148,7 +148,7 @@
const data = {
id: variables.model.id,
userId: Number(variables.model.userId),
expireTime: format(variables.model.expireTime, 'yyyy-MM-dd HH:mm:ss'),
expireTime: format(variables.model.expireTime!, 'yyyy-MM-dd HH:mm:ss'),

Check warning on line 151 in dolphinscheduler-ui/src/views/security/token-manage/components/use-modal.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This assertion is unnecessary since the receiver accepts the original type of the expression.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZyePEsvaebX4kp8Mvjp&open=AZyePEsvaebX4kp8Mvjp&pullRequest=17907
token: variables.model.token
}

Expand Down
Loading