-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into dev_wenjun_fixTaskWorkingDirIsNotDelete
- Loading branch information
Showing
23 changed files
with
802 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
...-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/LdapLoginAPITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* 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.api.test.cases; | ||
|
||
import org.apache.dolphinscheduler.api.test.core.DolphinScheduler; | ||
import org.apache.dolphinscheduler.api.test.entity.GetUserInfoResponseData; | ||
import org.apache.dolphinscheduler.api.test.entity.HttpResponse; | ||
import org.apache.dolphinscheduler.api.test.entity.LoginResponseData; | ||
import org.apache.dolphinscheduler.api.test.pages.LoginPage; | ||
import org.apache.dolphinscheduler.api.test.pages.security.UserPage; | ||
import org.apache.dolphinscheduler.api.test.utils.JSONUtils; | ||
import org.apache.dolphinscheduler.common.enums.UserType; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.Test; | ||
import org.junitpioneer.jupiter.DisableIfTestFails; | ||
|
||
@DolphinScheduler(composeFiles = "docker/ldap-login/docker-compose.yaml") | ||
@Slf4j | ||
@DisableIfTestFails | ||
public class LdapLoginAPITest { | ||
|
||
private static String sessionId; | ||
|
||
@Test | ||
@Order(10) | ||
public void testAdminUserLoginSuccess() { | ||
final String username = "admin_user01"; | ||
|
||
final String password = "123"; | ||
|
||
LoginPage loginPage = new LoginPage(); | ||
HttpResponse loginHttpResponse = loginPage.login(username, password); | ||
sessionId = | ||
JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); | ||
UserPage userPage = new UserPage(); | ||
HttpResponse getUserInfoHttpResponse = userPage.getUserInfo(sessionId); | ||
GetUserInfoResponseData getUserInfoResponseData = | ||
JSONUtils.convertValue(getUserInfoHttpResponse.getBody().getData(), GetUserInfoResponseData.class); | ||
Assertions.assertEquals(username, getUserInfoResponseData.getUserName()); | ||
Assertions.assertEquals(UserType.ADMIN_USER, getUserInfoResponseData.getUserType()); | ||
} | ||
|
||
@Test | ||
@Order(20) | ||
public void testAdminUserFilterLoginSuccess() { | ||
final String username = "admin_user03"; | ||
|
||
final String password = "123"; | ||
|
||
LoginPage loginPage = new LoginPage(); | ||
HttpResponse loginHttpResponse = loginPage.login(username, password); | ||
sessionId = | ||
JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); | ||
UserPage userPage = new UserPage(); | ||
HttpResponse getUserInfoHttpResponse = userPage.getUserInfo(sessionId); | ||
GetUserInfoResponseData getUserInfoResponseData = | ||
JSONUtils.convertValue(getUserInfoHttpResponse.getBody().getData(), GetUserInfoResponseData.class); | ||
Assertions.assertEquals(username, getUserInfoResponseData.getUserName()); | ||
Assertions.assertEquals(UserType.ADMIN_USER, getUserInfoResponseData.getUserType()); | ||
} | ||
|
||
@Test | ||
@Order(30) | ||
public void testGeneralUserLoginSuccess() { | ||
final String username = "general_user02"; | ||
|
||
final String password = "123"; | ||
|
||
LoginPage loginPage = new LoginPage(); | ||
HttpResponse loginHttpResponse = loginPage.login(username, password); | ||
sessionId = | ||
JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); | ||
UserPage userPage = new UserPage(); | ||
HttpResponse getUserInfoHttpResponse = userPage.getUserInfo(sessionId); | ||
GetUserInfoResponseData getUserInfoResponseData = | ||
JSONUtils.convertValue(getUserInfoHttpResponse.getBody().getData(), GetUserInfoResponseData.class); | ||
Assertions.assertEquals(username, getUserInfoResponseData.getUserName()); | ||
Assertions.assertEquals(UserType.GENERAL_USER, getUserInfoResponseData.getUserType()); | ||
} | ||
|
||
@Test | ||
@Order(40) | ||
public void testGeneralUserLoginFailed() { | ||
final String username = "general_user02"; | ||
|
||
final String password = "1"; | ||
|
||
LoginPage loginPage = new LoginPage(); | ||
HttpResponse loginHttpResponse = loginPage.login(username, password); | ||
Boolean loginResult = loginHttpResponse.getBody().getSuccess(); | ||
Assertions.assertFalse(loginResult); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...se/src/test/java/org/apache/dolphinscheduler/api/test/entity/GetUserInfoResponseData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.api.test.entity; | ||
|
||
import org.apache.dolphinscheduler.common.enums.UserType; | ||
|
||
import java.util.Date; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class GetUserInfoResponseData { | ||
|
||
private Integer id; | ||
private String userName; | ||
private String userPassword; | ||
private String email; | ||
private Integer phone; | ||
private UserType userType; | ||
private Integer tenantId; | ||
private Integer state; | ||
private String tenantCode; | ||
private String queueName; | ||
private String alertGroup; | ||
private String queue; | ||
private String timeZone; | ||
private Date createTime; | ||
private Date updateTime; | ||
} |
37 changes: 37 additions & 0 deletions
37
...test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/security/UserPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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.api.test.pages.security; | ||
|
||
import org.apache.dolphinscheduler.api.test.core.Constants; | ||
import org.apache.dolphinscheduler.api.test.entity.HttpResponse; | ||
import org.apache.dolphinscheduler.api.test.utils.RequestClient; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class UserPage { | ||
|
||
public HttpResponse getUserInfo(String sessionId) { | ||
Map<String, String> headers = new HashMap<>(); | ||
headers.put(Constants.SESSION_ID_KEY, sessionId); | ||
|
||
RequestClient requestClient = new RequestClient(); | ||
|
||
return requestClient.get("/users/get-user-info", headers, new HashMap<>()); | ||
} | ||
} |
Oops, something went wrong.