Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maintenance: Add getNewUserRequests, approveNewUserRequests, declineN… #2520

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 @@ -53,6 +53,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.jasypt.util.text.BasicTextEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -646,7 +647,7 @@ public ApiResponse addNewUser(UserInfoModel newUser, boolean isExternal) throws
} catch (Exception e1) {
log.error("Try deleting user");
}
if (e.getMessage().contains("should not exist")) {
if (StringUtils.isNotBlank(e.getMessage()) && e.getMessage().contains("should not exist")) {
return ApiResponse.notOk(TEAMS_ERR_110);
} else {
log.error("Error ", e);
Expand Down
33 changes: 33 additions & 0 deletions core/src/test/java/io/aiven/klaw/UtilMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.aiven.klaw.dao.KwKafkaConnector;
import io.aiven.klaw.dao.KwTenants;
import io.aiven.klaw.dao.MessageSchema;
import io.aiven.klaw.dao.RegisterUserInfo;
import io.aiven.klaw.dao.SchemaRequest;
import io.aiven.klaw.dao.ServiceAccounts;
import io.aiven.klaw.dao.Team;
Expand All @@ -37,6 +38,7 @@
import io.aiven.klaw.model.enums.KafkaFlavors;
import io.aiven.klaw.model.enums.KafkaSupportedProtocol;
import io.aiven.klaw.model.enums.MetadataOperationType;
import io.aiven.klaw.model.enums.NewUserStatus;
import io.aiven.klaw.model.enums.OperationalRequestType;
import io.aiven.klaw.model.enums.PermissionType;
import io.aiven.klaw.model.enums.RequestEntityType;
Expand Down Expand Up @@ -197,6 +199,37 @@ public List<UserInfoModelResponse> getUserInfoListModel(String username, String
return userInfoList;
}

public RegisterUserInfo getRegisterUserInfoMock(String newUserName, String pwd) {
RegisterUserInfo regUser = new RegisterUserInfo();
regUser.setUsername(newUserName);
regUser.setFullname("John Doe");
regUser.setStatus(NewUserStatus.PENDING.value);
regUser.setPwd(pwd);
regUser.setMailid("[email protected]");
regUser.setTeamId(TEST_TENANT_ID + 1);
regUser.setTenantId(TEST_TENANT_ID);
regUser.setRole("USER");
return regUser;
}

public List<RegisterUserInfo> getRegisterUserInfoList(
Map<Integer, String> tenantMapMock, int count, String usernamePrefix) {
List<RegisterUserInfo> userInfoList = new ArrayList<>();
for (int i = 0; i < count; i++) {
RegisterUserInfo userInfo = new RegisterUserInfo();
userInfo.setTeamId(i + 1);
userInfo.setUsername(usernamePrefix + i);
userInfo.setMailid(String.format("%[email protected]", userInfo.getUsername()));
userInfo.setStatus(NewUserStatus.PENDING.value);
userInfo.setTenantId(i + count);
userInfoList.add(userInfo);

tenantMapMock.put(userInfo.getTenantId(), String.format("tenant%s", userInfo.getTenantId()));
}

return userInfoList;
}

public Team getTeamDaoMock() {
ServiceAccounts serviceAccounts = new ServiceAccounts();
serviceAccounts.setNumberOfAllowedAccounts(-1);
Expand Down
Loading