Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Aiven-Open/klaw into offset-message
Browse files Browse the repository at this point in the history
  • Loading branch information
muralibasani committed Nov 16, 2023
2 parents d2e8ba3 + f67c060 commit 3b23da3
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion coral/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@tanstack/react-query-devtools": "^4.29.5",
"@tanstack/react-query-devtools": "^4.29.6",
"@testing-library/dom": "^9.3.1",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
Expand Down
8 changes: 4 additions & 4 deletions coral/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private List<AclRequestsResponseModel> getAclRequestsModels(
List<AclRequestsResponseModel> aclRequestsModels = new ArrayList<>();
AclRequestsResponseModel aclRequestsModel;

List<String> approverRoles =
Set<String> approverRoles =
rolesPermissionsControllerService.getApproverRoles("SUBSCRIPTIONS", tenantId);

if (aclReqs != null)
Expand Down Expand Up @@ -379,7 +379,7 @@ private String updateApprovingInfo(
String topicName,
RequestOperationType requestOperationType,
Integer team,
List<String> approverRoles,
Set<String> approverRoles,
String requester,
int tenantId) {
List<Topic> topicTeamsList = commonUtilsService.getTopicsForTopicName(topicName, tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ private List<KafkaConnectorRequestsResponseModel> getConnectorRequestModels(
Integer userTeamId = commonUtilsService.getTeamId(userName);

int tenantId = commonUtilsService.getTenantId(userName);
List<String> approverRoles =
Set<String> approverRoles =
rolesPermissionsControllerService.getApproverRoles("CONNECTORS", tenantId);
List<UserInfo> userList = manageDatabase.getUsersPerTeamAndTenant(userTeamId, tenantId);

Expand Down Expand Up @@ -1486,7 +1486,7 @@ private KafkaConnectorRequestsResponseModel setRequestorPermissions(
}

private String updateApproverInfo(
List<UserInfo> userList, String teamName, List<String> approverRoles, String requestor) {
List<UserInfo> userList, String teamName, Set<String> approverRoles, String requestor) {
StringBuilder approvingInfo = new StringBuilder("Team : " + teamName + ", Users : ");

for (UserInfo userInfo : userList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private List<OperationalRequestsResponseModel> getOperationalRequestModels(
Integer userTeamId = commonUtilsService.getTeamId(userName);

int tenantId = commonUtilsService.getTenantId(userName);
List<String> approverRoles =
Set<String> approverRoles =
rolesPermissionsControllerService.getApproverRoles("TOPICS", tenantId);
List<UserInfo> userList = manageDatabase.getUsersPerTeamAndTenant(userTeamId, tenantId);

Expand Down Expand Up @@ -353,7 +353,7 @@ private OperationalRequestsResponseModel setRequestorPermissions(
}

private String updateApproverInfo(
List<UserInfo> userList, String teamName, List<String> approverRoles, String requestor) {
List<UserInfo> userList, String teamName, Set<String> approverRoles, String requestor) {
StringBuilder approvingInfo = new StringBuilder("Team : " + teamName + ", Users : ");

for (UserInfo userInfo : userList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.aiven.klaw.model.enums.PermissionType;
import io.aiven.klaw.model.requests.KwRolesPermissionsModel;
import java.util.*;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.context.SecurityContextHolder;
Expand Down Expand Up @@ -225,9 +224,9 @@ private Object getPrincipal() {
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}

protected List<String> getApproverRoles(String requestType, int tenantId) {
protected Set<String> getApproverRoles(String requestType, int tenantId) {
Map<String, List<Map<String, Boolean>>> existingPermissions = getPermissions(false);
List<String> approverRoles = new ArrayList<>();
Set<String> approverRoles = new HashSet<>();
for (Map.Entry<String, List<Map<String, Boolean>>> permissionsListEntry :
existingPermissions.entrySet()) {
List<Map<String, Boolean>> entryDets = permissionsListEntry.getValue();
Expand Down Expand Up @@ -258,6 +257,6 @@ protected List<String> getApproverRoles(String requestType, int tenantId) {
}
}

return approverRoles.stream().distinct().collect(Collectors.toList());
return approverRoles;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public List<SchemaRequestsResponseModel> getSchemaRequests(
Integer userTeamId = commonUtilsService.getTeamId(userName);
List<UserInfo> userList = manageDatabase.getUsersPerTeamAndTenant(userTeamId, tenantId);

List<String> approverRoles =
Set<String> approverRoles =
rolesPermissionsControllerService.getApproverRoles("CONNECTORS", tenantId);
List<SchemaRequestsResponseModel> schemaRequestModels = new ArrayList<>();

Expand Down Expand Up @@ -166,7 +166,7 @@ private Comparator<SchemaRequestsResponseModel> getPreferredOrder(Order order) {
}

private String updateApproverInfo(
List<UserInfo> userList, String teamName, List<String> approverRoles, String requestor) {
List<UserInfo> userList, String teamName, Set<String> approverRoles, String requestor) {
StringBuilder approvingInfo = new StringBuilder("Team : " + teamName + ", Users : ");

for (UserInfo userInfo : userList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ private List<TopicRequestsResponseModel> getTopicRequestModels(List<TopicRequest
Integer userTeamId = commonUtilsService.getTeamId(userName);

int tenantId = commonUtilsService.getTenantId(userName);
List<String> approverRoles =
Set<String> approverRoles =
rolesPermissionsControllerService.getApproverRoles("TOPICS", tenantId);
List<UserInfo> userList = manageDatabase.getUsersPerTeamAndTenant(userTeamId, tenantId);

Expand Down Expand Up @@ -660,7 +660,7 @@ private void validateAndCopyTopicConfigs(
}

private String updateApproverInfo(
List<UserInfo> userList, String teamName, List<String> approverRoles, String requestor) {
List<UserInfo> userList, String teamName, Set<String> approverRoles, String requestor) {
StringBuilder approvingInfo = new StringBuilder("Team : " + teamName + ", Users : ");

for (UserInfo userInfo : userList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public void getAclRequestsFirstAndSecondPage() {
anyInt()))
.thenReturn(getAclRequests("testtopic", 15));
when(rolesPermissionsControllerService.getApproverRoles(anyString(), anyInt()))
.thenReturn(Collections.singletonList("USER"));
.thenReturn(Collections.singleton("USER"));
when(manageDatabase.getTeamNameFromTeamId(anyInt(), anyInt())).thenReturn(teamName);
when(commonUtilsService.getTopicsForTopicName(anyString(), anyInt())).thenReturn(topicList);
when(commonUtilsService.getFilteredTopicsForTenant(any())).thenReturn(topicList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void getSchemaRequests() {
eq(false)))
.thenReturn(getSchemasReqs());
when(rolesPermissionsControllerService.getApproverRoles(anyString(), anyInt()))
.thenReturn(List.of(""));
.thenReturn(Set.of(""));
when(commonUtilsService.getEnvsFromUserId(anyString()))
.thenReturn(new HashSet<>(Collections.singletonList("1")));
when(handleDbRequests.getAllUsersInfoForTeam(anyInt(), anyInt())).thenReturn(List.of(userInfo));
Expand Down Expand Up @@ -674,7 +674,7 @@ public void getListofSchemaRequestsIn_NEWEST_FIRST_ORDER() {
eq(false)))
.thenReturn(getSchemasReqs(40));
when(rolesPermissionsControllerService.getApproverRoles(anyString(), anyInt()))
.thenReturn(List.of(""));
.thenReturn(Set.of(""));
when(commonUtilsService.getEnvsFromUserId(anyString()))
.thenReturn(new HashSet<>(Collections.singletonList("1")));
when(handleDbRequests.getAllUsersInfoForTeam(anyInt(), anyInt())).thenReturn(List.of(userInfo));
Expand Down Expand Up @@ -721,7 +721,7 @@ public void getListofSchemaRequestsIn_OLDEST_FIRST_ORDER() {
eq(false)))
.thenReturn(getSchemasReqs(40));
when(rolesPermissionsControllerService.getApproverRoles(anyString(), anyInt()))
.thenReturn(List.of(""));
.thenReturn(Set.of(""));
when(commonUtilsService.getEnvsFromUserId(anyString()))
.thenReturn(new HashSet<>(Collections.singletonList("1")));
when(handleDbRequests.getAllUsersInfoForTeam(anyInt(), anyInt())).thenReturn(List.of(userInfo));
Expand All @@ -746,7 +746,7 @@ public void getListofSchemaRequestsIn_OLDEST_FIRST_ORDER() {
for (SchemaRequestsResponseModel req : ordered_response) {

// assert That each new Request time is newer than or equal to the previous request
assertThat(origReqTime.compareTo(req.getRequesttime()) <= 0).isTrue();
assertThat(origReqTime).isBeforeOrEqualTo(req.getRequesttime());
origReqTime = req.getRequesttime();
}
}
Expand Down

0 comments on commit 3b23da3

Please sign in to comment.