diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 72841b8..b67dfc6 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,3 +1,147 @@ +Kafkawize 4.4 + +1. Changes include improved User interface and few bug fixes. +2. Metadata Synchronize option has been removed +3. SSL connectivity to Kafka cluster has been removed +4. Dashboard updated to show logged in Username, Team and Role +5. Users can now only 4 environments DEV, TST, ACC and PRD. Hierarchy is defined in properties file. +6. New model for UserInfo class is introduced to fix a password bug +7. Password is not stored as encrypted text +8. Validations bug in acls and topics requests +9. Connect to Kafka clusters during start of Kafkawize +10. Menu colors are updated + +---------------------------------------------------------------- + Kafkawize 4.3 -Changes include improved User interface and few bug fixes. \ No newline at end of file +Changes include improved User interface and few bug fixes. + +---------------------------------------------------------------- + + +Kafkawize 4.2 + +Changes include +1. Critical bug fix - concurrent user access +1. Ability to have environments DEV, TST, ACC and PRD +2. Ability to request for topics in DTAP environments +3. Ability to view topic overview and subscriptions in one page +4. Ability to view topic partitions and replication factor of all environments in topic overview page +5. Ability to view topics and their existence in all environments +6. Updated dashboard to view your team topics + +---------------------------------------------------------------- + +Kafkawize 4.1 + +Changes include +1. New Bootstrap 4 User interface with new appealing look and feel +2. New UI/UX - for great user experience +3. Few bug fixes +1. Critical bug fix - concurrent user access + +---------------------------------------------------------------- + +Kafkawize 4.0 + + +Changes include +1. About 320 Unit tests. Above 85% code coverage. +2. Integration tests for both stores Cassandra and Rdbms, with EmbeddedCassandra and Embedded H2 sql database +3. New UI for viewing topics +4. New UI for viewing acls of topic +5. New UI for approving topics +6. New UI for approving acls +7. New UI for login screen +8. New UI for Dashboard, showing cluster api status and kafka cluster statuses +9. Added License key validation +10. Bug fixes and code enhancements + +There are several other changes and upgraded dependencies which improved the code quality and efficiency. +1. New Bootstrap 4 User interface with new appealing look and feel +2. New UX - for great user experience +3. Few bug fixes + + +---------------------------------------------------------------- + +Kafkawize 3.5 + +Changes include +1. New page (Admin-ServerConfig) to display server configuration - application properties +2. Default replication factor, default partitions and default max partitions can be configured from Clusters page. +3. Couple of minor bug fixes +1. About 320 Unit tests. Above 85% code coverage. +2. Integration tests for both stores Cassandra and Rdbms, with EmbeddedCassandra and Embedded H2 sql database +3. New UI for viewing topics +4. New UI for viewing acls of topic +5. New UI for approving topics +6. New UI for approving acls +7. New UI for login screen +8. New UI for Dashboard, showing cluster api status and kafka cluster statuses +9. Added License key validation +10. Bug fixes and code enhancements + +There are several other changes and upgraded dependencies which improved the code quality and efficiency. + + +---------------------------------------------------------------- + +Kafkawize 3.4 + +Changes include + +1. Decline Topic requests +2. Decline Acl requests +3. Bug fix in creating topic request +1. New page (Admin-ServerConfig) to display server configuration - application properties +2. Default replication factor, default partitions and default max partitions can be configured from Clusters page. +3. Couple of minor bug fixes + + +---------------------------------------------------------------- + +Kafkawize 3.3 + +Changes include search features in almost all screens, bug fixes and code improvements. +Changes include +1. Decline Topic requests +2. Decline Acl requests +3. Bug fix in creating topic request + +---------------------------------------------------------------- + +Kafkawize 3.2 + +Changes include search features in almost all screens, bug fixes and code improvements. + +---------------------------------------------------------------- + +Kafkawize 3.1 + +New features: +1. Support for RDBMS store like MySql to store meta information. 1.0 only supports Apache Cassandra. It is one of the important feature which will support many customers who already have an SQL based solution. +Changing property db.storetype=rdbms/cassandra will make the difference. + +Bug fixes: + +There are few bugs which are fixed in Topic requests, acls and schema registry modules. + +Changes include search features in almost all screens, bug fixes and code improvements. + +---------------------------------------------------------------- + +Kafkawize 2.0 + +Kafkawize is a Kafka Topic management tool (A Web application) which automates the process of creating and browsing Kafka components, by introducing roles/authorizations to users of various teams of an organization + +Changes include new feature Rdbms support for metastore, package restructuring, jpa/hibernate implementation, improved code quality and bug fixes. + +New features: +1. Support for RDBMS store like MySql to store meta information. 1.0 only supports Apache Cassandra. It is one of the important feature which will support many customers who already have an SQL based solution. +Changing property db.storetype=rdbms/cassandra will make the difference. + +Bug fixes: + +There are few bugs which are fixed in Topic requests, acls and schema registry modules. diff --git a/pom.xml b/pom.xml index 8e8e6c3..232cd70 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.kafkamgt.uiapi kafkawize - 4.3 + 4.4 jar diff --git a/screenshots/ActivityLog.JPG b/screenshots/ActivityLog.JPG index 902aa34..722b367 100644 Binary files a/screenshots/ActivityLog.JPG and b/screenshots/ActivityLog.JPG differ diff --git a/screenshots/AddCluster.JPG b/screenshots/AddCluster.JPG index d26a6cb..91ee204 100644 Binary files a/screenshots/AddCluster.JPG and b/screenshots/AddCluster.JPG differ diff --git a/screenshots/AddTeam.JPG b/screenshots/AddTeam.JPG index 2b531e8..c74787b 100644 Binary files a/screenshots/AddTeam.JPG and b/screenshots/AddTeam.JPG differ diff --git a/screenshots/AddUser.JPG b/screenshots/AddUser.JPG index 2fd76b1..5ffd8ae 100644 Binary files a/screenshots/AddUser.JPG and b/screenshots/AddUser.JPG differ diff --git a/screenshots/ApproveACL.JPG b/screenshots/ApproveACL.JPG index c4c509f..71581a9 100644 Binary files a/screenshots/ApproveACL.JPG and b/screenshots/ApproveACL.JPG differ diff --git a/screenshots/ApproveTopics.JPG b/screenshots/ApproveTopics.JPG index 90df9e9..aefd374 100644 Binary files a/screenshots/ApproveTopics.JPG and b/screenshots/ApproveTopics.JPG differ diff --git a/screenshots/BrowseTopics.JPG b/screenshots/BrowseTopics.JPG index 773ed3b..6f4f30b 100644 Binary files a/screenshots/BrowseTopics.JPG and b/screenshots/BrowseTopics.JPG differ diff --git a/screenshots/Dashboard.JPG b/screenshots/Dashboard.JPG index 934b5b9..27a8fe9 100644 Binary files a/screenshots/Dashboard.JPG and b/screenshots/Dashboard.JPG differ diff --git a/screenshots/Environments.JPG b/screenshots/Environments.JPG index 3b6a2f7..c6b4b5d 100644 Binary files a/screenshots/Environments.JPG and b/screenshots/Environments.JPG differ diff --git a/screenshots/Logout.JPG b/screenshots/Logout.JPG index 80cd323..e47f598 100644 Binary files a/screenshots/Logout.JPG and b/screenshots/Logout.JPG differ diff --git a/screenshots/MyAclRequests.JPG b/screenshots/MyAclRequests.JPG index 846e5ec..3832219 100644 Binary files a/screenshots/MyAclRequests.JPG and b/screenshots/MyAclRequests.JPG differ diff --git a/screenshots/MyTopicRequests.JPG b/screenshots/MyTopicRequests.JPG index 3bb0782..d1dd6d3 100644 Binary files a/screenshots/MyTopicRequests.JPG and b/screenshots/MyTopicRequests.JPG differ diff --git a/screenshots/RequestACL.JPG b/screenshots/RequestACL.JPG index 19d5ffc..6449cbd 100644 Binary files a/screenshots/RequestACL.JPG and b/screenshots/RequestACL.JPG differ diff --git a/screenshots/RequestSchema.JPG b/screenshots/RequestSchema.JPG index 9ad0495..675f296 100644 Binary files a/screenshots/RequestSchema.JPG and b/screenshots/RequestSchema.JPG differ diff --git a/screenshots/RequestTopic.JPG b/screenshots/RequestTopic.JPG index 3f2e000..df846b9 100644 Binary files a/screenshots/RequestTopic.JPG and b/screenshots/RequestTopic.JPG differ diff --git a/screenshots/ServerConfig.JPG b/screenshots/ServerConfig.JPG index 8b63b99..a202bd2 100644 Binary files a/screenshots/ServerConfig.JPG and b/screenshots/ServerConfig.JPG differ diff --git a/screenshots/SynchronizeAcls.JPG b/screenshots/SynchronizeAcls.JPG index e6fc27e..dcea231 100644 Binary files a/screenshots/SynchronizeAcls.JPG and b/screenshots/SynchronizeAcls.JPG differ diff --git a/screenshots/SynchronizeTopics.JPG b/screenshots/SynchronizeTopics.JPG index 5d5ccf5..59add57 100644 Binary files a/screenshots/SynchronizeTopics.JPG and b/screenshots/SynchronizeTopics.JPG differ diff --git a/screenshots/ViewAcls.JPG b/screenshots/ViewAcls.JPG index a6fd193..e87a9b8 100644 Binary files a/screenshots/ViewAcls.JPG and b/screenshots/ViewAcls.JPG differ diff --git a/screenshots/ViewTeams.JPG b/screenshots/ViewTeams.JPG index fabdc34..ae98658 100644 Binary files a/screenshots/ViewTeams.JPG and b/screenshots/ViewTeams.JPG differ diff --git a/screenshots/ViewUsers.JPG b/screenshots/ViewUsers.JPG index 9e47986..2e9c673 100644 Binary files a/screenshots/ViewUsers.JPG and b/screenshots/ViewUsers.JPG differ diff --git a/screenshots/login.JPG b/screenshots/login.JPG index ee947fb..1244187 100644 Binary files a/screenshots/login.JPG and b/screenshots/login.JPG differ diff --git a/src/main/java/com/kafkamgt/uiapi/config/ManageDatabase.java b/src/main/java/com/kafkamgt/uiapi/config/ManageDatabase.java index 3a073fc..7f2066f 100644 --- a/src/main/java/com/kafkamgt/uiapi/config/ManageDatabase.java +++ b/src/main/java/com/kafkamgt/uiapi/config/ManageDatabase.java @@ -6,11 +6,15 @@ import com.kafkamgt.uiapi.helpers.db.cassandra.HandleDbRequestsCassandra; import com.kafkamgt.uiapi.helpers.db.rdbms.HandleDbRequestsJdbc; import com.kafkamgt.uiapi.helpers.db.rdbms.JdbcDataSourceCondition; +import com.kafkamgt.uiapi.service.ClusterApiService; +import com.kafkamgt.uiapi.service.UtilService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; import javax.annotation.PostConstruct; import java.util.ArrayList; @@ -22,21 +26,33 @@ @Slf4j public class ManageDatabase { - @Value("${custom.db.storetype}") + @Value("${kafkawize.db.storetype}") private String dbStore; - @Value("${custom.envs.order}") + @Value("${kafkawize.envs.order}") private String orderOfEnvs; private HandleDbRequests handleDbRequests; public static HashMap>> envParamsMap; - @Value("${custom.org.name}") + @Autowired + private + UtilService utils; + + @Value("${kafkawize.invalidkey.msg}") + private + String invalidKeyMessage; + + @Value("${kafkawize.org.name}") private String orgName; + @Autowired + private + Environment environment; + @PostConstruct public void loadDb() throws Exception { @@ -45,13 +61,28 @@ public void loadDb() throws Exception { System.exit(0); } + HashMap licenseMap = utils.validateLicense(); + if(! (environment.getActiveProfiles().length >0 + && environment.getActiveProfiles()[0].equals("integrationtest"))) { + if (!licenseMap.get("LICENSE_STATUS").equals(Boolean.TRUE.toString())) { + log.info(invalidKeyMessage); + System.exit(0); + } + } + if (dbStore != null && dbStore.equals("rdbms")) { handleDbRequests = handleJdbc(); } else handleDbRequests = handleCassandra(); - handleDbRequests.connectToDb("licenseKey"); - loadEnvParams(); + if(UtilService.licenceLoaded) { + handleDbRequests.connectToDb("licenseKey"); + loadEnvParams(); + }else + { + log.info(invalidKeyMessage); + System.exit(0); + } } diff --git a/src/main/java/com/kafkamgt/uiapi/config/SecurityConfig.java b/src/main/java/com/kafkamgt/uiapi/config/SecurityConfig.java index 332def5..28f8261 100644 --- a/src/main/java/com/kafkamgt/uiapi/config/SecurityConfig.java +++ b/src/main/java/com/kafkamgt/uiapi/config/SecurityConfig.java @@ -4,6 +4,7 @@ import com.kafkamgt.uiapi.dao.UserInfo; import com.kafkamgt.uiapi.error.KafkawizeException; import com.kafkamgt.uiapi.service.UtilService; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +17,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.factory.PasswordEncoderFactories; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.provisioning.InMemoryUserDetailsManager; @@ -34,10 +34,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UtilService utils; - @Value("${custom.org.name}") + @Value("${kafkawize.org.name}") private String orgName; - @Value("${custom.invalidkey.msg}") + @Value("${kafkawize.invalidkey.msg}") private String invalidKeyMessage; @Autowired @@ -69,14 +69,22 @@ protected void configure(HttpSecurity http) throws Exception { public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder(); - List users = new ArrayList<>(); + List users ; if(orgName.equals("Your company name.")) { LOG.error("Invalid organization configured !!"); System.exit(0); throw new Exception("Invalid organization configured !!"); } - + if(! (environment.getActiveProfiles().length >0 + && environment.getActiveProfiles()[0].equals("integrationtest"))) { + HashMap licenseMap = utils.validateLicense(); + if (!licenseMap.get("LICENSE_STATUS").equals(Boolean.TRUE.toString())) { + LOG.error(invalidKeyMessage); + System.exit(0); + throw new Exception(invalidKeyMessage); + } + } try { users = manageTopics.selectAllUsersInfo(); }catch(Exception e){ @@ -93,17 +101,17 @@ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception userDetailsBuilder = auth.inMemoryAuthentication() .passwordEncoder(encoder) .withUser(userInfo.getUsername()) - .password(encoder.encode(userInfo.getPwd())) + .password(encoder.encode(base64DecodePwd((userInfo.getPwd())))) .roles(userInfo.getRole()); while(iter.hasNext()){ - userInfo = iter.next(); - userDetailsBuilder - .and() - .withUser(userInfo.getUsername()) - .password(encoder.encode(userInfo.getPwd())) - .roles(userInfo.getRole()); - } + userInfo = iter.next(); + userDetailsBuilder + .and() + .withUser(userInfo.getUsername()) + .password(encoder.encode(base64DecodePwd(userInfo.getPwd()))) + .roles(userInfo.getRole()); + } auth.userDetailsService(inMemoryUserDetailsManager()); } @@ -118,11 +126,15 @@ public InMemoryUserDetailsManager inMemoryUserDetailsManager() { PasswordEncoderFactories.createDelegatingPasswordEncoder(); while(iter.hasNext()){ userInfo = iter.next(); - globalUsers.put(userInfo.getUsername(),encoder.encode(userInfo.getPwd())+","+ + globalUsers.put(userInfo.getUsername(), + encoder.encode(base64DecodePwd(userInfo.getPwd()))+","+ userInfo.getRole()+",enabled"); } return new InMemoryUserDetailsManager(globalUsers); } + private String base64DecodePwd(String pwd){ + return new String(Base64.getDecoder().decode(pwd)); + } } diff --git a/src/main/java/com/kafkamgt/uiapi/controller/AclController.java b/src/main/java/com/kafkamgt/uiapi/controller/AclController.java index ef76aab..1a7e47d 100644 --- a/src/main/java/com/kafkamgt/uiapi/controller/AclController.java +++ b/src/main/java/com/kafkamgt/uiapi/controller/AclController.java @@ -32,11 +32,6 @@ public ResponseEntity createAcl(@RequestBody AclRequests addAclRequest) return new ResponseEntity<>(aclControllerService.createAcl(addAclRequest), HttpStatus.OK); } - @PostMapping(value = "/updateSyncAcls") - public ResponseEntity> updateSyncAcls(@RequestBody List syncAclUpdates) { - return new ResponseEntity<>(aclControllerService.updateSyncAcls(syncAclUpdates), HttpStatus.OK); - } - @RequestMapping(value = "/getAclRequests", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) public ResponseEntity> getAclRequests(@RequestParam("pageNo") String pageNo) { return new ResponseEntity<>(aclControllerService.getAclRequests(pageNo), HttpStatus.OK); @@ -67,11 +62,6 @@ public ResponseEntity getAcls(@RequestParam(value="topicnamesearc return new ResponseEntity<>(aclControllerService.getAcls(topicNameSearch), HttpStatus.OK); } - @RequestMapping(value = "/getSyncAcls", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) - public ResponseEntity> getSyncAcls(@RequestParam("env") String env, @RequestParam("pageNo") String pageNo, - @RequestParam(value="topicnamesearch", required=false) String topicNameSearch) throws KafkawizeException { - return new ResponseEntity<>(aclControllerService.getSyncAcls(env, pageNo, topicNameSearch), HttpStatus.OK); - } } diff --git a/src/main/java/com/kafkamgt/uiapi/controller/TopicController.java b/src/main/java/com/kafkamgt/uiapi/controller/TopicController.java index d6dd95c..c27d24c 100644 --- a/src/main/java/com/kafkamgt/uiapi/controller/TopicController.java +++ b/src/main/java/com/kafkamgt/uiapi/controller/TopicController.java @@ -28,12 +28,6 @@ public ResponseEntity createTopicsRequest(@RequestBody TopicRequest addT return new ResponseEntity<>(result, HttpStatus.OK); } - @PostMapping(value = "/updateSyncTopics") - public ResponseEntity> updateSyncTopics(@RequestBody List syncTopicUpdates) { - HashMap updateSyncTopicsResult = topicControllerService.updateSyncTopics(syncTopicUpdates); - return new ResponseEntity<>(updateSyncTopicsResult, HttpStatus.OK); - } - @RequestMapping(value = "/getTopicRequests", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) public ResponseEntity> getTopicRequests(@RequestParam("pageNo") String pageNo) { return new ResponseEntity<>(topicControllerService.getTopicRequests(pageNo), HttpStatus.OK); @@ -84,13 +78,4 @@ public ResponseEntity> getTopicsOnly() throws Exception { return new ResponseEntity<>(topicControllerService.getAllTopics(), HttpStatus.OK); } - @RequestMapping(value = "/getSyncTopics", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) - public ResponseEntity> getSyncTopics(@RequestParam("env") String env, @RequestParam("pageNo") String pageNo, - @RequestParam(value="topicnamesearch",required=false) String topicNameSearch) throws Exception { - - return new ResponseEntity<>(topicControllerService.getSyncTopics(env, pageNo, topicNameSearch), HttpStatus.OK); - } - - - } diff --git a/src/main/java/com/kafkamgt/uiapi/controller/UiConfigController.java b/src/main/java/com/kafkamgt/uiapi/controller/UiConfigController.java index 5226cdd..2de862e 100644 --- a/src/main/java/com/kafkamgt/uiapi/controller/UiConfigController.java +++ b/src/main/java/com/kafkamgt/uiapi/controller/UiConfigController.java @@ -2,6 +2,7 @@ import com.kafkamgt.uiapi.dao.*; import com.kafkamgt.uiapi.error.KafkawizeException; +import com.kafkamgt.uiapi.model.UserInfoModel; import com.kafkamgt.uiapi.service.UiConfigControllerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -9,7 +10,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; import java.util.HashMap; import java.util.List; @@ -31,6 +31,11 @@ public ResponseEntity> getEnvs() { return new ResponseEntity<>(uiConfigControllerService.getEnvs(true), HttpStatus.OK); } + @RequestMapping(value = "/getOtherEnvs", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) + public ResponseEntity> getOtherEnvs() { + return new ResponseEntity<>(uiConfigControllerService.getOtherEnvs(), HttpStatus.OK); + } + @RequestMapping(value = "/getEnvsOnly", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) public ResponseEntity> getEnvsOnly() { return new ResponseEntity<>(uiConfigControllerService.getEnvsOnly(true), HttpStatus.OK); @@ -121,7 +126,7 @@ public ResponseEntity changePwd(@RequestParam ("changePwd") String chang } @RequestMapping(value = "/showUserList", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) - public ResponseEntity> showUsers(){ + public ResponseEntity> showUsers(){ return new ResponseEntity<>(uiConfigControllerService.showUsers(), HttpStatus.OK); } diff --git a/src/main/java/com/kafkamgt/uiapi/controller/UiControllerLogin.java b/src/main/java/com/kafkamgt/uiapi/controller/UiControllerLogin.java index a80150a..81e7275 100644 --- a/src/main/java/com/kafkamgt/uiapi/controller/UiControllerLogin.java +++ b/src/main/java/com/kafkamgt/uiapi/controller/UiControllerLogin.java @@ -1,8 +1,13 @@ package com.kafkamgt.uiapi.controller; +import com.kafkamgt.uiapi.config.ManageDatabase; +import com.kafkamgt.uiapi.dao.UserInfo; +import com.kafkamgt.uiapi.helpers.HandleDbRequests; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Controller; @@ -13,8 +18,12 @@ @Controller public class UiControllerLogin { + @Autowired + ManageDatabase manageDatabase; + private static Logger LOG = LoggerFactory.getLogger(UiControllerLogin.class); + private static final String indexPage = "index"; private static final String defaultPage = "login.html"; private String checkAuth(String uri){ @@ -22,11 +31,21 @@ private String checkAuth(String uri){ UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if (userDetails != null) { + + HandleDbRequests reqsHandle = manageDatabase.getHandleDbRequests(); + UserInfo userInfo = reqsHandle.getUsersInfo(userDetails.getUsername()); + if(userInfo == null) + return defaultPage; + LOG.info("Authenticated..." + userDetails.getUsername()); + if(uri.equals(defaultPage) ) + return indexPage; return uri; } return defaultPage; }catch (Exception e){ + if(uri.equals(defaultPage) ) + return uri; return defaultPage; } } @@ -43,7 +62,7 @@ public String dashboard(ModelMap model) { @RequestMapping(value = "/login", method = RequestMethod.GET) public String login(ModelMap model) { - return checkAuth("index"); + return checkAuth("login.html"); } @RequestMapping(value = "/addUser", method = RequestMethod.GET) diff --git a/src/main/java/com/kafkamgt/uiapi/dao/Topic.java b/src/main/java/com/kafkamgt/uiapi/dao/Topic.java index d8a5a9f..6afcc62 100644 --- a/src/main/java/com/kafkamgt/uiapi/dao/Topic.java +++ b/src/main/java/com/kafkamgt/uiapi/dao/Topic.java @@ -43,7 +43,7 @@ public void setTopicname(String topicname) { } public String getEnvironment() { - if(this.topicPK == null) + if(this.environment != null) return this.environment; else return this.topicPK.getEnvironment(); diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/CassandraDataSourceCondition.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/CassandraDataSourceCondition.java index 25a50be..226ca1f 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/CassandraDataSourceCondition.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/CassandraDataSourceCondition.java @@ -13,7 +13,7 @@ public class CassandraDataSourceCondition implements Condition { public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) { Environment defaultEnv = conditionContext.getEnvironment(); - if(defaultEnv.getProperty("custom.db.storetype").equals("cassandra")) + if(defaultEnv.getProperty("kafkawize.db.storetype").equals("cassandra")) return true; else return false; diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/DeleteData.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/DeleteData.java index 286f7a4..a16dec5 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/DeleteData.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/DeleteData.java @@ -1,15 +1,11 @@ package com.kafkamgt.uiapi.helpers.db.cassandra; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Row; import com.datastax.driver.core.Session; import com.datastax.driver.core.querybuilder.Clause; import com.datastax.driver.core.querybuilder.Delete; import com.datastax.driver.core.querybuilder.QueryBuilder; -import com.datastax.driver.core.querybuilder.Select; import com.kafkamgt.uiapi.dao.Acl; -import com.kafkamgt.uiapi.dao.Topic; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -24,7 +20,7 @@ public class DeleteData { Session session; - @Value("${custom.cassandradb.keyspace:@null}") + @Value("${kafkawize.cassandradb.keyspace:@null}") String keyspace; public DeleteData(){} diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/HandleDbRequestsCassandra.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/HandleDbRequestsCassandra.java index a0da789..ab6b9a0 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/HandleDbRequestsCassandra.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/HandleDbRequestsCassandra.java @@ -41,19 +41,19 @@ public class HandleDbRequestsCassandra implements HandleDbRequests { private Cluster cluster; - @Value("${custom.cassandradb.url:@null}") + @Value("${kafkawize.cassandradb.url:@null}") private String clusterConnHost; - @Value("${custom.cassandradb.port:9042}") + @Value("${kafkawize.cassandradb.port:9042}") private int clusterConnPort; - @Value("${custom.cassandradb.keyspace:@null}") + @Value("${kafkawize.cassandradb.keyspace:@null}") private String keyspace; - @Value("${custom.dbscripts.execution:auto}") + @Value("${kafkawize.dbscripts.execution:auto}") private String dbScriptsExecution; - @Value("${custom.dbscripts.dropall_recreate:false}") + @Value("${kafkawize.dbscripts.dropall_recreate:false}") private String dbScriptsDropAllRecreate; public HandleDbRequestsCassandra(){ @@ -156,6 +156,7 @@ public String addToSyncacls(List acls) { return cassandraInsertHelper.insertIntoAclsSOT(acls,true); } + /*--------------------Select */ public HashMap getAllRequestsToBeApproved(String requestor, String role){ diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/InsertData.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/InsertData.java index 9d1fc65..ded48ac 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/InsertData.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/InsertData.java @@ -27,10 +27,10 @@ public class InsertData { private static BoundStatement boundStatementInsertIntoRequestTopic, boundStatementInsertIntoTopicSOT, boundStatementInsertIntoAclsSOT, boundStatementAclRequest, boundStatementInsertAclsSOT, boundStatementTopicsSOT, boundStatementInsertIntoActivityLogAcl, - boundStatementSchemaReqs, boundStatementSchemas, boundStatementUsers, boundStatementRegisterUsers, + boundStatementSchemaReqs, boundStatementSchemas, boundStatementUsers, boundStatementTeams, boundStatementEnvs; - @Value("${custom.cassandradb.keyspace:@null}") + @Value("${kafkawize.cassandradb.keyspace:@null}") private String keyspace; SelectData cassandraSelectHelper; diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/LoadDb.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/LoadDb.java index c679e5d..4045ab7 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/LoadDb.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/LoadDb.java @@ -21,7 +21,7 @@ public class LoadDb { private static String DROP_SQL = "scripts/base/cassandra/dropcassandra.sql"; - @Value("${custom.kafkawize.version:4.1}") + @Value("${kafkawize.version:4.4}") private String kafkawizeVersion; @Autowired diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/SelectData.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/SelectData.java index 1c3721e..1c55bee 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/SelectData.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/SelectData.java @@ -17,7 +17,6 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; @Component public class SelectData{ @@ -26,7 +25,7 @@ public class SelectData{ Session session; - @Value("${custom.cassandradb.keyspace:@null}") + @Value("${kafkawize.cassandradb.keyspace:@null}") String keyspace; public SelectData(){} @@ -46,7 +45,6 @@ public HashMap getAllRequestsToBeApproved(String requestor, Stri countList.put("acls",allAclReqs.size()+""); countList.put("schemas",allSchemaReqs.size()+""); - return countList; } diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/UpdateData.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/UpdateData.java index ae870c5..8055662 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/UpdateData.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/cassandra/UpdateData.java @@ -25,7 +25,7 @@ public class UpdateData { Session session; - @Value("${custom.cassandradb.keyspace:@null}") + @Value("${kafkawize.cassandradb.keyspace:@null}") String keyspace; @Autowired @@ -173,4 +173,24 @@ public String updateSchemaRequestDecline(SchemaRequest schemaRequest, String app return "success"; } + public String updateNewUserRequest(String username, String approver, boolean isApprove) { + String status ; + if(isApprove) + status = "APPROVED"; + else + status = "DECLINED"; + try { + Clause eqclause = QueryBuilder.eq("userid", username); + Update.Where updateQuery = QueryBuilder.update(keyspace, "registerusers") + .with(QueryBuilder.set("status", status)) + .and(QueryBuilder.set("approver", approver)) + .and(QueryBuilder.set("registeredtime", new Date())) + .where(eqclause); + session.execute(updateQuery); + + return "success"; + }catch (Exception e){ + return "failure"; + } + } } diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/DeleteDataJdbc.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/DeleteDataJdbc.java index cee132a..f7092ca 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/DeleteDataJdbc.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/DeleteDataJdbc.java @@ -1,6 +1,5 @@ package com.kafkamgt.uiapi.helpers.db.rdbms; -import com.google.common.collect.Lists; import com.kafkamgt.uiapi.dao.*; import com.kafkamgt.uiapi.repository.*; import org.slf4j.Logger; @@ -118,48 +117,13 @@ public String deleteTeamRequest(String teamId){ public String deletePrevAclRecs(List aclsToBeDeleted){ - List allAcls = Lists.newArrayList(aclRepo.findAll()); - for(Acl aclToBeDeleted :aclsToBeDeleted){ - for(Acl allAcl: allAcls) { - - if(aclToBeDeleted.getTopictype().equals("Producer")) { - if (aclToBeDeleted.getTopicname().equals(allAcl.getTopicname()) && - aclToBeDeleted.getTopictype().equals(allAcl.getTopictype()) && - aclToBeDeleted.getEnvironment().equals(allAcl.getEnvironment()) - ) { - if ((aclToBeDeleted.getAclip() != null && allAcl.getAclip() != null && - aclToBeDeleted.getAclip().equals(allAcl.getAclip())) || - (aclToBeDeleted.getAclssl() != null && allAcl.getAclssl() != null && - aclToBeDeleted.getAclssl().equals(allAcl.getAclssl()))) { - LOG.info("acl to be deleted" + allAcl); - aclRepo.delete(allAcl); - break; - } - - } - } - else if (aclToBeDeleted.getTopictype().equals("Consumer")) { - if (aclToBeDeleted.getTopicname().equals(allAcl.getTopicname()) && - aclToBeDeleted.getTopictype().equals(allAcl.getTopictype()) && - aclToBeDeleted.getConsumergroup().equals(allAcl.getConsumergroup()) && - aclToBeDeleted.getEnvironment().equals(allAcl.getEnvironment()) - ) { - if ((aclToBeDeleted.getAclip() != null && allAcl.getAclip() != null && - aclToBeDeleted.getAclip().equals(allAcl.getAclip())) || - (aclToBeDeleted.getAclssl() != null && allAcl.getAclssl() != null && - aclToBeDeleted.getAclssl().equals(allAcl.getAclssl()))) { - LOG.info("acl to be deleted" + allAcl); - aclRepo.delete(allAcl); - break; - } - - } - } + Optional acl = aclRepo.findById(aclToBeDeleted.getReq_no()); + if(acl.isPresent() && acl.get().getTopicname().equals(aclToBeDeleted.getTopicname())) { + aclRepo.delete(acl.get()); } } - return "success"; } diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/HandleDbRequestsJdbc.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/HandleDbRequestsJdbc.java index e2bcf3b..8ae62d9 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/HandleDbRequestsJdbc.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/HandleDbRequestsJdbc.java @@ -12,10 +12,10 @@ @Configuration public class HandleDbRequestsJdbc implements HandleDbRequests { - @Value("${custom.dbscripts.execution:auto}") + @Value("${kafkawize.dbscripts.execution:auto}") String dbScriptsExecution; - @Value("${custom.dbscripts.dropall_recreate:false}") + @Value("${kafkawize.dbscripts.dropall_recreate:false}") String dbScriptsDropAllRecreate; @Autowired diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/JdbcDataSourceCondition.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/JdbcDataSourceCondition.java index 49f2304..a974acf 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/JdbcDataSourceCondition.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/JdbcDataSourceCondition.java @@ -13,7 +13,7 @@ public class JdbcDataSourceCondition implements Condition { public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) { Environment defaultEnv = conditionContext.getEnvironment(); - if(defaultEnv.getProperty("custom.db.storetype").equals("rdbms")) + if(defaultEnv.getProperty("kafkawize.db.storetype").equals("rdbms")) return true; else return false; diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/LoadDbJdbc.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/LoadDbJdbc.java index 3a566aa..7d97f8b 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/LoadDbJdbc.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/LoadDbJdbc.java @@ -28,7 +28,7 @@ public class LoadDbJdbc { @Autowired(required=false) private JdbcTemplate jdbcTemplate; - @Value("${custom.kafkawize.version:4.1}") + @Value("${kafkawize.version:4.4}") private String kafkawizeVersion; @Autowired @@ -147,9 +147,7 @@ else if(tmpLine.toLowerCase().startsWith("insert") || tmpLine.toLowerCase().star try { jdbcTemplate.execute(execQuery.trim()); }catch (Exception sqlException){ - if(sqlException instanceof SQLIntegrityConstraintViolationException){ - //do nothing - }else throw sqlException; + throw sqlException; } execQuery = ""; } diff --git a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/UpdateDataJdbc.java b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/UpdateDataJdbc.java index 396ec78..b73bbc1 100644 --- a/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/UpdateDataJdbc.java +++ b/src/main/java/com/kafkamgt/uiapi/helpers/db/rdbms/UpdateDataJdbc.java @@ -125,8 +125,7 @@ public String declineAclRequest(AclRequests aclRequests, String approver){ public String updatePassword(String username, String password){ - UserInfo userInfo = new UserInfo(); - userInfo.setUsername(username); + UserInfo userInfo = userInfoRepo.findById(username).get(); userInfo.setPwd(password); userInfoRepo.save(userInfo); diff --git a/src/main/java/com/kafkamgt/uiapi/model/AclInfo.java b/src/main/java/com/kafkamgt/uiapi/model/AclInfo.java index a05f65c..00e02e8 100644 --- a/src/main/java/com/kafkamgt/uiapi/model/AclInfo.java +++ b/src/main/java/com/kafkamgt/uiapi/model/AclInfo.java @@ -21,4 +21,5 @@ public class AclInfo { private String totalNoPages; private List allPageNos; private List possibleTeams; + private boolean showDeleteAcl; } diff --git a/src/main/java/com/kafkamgt/uiapi/model/TopicInfo.java b/src/main/java/com/kafkamgt/uiapi/model/TopicInfo.java index 9566691..1c50826 100644 --- a/src/main/java/com/kafkamgt/uiapi/model/TopicInfo.java +++ b/src/main/java/com/kafkamgt/uiapi/model/TopicInfo.java @@ -15,4 +15,6 @@ public class TopicInfo { private String teamname; private String cluster; private List environmentsList; + private boolean showDeleteTopic; + private boolean topicDeletable; } diff --git a/src/main/java/com/kafkamgt/uiapi/model/TopicOverview.java b/src/main/java/com/kafkamgt/uiapi/model/TopicOverview.java index 8278966..3459b1c 100644 --- a/src/main/java/com/kafkamgt/uiapi/model/TopicOverview.java +++ b/src/main/java/com/kafkamgt/uiapi/model/TopicOverview.java @@ -2,11 +2,13 @@ import lombok.Data; +import java.util.HashMap; import java.util.List; @Data public class TopicOverview { List topicInfoList; List aclInfoList; + HashMap promotionDetails; boolean topicExists; } diff --git a/src/main/java/com/kafkamgt/uiapi/model/UserInfoModel.java b/src/main/java/com/kafkamgt/uiapi/model/UserInfoModel.java new file mode 100644 index 0000000..b2b3326 --- /dev/null +++ b/src/main/java/com/kafkamgt/uiapi/model/UserInfoModel.java @@ -0,0 +1,17 @@ +package com.kafkamgt.uiapi.model; + +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +@Getter +@Setter +public class UserInfoModel implements Serializable { + + private String username; + private String team; + private String role; + private String fullname; + private String mailid; +} diff --git a/src/main/java/com/kafkamgt/uiapi/service/AclControllerService.java b/src/main/java/com/kafkamgt/uiapi/service/AclControllerService.java index 5973d42..32dfb21 100644 --- a/src/main/java/com/kafkamgt/uiapi/service/AclControllerService.java +++ b/src/main/java/com/kafkamgt/uiapi/service/AclControllerService.java @@ -1,10 +1,7 @@ package com.kafkamgt.uiapi.service; import com.kafkamgt.uiapi.config.ManageDatabase; -import com.kafkamgt.uiapi.dao.Acl; -import com.kafkamgt.uiapi.dao.AclRequests; -import com.kafkamgt.uiapi.dao.Env; -import com.kafkamgt.uiapi.dao.Topic; +import com.kafkamgt.uiapi.dao.*; import com.kafkamgt.uiapi.error.KafkawizeException; import com.kafkamgt.uiapi.helpers.HandleDbRequests; import com.kafkamgt.uiapi.model.AclInfo; @@ -12,6 +9,7 @@ import com.kafkamgt.uiapi.model.TopicInfo; import com.kafkamgt.uiapi.model.TopicOverview; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; @@ -20,6 +18,8 @@ import java.util.*; import java.util.stream.Collectors; +import static org.springframework.beans.BeanUtils.copyProperties; + @Service public class AclControllerService { @@ -33,6 +33,12 @@ public class AclControllerService { private final ClusterApiService clusterApiService; + @Autowired + UiConfigControllerService uiConfigControllerService; + + @Value("${kafkawize.envs.order}") + private String orderOfEnvs; + AclControllerService(ClusterApiService clusterApiService, UtilService utilService){ this.clusterApiService = clusterApiService; this.utilService = utilService; @@ -48,69 +54,26 @@ public String createAcl(AclRequests aclReq) { return "{\"result\":\"Not Authorized\"}"; } - String execRes = manageDatabase.getHandleDbRequests().requestForAcl(aclReq); - - return "{\"result\":\""+execRes+"\"}"; - } - - public HashMap updateSyncAcls(List syncAclUpdates) { - UserDetails userDetails = getUserDetails(); - HashMap response = new HashMap<>(); - - if(!utilService.checkAuthorizedSU(userDetails)){ - response.put("result", "Not Authorized."); - return response; - } - - List listTopics = new ArrayList<>(); - Acl t; - - if(syncAclUpdates != null && syncAclUpdates.size() > 0){ - Set sequences = new HashSet<>(); - syncAclUpdates.forEach(updateItem ->sequences.add(updateItem.getSequence())); - HashMap stringSyncAclUpdatesHashMap = new HashMap<>(); + if(aclReq.getAcl_ssl() == null || aclReq.getAcl_ssl().equals("null")) + aclReq.setAcl_ssl("User:*"); - // remove duplicates - for(SyncAclUpdates syncAclUpdateItem: syncAclUpdates){ - if(stringSyncAclUpdatesHashMap.containsKey(syncAclUpdateItem.getSequence())){ - stringSyncAclUpdatesHashMap.remove(syncAclUpdateItem.getSequence()); - stringSyncAclUpdatesHashMap.put(syncAclUpdateItem.getSequence(), syncAclUpdateItem); - } - else - stringSyncAclUpdatesHashMap.put(syncAclUpdateItem.getSequence(), syncAclUpdateItem); + List topics = manageDatabase.getHandleDbRequests().getTopics(aclReq.getTopicname()); + boolean topicFound = false; + for (Topic topic : topics) { + if (topic.getEnvironment().equals(aclReq.getEnvironment())) + { + topicFound = true; + break; } + } - for (Map.Entry stringSyncAclUpdatesEntry : stringSyncAclUpdatesHashMap.entrySet()) { - SyncAclUpdates syncAclUpdateItem = stringSyncAclUpdatesEntry.getValue(); - - t = new Acl(); - - t.setReq_no(syncAclUpdateItem.getReq_no()); - t.setTopicname(syncAclUpdateItem.getTopicName()); - t.setConsumergroup(syncAclUpdateItem.getConsumerGroup()); - t.setAclip(syncAclUpdateItem.getAclIp()); - t.setAclssl(syncAclUpdateItem.getAclSsl()); - t.setTeamname(syncAclUpdateItem.getTeamSelected()); - t.setEnvironment(syncAclUpdateItem.getEnvSelected()); - t.setTopictype(syncAclUpdateItem.getAclType()); + String result = "Failure : Topic not found on target environment."; + if(!topicFound) + return "{\"result\":\""+result+"\"}"; - listTopics.add(t); - } - } - else - { - response.put("result", "No record updated."); - return response; - } + String execRes = manageDatabase.getHandleDbRequests().requestForAcl(aclReq); - try{ - if(listTopics.size()>0){ - response.put("result", manageDatabase.getHandleDbRequests().addToSyncacls(listTopics)); - } - }catch(Exception e){ - response.put("result", "Failure." + e.toString()); - } - return response; + return "{\"result\":\""+execRes+"\"}"; } public List getAclRequests(String pageNo) { @@ -199,6 +162,7 @@ public String deleteAclRequests(String req_no) { } } + public String approveAclRequests(String req_no) throws KafkawizeException { UserDetails userDetails = getUserDetails(); if(!utilService.checkAuthorizedAdmin_SU(userDetails)) @@ -219,6 +183,7 @@ public String approveAclRequests(String req_no) throws KafkawizeException { }catch(Exception e){ return "{\"result\":\"failure "+e.toString()+"\"}"; } + return "{\"result\":\""+updateAclReqStatus+"\"}"; } else @@ -246,9 +211,9 @@ public String declineAclRequests(String req_no) { return "{\"result\":\"Record not found !\"}"; } - private List> getAclListFromCluster(String bootstrapHost, boolean isSyncAcls, String topicNameSearch) throws KafkawizeException { + private List> getAclListFromCluster(String bootstrapHost, String protocol, boolean isSyncAcls, String topicNameSearch) throws KafkawizeException { List> aclList ; - aclList = clusterApiService.getAcls(bootstrapHost); + aclList = clusterApiService.getAcls(bootstrapHost, protocol); if(isSyncAcls) return updateConsumerGroups(groupAcls(aclList, topicNameSearch, true), aclList); else @@ -312,6 +277,57 @@ private List getAclsFromSOT(String env, String topicNameSearch, boolean reg return aclsFromSOT; } + + class TopicEnvComparator implements Comparator { + List orderedEnv = Arrays.asList(orderOfEnvs.split(",")); + + @Override + public int compare(String topicEnv1, String topicEnv2) { + if(orderedEnv.indexOf(topicEnv1) > orderedEnv.indexOf(topicEnv2)) + return 1; + else + return -1; + } + } + + public HashMap getTopicPromotionEnv(String topicSearch, List topics) + { + HashMap hashMap = new HashMap<>(); + try { + if(topics == null) + topics = manageDatabase.getHandleDbRequests().getTopics(topicSearch); + + hashMap.put("topicName", topicSearch); + + if (topics != null && topics.size() > 0) { + List envList = new ArrayList<>(); + List finalEnvList = envList; + topics.forEach(topic -> finalEnvList.add(topic.getEnvironment())); + envList = finalEnvList; + envList = envList.stream().sorted(new TopicEnvComparator()).collect(Collectors.toList()); + + String lastEnv = envList.get(envList.size() - 1); + List orderdEnvs = Arrays.asList(orderOfEnvs.split(",")); + + if (orderdEnvs.indexOf(lastEnv) == orderdEnvs.size() - 1) { + hashMap.put("status", "NO_PROMOTION"); // PRD + } else { + hashMap.put("status", "success"); + hashMap.put("sourceEnv", lastEnv); + String targetEnv = orderdEnvs.get(orderdEnvs.indexOf(lastEnv) + 1); + hashMap.put("targetEnv", targetEnv); + } + + return hashMap; + } + }catch (Exception e){ + hashMap.put("status","failure"); + hashMap.put("error","Topic does not exist in any environment."); + } + + return hashMap; + } + public TopicOverview getAcls(String topicNameSearch) throws KafkawizeException { UserDetails userDetails = getUserDetails(); HandleDbRequests handleDb = manageDatabase.getHandleDbRequests(); @@ -346,6 +362,7 @@ public TopicOverview getAcls(String topicNameSearch) throws KafkawizeException { List aclInfo = new ArrayList<>(); List tmpAcl; + for (TopicInfo topicInfo : topicInfoList) { aclsFromSOT.addAll(getAclsFromSOT(topicInfo.getCluster(), topicNameSearch, false)); @@ -360,27 +377,31 @@ public TopicOverview getAcls(String topicNameSearch) throws KafkawizeException { aclInfo = aclInfo.stream().distinct().collect(Collectors.toList()); topicOverview.setAclInfoList(aclInfo); topicOverview.setTopicInfoList(topicInfoList); - return topicOverview; - } - - public List getSyncAcls(String env, String pageNo, String topicNameSearch) throws KafkawizeException { - UserDetails userDetails = getUserDetails(); - if(topicNameSearch != null) - topicNameSearch = topicNameSearch.trim(); - - if(!utilService.checkAuthorizedSU(userDetails)) - return null; - List> aclList; - - Env envSelected= manageDatabase.getHandleDbRequests().selectEnvDetails(env); - String bootstrapHost=envSelected.getHost()+":"+envSelected.getPort(); - aclList = getAclListFromCluster(bootstrapHost, true, topicNameSearch); + try { + String topicOwnerTeam = handleDb.getTopicTeam(topicNameSearch).get(0).getTeamname(); - List aclsFromSOT = getAclsFromSOT(env, topicNameSearch, true); + if (topicOwnerTeam.equals(loggedInUserTeam)) { + topicOverview.setPromotionDetails(getTopicPromotionEnv(topicNameSearch, topics)); - topicCounter = 0; - return getAclsList(pageNo,applyFiltersAcls(env, aclList, aclsFromSOT, true)); + if(topicInfoList.size() > 0) + { + TopicInfo lastItem = topicInfoList.get(topicInfoList.size()-1); + lastItem.setTopicDeletable(aclInfo.stream() + .noneMatch(aclItem -> aclItem.getEnvironment().equals(lastItem.getCluster()))); + lastItem.setShowDeleteTopic(true); + } + } else { + HashMap hashMap = new HashMap<>(); + hashMap.put("status", "not_authorized"); + topicOverview.setPromotionDetails(hashMap); + } + }catch (Exception e){ + HashMap hashMap = new HashMap<>(); + hashMap.put("status", "not_authorized"); + topicOverview.setPromotionDetails(hashMap); + } + return topicOverview; } private List applyFiltersAclsForSOT(String loggedInUserTeam, List aclsFromSOT){ @@ -399,6 +420,8 @@ private List applyFiltersAclsForSOT(String loggedInUserTeam, List mp.setConsumergroup(aclSotItem.getConsumergroup()); mp.setTopictype(aclSotItem.getTopictype()); mp.setReq_no(aclSotItem.getReq_no()); + if(aclSotItem.getTeamname()!=null && aclSotItem.getTeamname().equals(loggedInUserTeam)) + mp.setShowDeleteAcl(true); if(aclSotItem.getAclip()!=null || aclSotItem.getAclssl()!=null) aclList.add(mp); @@ -454,7 +477,7 @@ else if(tmpPermType.equals("READ")){ if(acl_ssl==null || acl_ssl.equals("")) acl_ssl="User:*"; else { - if(!acl_ssl.equals("User:*")){ + if(!acl_ssl.equals("User:*") && !acl_ssl.startsWith("User:")){ acl_ssl = "User:" + acl_ssl; } } diff --git a/src/main/java/com/kafkamgt/uiapi/service/ClusterApiService.java b/src/main/java/com/kafkamgt/uiapi/service/ClusterApiService.java index c349801..695fbc2 100644 --- a/src/main/java/com/kafkamgt/uiapi/service/ClusterApiService.java +++ b/src/main/java/com/kafkamgt/uiapi/service/ClusterApiService.java @@ -30,13 +30,13 @@ public class ClusterApiService { @Autowired private final UtilService utilService; - @Value("${custom.clusterapi.url}") + @Value("${kafkawize.clusterapi.url}") private String clusterConnUrl; - @Value("${custom.clusterapi.username}") + @Value("${kafkawize.clusterapi.username}") private String clusterApiUser; - @Value("${custom.clusterapi.password}") + @Value("${kafkawize.clusterapi.password}") private String clusterApiPwd; public ClusterApiService(UtilService utilService){ @@ -90,12 +90,12 @@ String getSchemaClusterStatus(String host) { return clusterStatus; } - String getKafkaClusterStatus(String bootstrapHost) { + String getKafkaClusterStatus(String bootstrapHost, String protocol) { String clusterStatus ; try { String URI_ENV_STATUS = "/topics/getStatus/"; - String uri = clusterConnUrl + URI_ENV_STATUS + bootstrapHost; + String uri = clusterConnUrl + URI_ENV_STATUS + bootstrapHost + "/"+protocol; RestTemplate restTemplate = utilService.getRestTemplate(); HttpHeaders headers = createHeaders(clusterApiUser, clusterApiPwd); @@ -113,11 +113,11 @@ String getKafkaClusterStatus(String bootstrapHost) { return clusterStatus; } - public List> getAcls(String bootstrapHost) throws KafkawizeException { + public List> getAcls(String bootstrapHost, String protocol) throws KafkawizeException { List> aclListOriginal; try { String URI_GET_ACLS = "/topics/getAcls/"; - String uri = clusterConnUrl + URI_GET_ACLS + bootstrapHost; + String uri = clusterConnUrl + URI_GET_ACLS + bootstrapHost + "/"+protocol; RestTemplate restTemplate = utilService.getRestTemplate(); HttpHeaders headers = createHeaders(clusterApiUser, clusterApiPwd); @@ -135,11 +135,11 @@ public List> getAcls(String bootstrapHost) throws Kafkawi return aclListOriginal; } - public List> getAllTopics(String bootstrapHost) throws Exception{ + public List> getAllTopics(String bootstrapHost, String protocol) throws Exception{ List> topicsList ; try { String URI_GET_TOPICS = "/topics/getTopics/"; - String uriGetTopicsFull = clusterConnUrl + URI_GET_TOPICS + bootstrapHost; + String uriGetTopicsFull = clusterConnUrl + URI_GET_TOPICS + bootstrapHost + "/"+protocol; RestTemplate restTemplate = utilService.getRestTemplate(); HttpHeaders headers = createHeaders(clusterApiUser, clusterApiPwd); @@ -169,13 +169,19 @@ public ResponseEntity approveTopicRequests(String topicName, TopicReques Env envSelected = manageDatabase.getHandleDbRequests().selectEnvDetails(topicRequest.getEnvironment()); String bootstrapHost = envSelected.getHost() + ":" + envSelected.getPort(); params.add("env", bootstrapHost); + params.add("protocol", envSelected.getProtocol()); params.add("topicName", topicName); String URI_CREATE_TOPICS = "/topics/createTopics"; + String URI_DELETE_TOPICS = "/topics/deleteTopics"; String uri; - uri = clusterConnUrl + URI_CREATE_TOPICS; - params.add("partitions", topicRequest.getTopicpartitions()); - params.add("rf", topicRequest.getReplicationfactor()); + if(topicRequest.getTopictype().equals("Create")) { + uri = clusterConnUrl + URI_CREATE_TOPICS; + params.add("partitions", topicRequest.getTopicpartitions()); + params.add("rf", topicRequest.getReplicationfactor()); + } + else + uri = clusterConnUrl + URI_DELETE_TOPICS; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); @@ -197,8 +203,12 @@ public ResponseEntity approveAclRequests(AclRequests aclReq) throws Kafk String uri; String URI_CREATE_ACLS = "/topics/createAcls"; + String URI_DELETE_ACLS = "/topics/deleteAcls"; - uri = clusterConnUrl + URI_CREATE_ACLS; + if(aclReq.getAclType().equals("Create")) + uri = clusterConnUrl + URI_CREATE_ACLS; + else + uri = clusterConnUrl + URI_DELETE_ACLS; RestTemplate restTemplate = utilService.getRestTemplate(); @@ -207,6 +217,7 @@ public ResponseEntity approveAclRequests(AclRequests aclReq) throws Kafk Env envSelected = manageDatabase.getHandleDbRequests().selectEnvDetails(env); String bootstrapHost = envSelected.getHost() + ":" + envSelected.getPort(); params.add("env", bootstrapHost); + params.add("protocol", envSelected.getProtocol()); params.add("topicName", aclReq.getTopicname()); params.add("consumerGroup", aclReq.getConsumergroup()); params.add("aclType", aclReq.getTopictype()); diff --git a/src/main/java/com/kafkamgt/uiapi/service/ServerConfigService.java b/src/main/java/com/kafkamgt/uiapi/service/ServerConfigService.java index a060247..00476e7 100644 --- a/src/main/java/com/kafkamgt/uiapi/service/ServerConfigService.java +++ b/src/main/java/com/kafkamgt/uiapi/service/ServerConfigService.java @@ -44,7 +44,7 @@ public void getAllProperties() { ServerConfigProperties props = new ServerConfigProperties(); props.setKey(key); - if(key.contains("password") || key.contains("license")) + if(key.contains("password") || key.contains("license") || key.contains("path")) props.setValue("*******"); else props.setValue(WordUtils.wrap(propertySource.getProperty(key)+"",125,"\n",true)); diff --git a/src/main/java/com/kafkamgt/uiapi/service/TopicControllerService.java b/src/main/java/com/kafkamgt/uiapi/service/TopicControllerService.java index 9d53a4e..fb13804 100644 --- a/src/main/java/com/kafkamgt/uiapi/service/TopicControllerService.java +++ b/src/main/java/com/kafkamgt/uiapi/service/TopicControllerService.java @@ -3,7 +3,6 @@ import com.kafkamgt.uiapi.config.ManageDatabase; import com.kafkamgt.uiapi.dao.Env; import com.kafkamgt.uiapi.dao.Topic; -import com.kafkamgt.uiapi.dao.TopicPK; import com.kafkamgt.uiapi.dao.TopicRequest; import com.kafkamgt.uiapi.error.KafkawizeException; import com.kafkamgt.uiapi.helpers.HandleDbRequests; @@ -24,10 +23,10 @@ @Slf4j public class TopicControllerService { - @Value("${custom.syncdata.cluster:DEV}") + @Value("${kafkawize.syncdata.cluster:DEV}") private String syncCluster; - @Value("${custom.envs.order}") + @Value("${kafkawize.envs.order}") private String orderOfEnvs; @Autowired @@ -59,7 +58,7 @@ public String createTopicsRequest(TopicRequest topicRequestReq) throws Kafkawize topicRequestReq.setRequestor(userDetails.getUsername()); topicRequestReq.setUsername(userDetails.getUsername()); - topicRequestReq.setTopictype("Create"); // Possible options Create/Delete + topicRequestReq.setTopictype("Create"); String topicPartitions = topicRequestReq.getTopicpartitions(); @@ -152,103 +151,6 @@ else if(topicPartitionsInt > 0) return true; } - public HashMap updateSyncTopics(List updatedSyncTopics) { - UserDetails userDetails = getUserDetails(); - HashMap response = new HashMap<>(); - - if(!utilService.checkAuthorizedSU(userDetails)){ - response.put("result", "Not Authorized."); - return response; - } - - List existingTopics ; - List listTopics = new ArrayList<>(); - Topic t; - - String erroredTopics = ""; - boolean topicsWithDiffTeams = false; - - String erroredTopicsExist = ""; - boolean topicsDontExistInMainCluster = false; - - if(updatedSyncTopics!=null && updatedSyncTopics.size() > 0){ - Set sequences = new HashSet<>(); - updatedSyncTopics.forEach(updateItem ->sequences.add(updateItem.getSequence())); - HashMap stringSyncTopicUpdatesHashMap = new HashMap<>(); - - // remove duplicates - for(SyncTopicUpdates syncTopicUpdateItem: updatedSyncTopics){ - if(stringSyncTopicUpdatesHashMap.containsKey(syncTopicUpdateItem.getSequence())){ - stringSyncTopicUpdatesHashMap.remove(syncTopicUpdateItem.getSequence()); - stringSyncTopicUpdatesHashMap.put(syncTopicUpdateItem.getSequence(), syncTopicUpdateItem); - } - else - stringSyncTopicUpdatesHashMap.put(syncTopicUpdateItem.getSequence(), syncTopicUpdateItem); - } - - for(Map.Entry stringSyncAclUpdatesEntry : stringSyncTopicUpdatesHashMap.entrySet()){ - SyncTopicUpdates topicUpdate = stringSyncAclUpdatesEntry.getValue(); - - existingTopics = getTopicFromName(topicUpdate.getTopicName()); - - if(existingTopics != null){ - for (Topic existingTopic : existingTopics) { - if(existingTopic.getEnvironment().equals(syncCluster)){ - if(!existingTopic.getTeamname().equals(topicUpdate.getTeamSelected()) && - !topicUpdate.getEnvSelected().equals(syncCluster)) - { - erroredTopics += topicUpdate.getTopicName() + " "; - topicsWithDiffTeams = true; - } - break; - } - } - } - else if(!topicUpdate.getEnvSelected().equals(syncCluster)){ - erroredTopicsExist += topicUpdate.getTopicName() + " "; - topicsDontExistInMainCluster = true; - } - - t = new Topic(); - - TopicPK topicPK = new TopicPK(); - topicPK.setTopicname(topicUpdate.getTopicName()); - topicPK.setEnvironment(topicUpdate.getEnvSelected()); - - t.setTopicname(topicUpdate.getTopicName()); - t.setNoOfPartitions(topicUpdate.getPartitions()); - t.setNoOfReplcias(topicUpdate.getReplicationFactor()); - t.setEnvironment(topicUpdate.getEnvSelected()); - t.setTeamname(topicUpdate.getTeamSelected()); - t.setTopicPK(topicPK); - - listTopics.add(t); - } - } - - if(topicsDontExistInMainCluster){ - response.put("result", "Failure. Please sync up the team of the following topic(s) first in" + - " main Sync cluster (custom.syncdata.cluster)" + - " :" + syncCluster + ". \n Topics : " + erroredTopicsExist); - return response; - } - - if(topicsWithDiffTeams) { - response.put("result", "Failure. The following topics are being synchronized with" + - " a different team, when compared to main Sync cluster (custom.syncdata.cluster)" + - " :" + syncCluster + ". \n Topics : " + erroredTopics); - return response; - } - - if(listTopics.size()>0){ - response.put("result", manageDatabase.getHandleDbRequests().addToSynctopics(listTopics)); - } - else - response.put("result", "No record updated."); - - return response; - } - public List getTopicRequests(String pageNo) { UserDetails userDetails = getUserDetails(); List topicReqs = manageDatabase.getHandleDbRequests().getAllTopicRequests(userDetails.getUsername()); @@ -360,6 +262,7 @@ public String approveTopicRequests(String topicName, String env) throws Kafkawiz if(Objects.equals(response.getBody(), "success")) updateTopicReqStatus = dbHandle.updateTopicRequest(topicRequest, userDetails.getUsername()); + return "{\"result\":\""+updateTopicReqStatus+"\"}"; } @@ -469,36 +372,6 @@ private List> getPagedList(List topicsList){ return newList; } - public List getSyncTopics(String env, String pageNo, String topicNameSearch) throws Exception { - UserDetails userDetails = getUserDetails(); - - if(topicNameSearch != null) - topicNameSearch = topicNameSearch.trim(); - - Env envSelected= manageDatabase.getHandleDbRequests().selectEnvDetails(env); - String bootstrapHost=envSelected.getHost()+":"+envSelected.getPort(); - - List> topicsList = clusterApiService.getAllTopics(bootstrapHost); - //getTopicsListMap(clusterApiService.getAllTopics(bootstrapHost)); - - topicCounter = 0; - - List> topicFilteredList = topicsList; - // Filter topics on topic name for search - - if(topicNameSearch!=null && topicNameSearch.length()>0){ - final String topicSearchFilter = topicNameSearch; - topicFilteredList = topicsList.stream().filter(topic-> { - return topic.get("topicName").contains(topicSearchFilter); - } - ).collect(Collectors.toList()); - } - - topicsList = topicFilteredList.stream().sorted(new TopicNameSyncComparator()).collect(Collectors.toList()); - - return getSyncTopicList(topicsList,userDetails,pageNo,env); - } - private int counterIncrement() { topicCounter++; @@ -629,6 +502,8 @@ private List getSyncTopicList(List> topics return topicsListMap; } + + private UserDetails getUserDetails(){ return (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); } diff --git a/src/main/java/com/kafkamgt/uiapi/service/UiConfigControllerService.java b/src/main/java/com/kafkamgt/uiapi/service/UiConfigControllerService.java index d7f8674..7333d82 100644 --- a/src/main/java/com/kafkamgt/uiapi/service/UiConfigControllerService.java +++ b/src/main/java/com/kafkamgt/uiapi/service/UiConfigControllerService.java @@ -1,11 +1,10 @@ package com.kafkamgt.uiapi.service; import com.kafkamgt.uiapi.config.ManageDatabase; -import com.kafkamgt.uiapi.dao.ActivityLog; -import com.kafkamgt.uiapi.dao.Env; -import com.kafkamgt.uiapi.dao.Team; -import com.kafkamgt.uiapi.dao.UserInfo; +import com.kafkamgt.uiapi.dao.*; import com.kafkamgt.uiapi.helpers.HandleDbRequests; +import com.kafkamgt.uiapi.model.UserInfoModel; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.json.GsonJsonParser; @@ -18,19 +17,24 @@ import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; import java.util.*; import java.util.stream.Collectors; +import static org.springframework.beans.BeanUtils.copyProperties; + + @Service +@Slf4j public class UiConfigControllerService { - @Value("${custom.syncdata.cluster:DEV}") + @Value("${kafkawize.syncdata.cluster:DEV}") private String syncCluster; - @Value("${custom.request.topics.envs}") + @Value("${kafkawize.request.topics.envs}") private String requestTopicsEnvs; - @Value("${custom.envs.order}") + @Value("${kafkawize.envs.order}") private String orderOfEnvs; @Autowired @@ -57,6 +61,12 @@ public void setServices(ClusterApiService clusterApiService, UtilService utilSer this.utilService = utilService; } + @PostConstruct + public void initialLoadClusters(){ + log.info("Loading clusters"); + getEnvs(false); + } + public Env getClusterApiStatus(){ Env env = new Env(); env.setHost(clusterApiService.getClusterApiUrl()); @@ -123,6 +133,29 @@ public List getEnvsBaseCluster() { return Arrays.asList(requestTopicsEnvs.split(",")); } + public List getOtherEnvs() { + + List orderedEnv = Arrays.asList(orderOfEnvs.split(",")); + List listEnvs = manageDatabase.getHandleDbRequests().selectAllKafkaEnvs(); + + List newList = new ArrayList(); + boolean envFound; + + for (String env : orderedEnv) { + envFound = false; + for (Env listEnv : listEnvs) { + if(env.equals(listEnv.getName())) { + envFound = true; + break; + } + } + if(!envFound) + newList.add(env); + } + + return newList; + } + public List getEnvs(boolean envStatus) { List listEnvs = manageDatabase.getHandleDbRequests().selectAllKafkaEnvs(); @@ -133,10 +166,8 @@ public List getEnvs(boolean envStatus) { List newListEnvs = new ArrayList<>(); for(Env oneEnv: listEnvs){ String status; - if(oneEnv.getProtocol().equalsIgnoreCase("plain")) - status = clusterApiService.getKafkaClusterStatus(oneEnv.getHost()+":"+oneEnv.getPort()); - else - status = "NOT_KNOWN"; + status = clusterApiService.getKafkaClusterStatus(oneEnv.getHost()+":"+oneEnv.getPort(), + oneEnv.getProtocol()); oneEnv.setEnvStatus(status); newListEnvs.add(oneEnv); } @@ -157,7 +188,7 @@ public List getSchemaRegEnvsStatus() { List newListEnvs = new ArrayList<>(); for(Env oneEnv: listEnvs){ String status = null; - if (oneEnv.getProtocol().equalsIgnoreCase("plain")) + if (oneEnv.getProtocol().equalsIgnoreCase("plaintext")) status = clusterApiService.getSchemaClusterStatus(oneEnv.getHost() + ":" + oneEnv.getPort()); else status = "NOT_KNOWN"; @@ -256,6 +287,8 @@ public String deleteUser(String userId){ if(userId.equals("superuser") || userDetails.getUsername().equals(userId)) return envAddResult; + inMemoryUserDetailsManager.deleteUser(User.withUsername(userId).toString()); + try { return "{\"result\":\""+manageDatabase.getHandleDbRequests().deleteUserRequest(userId)+"\"}"; }catch (Exception e){ @@ -263,6 +296,10 @@ public String deleteUser(String userId){ } } + private String base64EncodePwd(String pwd){ + return Base64.getEncoder().encodeToString(pwd.getBytes()); + } + public String addNewUser(UserInfo newUser){ UserDetails userDetails = getUserDetails(); if(!utilService.checkAuthorizedSU(userDetails)) @@ -271,10 +308,10 @@ public String addNewUser(UserInfo newUser){ try { PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder(); - - inMemoryUserDetailsManager.createUser(User.withUsername(newUser.getUsername()) - .password(encoder.encode(newUser.getPwd())) - .roles(newUser.getRole()).build()); + inMemoryUserDetailsManager.createUser(User.withUsername(newUser.getUsername()) + .password(encoder.encode(newUser.getPwd())) + .roles(newUser.getRole()).build()); + newUser.setPwd(base64EncodePwd(newUser.getPwd())); HandleDbRequests dbHandle = manageDatabase.getHandleDbRequests(); @@ -313,15 +350,24 @@ public String changePwd(String changePwd){ pwdChange); inMemoryUserDetailsManager.updateUser(userDetailsUpdated); - return "{\"result\":\"" + manageDatabase.getHandleDbRequests().updatePassword(userDetails.getUsername(), pwdChange) + "\"}"; + return "{\"result\":\"" + manageDatabase.getHandleDbRequests() + .updatePassword(userDetails.getUsername(), base64EncodePwd(pwdChange)) + "\"}"; }catch(Exception e){ return "{\"result\":\"failure "+e.getMessage()+"\"}"; } } - public List showUsers(){ + public List showUsers(){ + List userInfoModels = new ArrayList<>(); + + List userList = manageDatabase.getHandleDbRequests().selectAllUsersInfo(); + userList.forEach(userListItem -> { + UserInfoModel userInfoModel = new UserInfoModel(); + copyProperties(userListItem,userInfoModel); + userInfoModels.add(userInfoModel); + }); - return manageDatabase.getHandleDbRequests().selectAllUsersInfo(); + return userInfoModels; } public UserInfo getMyProfileInfo(){ diff --git a/src/main/java/com/kafkamgt/uiapi/service/UtilControllerService.java b/src/main/java/com/kafkamgt/uiapi/service/UtilControllerService.java index 21bd686..0a7e1f0 100644 --- a/src/main/java/com/kafkamgt/uiapi/service/UtilControllerService.java +++ b/src/main/java/com/kafkamgt/uiapi/service/UtilControllerService.java @@ -26,11 +26,11 @@ public class UtilControllerService { @Autowired UtilService utilService; - @Value("${custom.org.name}") + @Value("${kafkawize.org.name}") private String companyInfo; - @Value("${custom.kafkawize.version:4.3}") + @Value("${kafkawize.version:5.0}") private String kafkawizeVersion; @@ -61,7 +61,6 @@ public HashMap getAuth() { String outstandingSchemasReqs = outstanding.get("schemas"); int outstandingSchemasReqsInt = Integer.parseInt(outstandingSchemasReqs); - if(outstandingTopicReqsInt<=0) outstandingTopicReqs = "0"; @@ -92,6 +91,7 @@ public HashMap getAuth() { dashboardData.put("status",statusAuth); dashboardData.put("username",userDetails.getUsername()); dashboardData.put("teamname",teamName); + dashboardData.put("userrole",authority.substring(5)); dashboardData.put("companyinfo",companyInfo); dashboardData.put("kafkawizeversion",kafkawizeVersion); dashboardData.put("notifications",outstandingTopicReqs); diff --git a/src/main/java/com/kafkamgt/uiapi/service/UtilService.java b/src/main/java/com/kafkamgt/uiapi/service/UtilService.java index 9d1ad1a..15399d6 100644 --- a/src/main/java/com/kafkamgt/uiapi/service/UtilService.java +++ b/src/main/java/com/kafkamgt/uiapi/service/UtilService.java @@ -3,22 +3,50 @@ import com.datastax.driver.core.*; import com.datastax.driver.core.policies.DefaultRetryPolicy; import com.kafkamgt.uiapi.config.ManageDatabase; +import com.kafkamgt.uiapi.error.KafkawizeException; import com.kafkamgt.uiapi.helpers.HandleDbRequests; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.PBEKeySpec; +import javax.crypto.spec.SecretKeySpec; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; +import java.text.SimpleDateFormat; +import java.util.Base64; +import java.util.Date; +import java.util.HashMap; + @Service @Slf4j public class UtilService { + @Value("${kafkawize.license.key}") + private + String licenseKey; + + @Value("${kafkawize.org.name}") + private + String organization; + @Autowired ManageDatabase manageDatabase; + public static boolean licenceLoaded = false; + RestTemplate getRestTemplate(){ return new RestTemplate(); } @@ -73,5 +101,55 @@ public Authentication getAuthentication(){ return SecurityContextHolder.getContext().getAuthentication(); } + public HashMap validateLicense(){ + HashMap hLicenseMap = new HashMap<>(); + + try { + loadLicenseUtil(licenseKey, organization); + hLicenseMap.put("LICENSE_STATUS", Boolean.TRUE.toString()); + hLicenseMap.put("LICENSE_KEY", licenseKey); + licenceLoaded=true; + return hLicenseMap; + } catch (Exception e) { + hLicenseMap.put("LICENSE_STATUS", Boolean.FALSE.toString()); + return hLicenseMap; + } + } + + + private void loadLicenseUtil(String licenseKey, String SALT_STR) throws Exception { + byte[] salt = SALT_STR.getBytes(); + int iterationCount = 40000; + int keyLength = 128; + + int sz = (int)Long.parseLong(licenseKey.substring(licenseKey.length()-3,licenseKey.length()-1),16); + String expData = licenseKey.substring(licenseKey.length()-sz-3); + expData = new String(base64Decode(new String(base64Decode(expData.substring(0,expData.length()-3)+"==")))); + String dateExpFound = expData.substring(expData.lastIndexOf(":")+1); + boolean checkExp = new SimpleDateFormat("yyyy-MM-dd").parse(dateExpFound).before(new Date()); + if(checkExp) + throw new KafkawizeException("Invalid License key !!"); + + decryptLicense(licenseKey.substring(0, licenseKey.length()-sz-3), createSecretKey(expData.toCharArray(), + salt, iterationCount, keyLength)); + } + + private static SecretKeySpec createSecretKey(char[] password, byte[] salt, int iterationCount, int keyLength) + throws NoSuchAlgorithmException, InvalidKeySpecException { + SecretKey keyTmps = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512") + .generateSecret(new PBEKeySpec(password, salt, iterationCount, keyLength)); + return new SecretKeySpec(keyTmps.getEncoded(), "AES"); + } + + private static void decryptLicense(String string, SecretKeySpec key) throws GeneralSecurityException, IOException { + Cipher cInstance = Cipher.getInstance("AES/CBC/PKCS5Padding"); + cInstance.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(base64Decode(string.split(":")[0]))); + cInstance.doFinal(base64Decode(string.split(":")[1])); + } + + private static byte[] base64Decode(String property) throws IOException { + return Base64.getDecoder().decode(property); + } + } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 9c980dd..7eec2ab 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,35 +2,45 @@ server.port:9097 server.servlet.context-path=/kafkawize -# custom.db.storetype should be "cassandra" or "rdbms" -custom.db.storetype=rdbms +server.ssl.key-store=C:/Software/confluent-5.3.1-2.12/certs/server.keystore.jks +server.ssl.trust-store=C:/Software/confluent-5.3.1-2.12/certs/server.truststore.jks +server.ssl.key-store-password=kafkawize +server.ssl.key-password=kafkawize +server.ssl.trust-store-password=kafkawize +server.ssl.key-store-type=JKS + +# kafkawize.db.storetype should be "cassandra" or "rdbms" +kafkawize.db.storetype=rdbms # cluster api properties -custom.clusterapi.url:http://localhost:9343 -custom.clusterapi.username:user1 -custom.clusterapi.password:pwd +kafkawize.clusterapi.url:http://localhost:9343 +kafkawize.clusterapi.username:user1 +kafkawize.clusterapi.password:pwd -# db store cassandra properties, to be filled in if custom.db.storetype is cassandra -custom.cassandradb.keyspace:kafkamanagementapi -custom.cassandradb.url:localhost -custom.cassandradb.port:9042 +# db store cassandra properties, to be filled in if kafkawize.db.storetype is cassandra +kafkawize.cassandradb.keyspace:kafkamanagementapi +kafkawize.cassandradb.url:localhost +kafkawize.cassandradb.port:9042 # db scripts execution 'auto' or 'manual'. If set to manual, user has to execute the scripts from resources dir manually -custom.dbscripts.execution=auto +kafkawize.dbscripts.execution=auto # drop all tables and recreate. Be careful with this property. -custom.dbscripts.dropall_recreate=false +kafkawize.dbscripts.dropall_recreate=false # default cluster to synchronize data -custom.syncdata.cluster=DEV +kafkawize.syncdata.cluster=DEV # order of envs -custom.envs.order=DEV,TST,ACC,PRD -custom.request.topics.envs=DEV,TST,ACC,PRD +kafkawize.envs.order=DEV,TST,ACC,PRD + +#request topics in below envs. Promote topics will be in higher envs +kafkawize.request.topics.envs=DEV,TST # licensing info -custom.org.name=Kafkawize -custom.kafkawize.version=4.3 -custom.invalidkey.msg=Invalid License !! Please request from https://kafkawize.com/request-for-license-key/ for a license key. +kafkawize.license.key= +kafkawize.org.name=MyOrganization +kafkawize.version=4.4 +kafkawize.invalidkey.msg=Invalid License !! Please request from https://kafkawize.com for a license key. # Spring JPA properties spring.datasource.url=jdbc:mysql://localhost:3306/kafkametadb?autoReconnect=true&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC @@ -46,4 +56,5 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialec spring.datasource.platform=mysql spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy + #logging.level.root=debug diff --git a/src/main/resources/scripts/base/cassandra/insertdata.sql b/src/main/resources/scripts/base/cassandra/insertdata.sql index 7b7b8af..e58c20a 100644 --- a/src/main/resources/scripts/base/cassandra/insertdata.sql +++ b/src/main/resources/scripts/base/cassandra/insertdata.sql @@ -1,18 +1,18 @@ -/* Insert Users */ +/* Insert Users, pwd - base64 encoded */ -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User1','Team1','uiuser1','USER','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User1','Team1','uiuser1','USER','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User2','Team2','uiuser2','USER','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User2','Team2','uiuser2','USER','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User3','Team3','uiuser3','USER','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User3','Team3','uiuser3','USER','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User4','Team1','uiuser4','ADMIN','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User4','Team1','uiuser4','ADMIN','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User5','Team2','uiuser5','ADMIN','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User5','Team2','uiuser5','ADMIN','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User6','Team3','uiuser6','ADMIN','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User6','Team3','uiuser6','ADMIN','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('SuperUser','Team2','superuser','SUPERUSER','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('SuperUser','Team2','superuser','SUPERUSER','dXNlcg=='); /* Insert Teams */ @@ -36,4 +36,4 @@ Insert into kafkamanagementapi.env(name,host,port,protocol,type) values ('DEV_SC /* Insert product and version */ -Insert into kafkamanagementapi.productdetails(name,version,licensekey) values ('KafkaWize','5.0',''); +Insert into kafkamanagementapi.productdetails(name,version,licensekey) values ('KafkaWize','4.4',''); diff --git a/src/main/resources/scripts/base/rdbms/insertdata.sql b/src/main/resources/scripts/base/rdbms/insertdata.sql index 6c253be..ecce485 100644 --- a/src/main/resources/scripts/base/rdbms/insertdata.sql +++ b/src/main/resources/scripts/base/rdbms/insertdata.sql @@ -1,18 +1,18 @@ -/* Insert Users */ +/* Insert Users , pwd: base64 encoded*/ -Insert into users(fullname,team,userid,roleid,pwd) values('User1','Team1','uiuser1','USER','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User1','Team1','uiuser1','USER','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User2','Team2','uiuser2','USER','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User2','Team2','uiuser2','USER','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User3','Team3','uiuser3','USER','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User3','Team3','uiuser3','USER','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User4','Team1','uiuser4','ADMIN','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User4','Team1','uiuser4','ADMIN','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User5','Team2','uiuser5','ADMIN','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User5','Team2','uiuser5','ADMIN','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User6','Team3','uiuser6','ADMIN','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User6','Team3','uiuser6','ADMIN','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('SuperUser','Team2','superuser','SUPERUSER','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('SuperUser','Team2','superuser','SUPERUSER','dXNlcg=='); /* Insert Teams */ @@ -36,6 +36,6 @@ Insert into env(name,host,port,protocol,type) values ('DEV_SCH','localhost','808 /* Insert product and version */ -Insert into productdetails(name,version) values ('KafkaWize','4.0'); +Insert into productdetails(name,version) values ('KafkaWize','4.4'); commit; \ No newline at end of file diff --git a/src/main/resources/static/assets/css/colors/default.css b/src/main/resources/static/assets/css/colors/default.css index 9aa5d1e..d09881b 100644 --- a/src/main/resources/static/assets/css/colors/default.css +++ b/src/main/resources/static/assets/css/colors/default.css @@ -235,16 +235,16 @@ a.link:hover, a.link:focus { color: #99abb4; } .sidebar-nav > ul > li.active > a, .sidebar-nav > ul > li.active:hover > a { color: #fff; - background: #607d8b; } + background: #26c6da; } .sidebar-nav > ul > li.active > a i, .sidebar-nav > ul > li.active:hover > a i { color: #fff; } .sidebar-nav > ul > li.active > a:after, .sidebar-nav > ul > li.active:hover > a:after { border-color: #fff; } .sidebar-nav > ul > li > a.active i, .sidebar-nav > ul > li > a:hover i { - color: #607d8b; } + color: #26c6da; } .sidebar-nav > ul > li > a i { color: #99abb4; } .sidebar-nav > ul > li > a.active { font-weight: 400; background: #fff; - color: #607d8b; } + color: #009efb; } diff --git a/src/main/resources/static/assets/images/background/login-register.jpg b/src/main/resources/static/assets/images/background/login-register.jpg index 4ceb32e..bbade52 100644 Binary files a/src/main/resources/static/assets/images/background/login-register.jpg and b/src/main/resources/static/assets/images/background/login-register.jpg differ diff --git a/src/main/resources/static/assets/images/favicon.png b/src/main/resources/static/assets/images/favicon.png index 874eac8..89fc838 100644 Binary files a/src/main/resources/static/assets/images/favicon.png and b/src/main/resources/static/assets/images/favicon.png differ diff --git a/src/main/resources/static/assets/images/logo-dark.png b/src/main/resources/static/assets/images/logo-dark.png deleted file mode 100644 index 0af29ee..0000000 Binary files a/src/main/resources/static/assets/images/logo-dark.png and /dev/null differ diff --git a/src/main/resources/static/assets/images/logo-icon.png b/src/main/resources/static/assets/images/logo-icon.png deleted file mode 100644 index 4ff1122..0000000 Binary files a/src/main/resources/static/assets/images/logo-icon.png and /dev/null differ diff --git a/src/main/resources/static/assets/images/logo-light.png b/src/main/resources/static/assets/images/logo-light.png deleted file mode 100644 index eda52a9..0000000 Binary files a/src/main/resources/static/assets/images/logo-light.png and /dev/null differ diff --git a/src/main/resources/static/assets/images/logo-si_oldgnin.png b/src/main/resources/static/assets/images/logo-si_oldgnin.png deleted file mode 100644 index b1dd775..0000000 Binary files a/src/main/resources/static/assets/images/logo-si_oldgnin.png and /dev/null differ diff --git a/src/main/resources/static/assets/images/logo-signin.png b/src/main/resources/static/assets/images/logo-signin.png index ca433cc..b85e69a 100644 Binary files a/src/main/resources/static/assets/images/logo-signin.png and b/src/main/resources/static/assets/images/logo-signin.png differ diff --git a/src/main/resources/static/assets/images/logo-signin1.png b/src/main/resources/static/assets/images/logo-signin1.png deleted file mode 100644 index e95fc2f..0000000 Binary files a/src/main/resources/static/assets/images/logo-signin1.png and /dev/null differ diff --git a/src/main/resources/static/assets/images/logo-text.png b/src/main/resources/static/assets/images/logo-text.png deleted file mode 100644 index 83b3c09..0000000 Binary files a/src/main/resources/static/assets/images/logo-text.png and /dev/null differ diff --git a/src/main/resources/static/assets/images/logo_kw.png b/src/main/resources/static/assets/images/logo_kw.png index 7e96633..20782f6 100644 Binary files a/src/main/resources/static/assets/images/logo_kw.png and b/src/main/resources/static/assets/images/logo_kw.png differ diff --git a/src/main/resources/static/assets/images/logo_kw1.png b/src/main/resources/static/assets/images/logo_kw1.png deleted file mode 100644 index 024c154..0000000 Binary files a/src/main/resources/static/assets/images/logo_kw1.png and /dev/null differ diff --git a/src/main/resources/static/assets/images/logo_kw_old.png b/src/main/resources/static/assets/images/logo_kw_old.png deleted file mode 100644 index 6667a08..0000000 Binary files a/src/main/resources/static/assets/images/logo_kw_old.png and /dev/null differ diff --git a/src/main/resources/static/assets/images/screenshots/ActivityLog.JPG b/src/main/resources/static/assets/images/screenshots/ActivityLog.JPG index 5f05c9b..722b367 100644 Binary files a/src/main/resources/static/assets/images/screenshots/ActivityLog.JPG and b/src/main/resources/static/assets/images/screenshots/ActivityLog.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/AddCluster.JPG b/src/main/resources/static/assets/images/screenshots/AddCluster.JPG index 2888837..91ee204 100644 Binary files a/src/main/resources/static/assets/images/screenshots/AddCluster.JPG and b/src/main/resources/static/assets/images/screenshots/AddCluster.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/AddTeam.JPG b/src/main/resources/static/assets/images/screenshots/AddTeam.JPG index 5a39e15..c74787b 100644 Binary files a/src/main/resources/static/assets/images/screenshots/AddTeam.JPG and b/src/main/resources/static/assets/images/screenshots/AddTeam.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/AddUser.JPG b/src/main/resources/static/assets/images/screenshots/AddUser.JPG index 19ecdce..5ffd8ae 100644 Binary files a/src/main/resources/static/assets/images/screenshots/AddUser.JPG and b/src/main/resources/static/assets/images/screenshots/AddUser.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/ApproveACL.JPG b/src/main/resources/static/assets/images/screenshots/ApproveACL.JPG index a1bc004..71581a9 100644 Binary files a/src/main/resources/static/assets/images/screenshots/ApproveACL.JPG and b/src/main/resources/static/assets/images/screenshots/ApproveACL.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/ApproveTopics.JPG b/src/main/resources/static/assets/images/screenshots/ApproveTopics.JPG index dff192f..aefd374 100644 Binary files a/src/main/resources/static/assets/images/screenshots/ApproveTopics.JPG and b/src/main/resources/static/assets/images/screenshots/ApproveTopics.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/BrowseTopics.JPG b/src/main/resources/static/assets/images/screenshots/BrowseTopics.JPG index 4ecf43b..6f4f30b 100644 Binary files a/src/main/resources/static/assets/images/screenshots/BrowseTopics.JPG and b/src/main/resources/static/assets/images/screenshots/BrowseTopics.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/Dashboard.JPG b/src/main/resources/static/assets/images/screenshots/Dashboard.JPG index 20df24d..27a8fe9 100644 Binary files a/src/main/resources/static/assets/images/screenshots/Dashboard.JPG and b/src/main/resources/static/assets/images/screenshots/Dashboard.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/Environments.JPG b/src/main/resources/static/assets/images/screenshots/Environments.JPG index 7821141..c6b4b5d 100644 Binary files a/src/main/resources/static/assets/images/screenshots/Environments.JPG and b/src/main/resources/static/assets/images/screenshots/Environments.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/Logout.JPG b/src/main/resources/static/assets/images/screenshots/Logout.JPG index 80cd323..e47f598 100644 Binary files a/src/main/resources/static/assets/images/screenshots/Logout.JPG and b/src/main/resources/static/assets/images/screenshots/Logout.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/MyAclRequests.JPG b/src/main/resources/static/assets/images/screenshots/MyAclRequests.JPG index b0860bc..3832219 100644 Binary files a/src/main/resources/static/assets/images/screenshots/MyAclRequests.JPG and b/src/main/resources/static/assets/images/screenshots/MyAclRequests.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/MyTopicRequests.JPG b/src/main/resources/static/assets/images/screenshots/MyTopicRequests.JPG index d4e7d79..d1dd6d3 100644 Binary files a/src/main/resources/static/assets/images/screenshots/MyTopicRequests.JPG and b/src/main/resources/static/assets/images/screenshots/MyTopicRequests.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/RequestACL.JPG b/src/main/resources/static/assets/images/screenshots/RequestACL.JPG index 95a5959..6449cbd 100644 Binary files a/src/main/resources/static/assets/images/screenshots/RequestACL.JPG and b/src/main/resources/static/assets/images/screenshots/RequestACL.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/RequestSchema.JPG b/src/main/resources/static/assets/images/screenshots/RequestSchema.JPG index 7d064b6..675f296 100644 Binary files a/src/main/resources/static/assets/images/screenshots/RequestSchema.JPG and b/src/main/resources/static/assets/images/screenshots/RequestSchema.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/RequestTopic.JPG b/src/main/resources/static/assets/images/screenshots/RequestTopic.JPG index 536ea56..df846b9 100644 Binary files a/src/main/resources/static/assets/images/screenshots/RequestTopic.JPG and b/src/main/resources/static/assets/images/screenshots/RequestTopic.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/ServerConfig.JPG b/src/main/resources/static/assets/images/screenshots/ServerConfig.JPG index 4e5de99..a202bd2 100644 Binary files a/src/main/resources/static/assets/images/screenshots/ServerConfig.JPG and b/src/main/resources/static/assets/images/screenshots/ServerConfig.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/SynchronizeAcls.JPG b/src/main/resources/static/assets/images/screenshots/SynchronizeAcls.JPG index 3f5e989..dcea231 100644 Binary files a/src/main/resources/static/assets/images/screenshots/SynchronizeAcls.JPG and b/src/main/resources/static/assets/images/screenshots/SynchronizeAcls.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/SynchronizeTopics.JPG b/src/main/resources/static/assets/images/screenshots/SynchronizeTopics.JPG index 3f1f056..59add57 100644 Binary files a/src/main/resources/static/assets/images/screenshots/SynchronizeTopics.JPG and b/src/main/resources/static/assets/images/screenshots/SynchronizeTopics.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/ViewAcls.JPG b/src/main/resources/static/assets/images/screenshots/ViewAcls.JPG index 24350af..e87a9b8 100644 Binary files a/src/main/resources/static/assets/images/screenshots/ViewAcls.JPG and b/src/main/resources/static/assets/images/screenshots/ViewAcls.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/ViewTeams.JPG b/src/main/resources/static/assets/images/screenshots/ViewTeams.JPG index c7b27b1..ae98658 100644 Binary files a/src/main/resources/static/assets/images/screenshots/ViewTeams.JPG and b/src/main/resources/static/assets/images/screenshots/ViewTeams.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/ViewUsers.JPG b/src/main/resources/static/assets/images/screenshots/ViewUsers.JPG index b7f305c..2e9c673 100644 Binary files a/src/main/resources/static/assets/images/screenshots/ViewUsers.JPG and b/src/main/resources/static/assets/images/screenshots/ViewUsers.JPG differ diff --git a/src/main/resources/static/assets/images/screenshots/arch.png b/src/main/resources/static/assets/images/screenshots/arch.png index 2f67fb5..dcfafc8 100644 Binary files a/src/main/resources/static/assets/images/screenshots/arch.png and b/src/main/resources/static/assets/images/screenshots/arch.png differ diff --git a/src/main/resources/static/assets/images/screenshots/login.JPG b/src/main/resources/static/assets/images/screenshots/login.JPG index ee947fb..1244187 100644 Binary files a/src/main/resources/static/assets/images/screenshots/login.JPG and b/src/main/resources/static/assets/images/screenshots/login.JPG differ diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index 2fd08f4..7c5bc0d 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -21,7 +21,7 @@ - + @@ -56,23 +56,7 @@ - + @@ -82,12 +66,7 @@ + + diff --git a/src/main/resources/static/js/browseAcls.js b/src/main/resources/static/js/browseAcls.js index 794d5dc..fed4cc2 100644 --- a/src/main/resources/static/js/browseAcls.js +++ b/src/main/resources/static/js/browseAcls.js @@ -58,6 +58,7 @@ app.controller("browseAclsCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; @@ -158,5 +159,6 @@ app.controller("browseAclsCtrl", function($scope, $http, $location, $window) { }; + } ); \ No newline at end of file diff --git a/src/main/resources/static/js/browseTopics.js b/src/main/resources/static/js/browseTopics.js index da89fe8..57d58b6 100644 --- a/src/main/resources/static/js/browseTopics.js +++ b/src/main/resources/static/js/browseTopics.js @@ -61,6 +61,7 @@ app.controller("browseTopicsCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/envs.js b/src/main/resources/static/js/envs.js index c0fe784..ffc54ae 100644 --- a/src/main/resources/static/js/envs.js +++ b/src/main/resources/static/js/envs.js @@ -48,6 +48,22 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) { ); }; + $scope.getOtherEnvs = function() { + + $http({ + method: "GET", + url: "getOtherEnvs", + headers : { 'Content-Type' : 'application/json' } + }).success(function(output) { + $scope.allotherenvs = output; + }).error( + function(error) + { + $scope.alert = error; + } + ); + }; + $scope.deleteEnv = function(idval) { if (!window.confirm("Are you sure, you would like to delete the cluster : " @@ -80,48 +96,48 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) { if($scope.addNewEnv.defparts.length<=0 || $scope.addNewEnv.defparts<=0) { $scope.alertnote = "Default partitions should not be empty and should be greater than 0"; - $scope.showAlertToast(); + // $scope.showAlertToast(); return; } if($scope.addNewEnv.defmaxparts.length<=0 || $scope.addNewEnv.defmaxparts<=0) { $scope.alertnote = "Maximum partitions should not be empty and should be greater than 0"; - $scope.showAlertToast(); + // $scope.showAlertToast(); return; } if($scope.addNewEnv.defrepfctr.length<=0 || $scope.addNewEnv.defrepfctr<=0) { $scope.alertnote = "Default replication factor should not be empty and should be greater than 0"; - $scope.showAlertToast(); + // $scope.showAlertToast(); return; } if($scope.addNewEnv.type == undefined) { $scope.alertnote = "Please select the cluster type"; - $scope.showAlertToast(); + // $scope.showAlertToast(); return; } if($scope.addNewEnv.host == undefined) { $scope.alertnote = "Please fill in host"; - $scope.showAlertToast(); + // $scope.showAlertToast(); return; } if($scope.addNewEnv.envname == undefined) { $scope.alertnote = "Please fill in a name for cluster"; - $scope.showAlertToast(); + // $scope.showAlertToast(); return; } if($scope.addNewEnv.envname.length > 3) { $scope.alertnote = "Cluster name cannot be more than 3 characters."; - $scope.showAlertToast(); + // $scope.showAlertToast(); return; } @@ -144,13 +160,13 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) { data: serviceInput }).success(function(output) { $scope.alert = "New cluster added: "+output.result; - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { $scope.alert = error; $scope.alertnote = error; - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); @@ -185,6 +201,7 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/execAcls.js b/src/main/resources/static/js/execAcls.js index 6814724..cc966fc 100644 --- a/src/main/resources/static/js/execAcls.js +++ b/src/main/resources/static/js/execAcls.js @@ -57,6 +57,7 @@ app.controller("execAclsCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; @@ -145,14 +146,14 @@ app.controller("execAclsCtrl", function($scope, $http, $location, $window) { $scope.alert = "Acl Approve Request : "+output.result; $scope.getMyAclRequests(); - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { $scope.alert = error; $scope.alertnote = error; - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); } @@ -171,14 +172,14 @@ app.controller("execAclsCtrl", function($scope, $http, $location, $window) { $scope.alert = "Acl Decline Request : "+output.result; $scope.getMyAclRequests(); - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { $scope.alert = error; $scope.alertnote = error; - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); } diff --git a/src/main/resources/static/js/execSchemas.js b/src/main/resources/static/js/execSchemas.js index 08f3ebc..543c440 100644 --- a/src/main/resources/static/js/execSchemas.js +++ b/src/main/resources/static/js/execSchemas.js @@ -57,14 +57,14 @@ app.controller("execSchemasCtrl", function($scope, $http, $location, $window) { $scope.alert = "Schema Approve Request : "+output.result; $scope.getMySchemaRequests(); - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { $scope.alert = error; $scope.alertnote = error; - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); } @@ -82,14 +82,14 @@ app.controller("execSchemasCtrl", function($scope, $http, $location, $window) { $scope.alert = "Schema Decline Request : "+output.result; $scope.getMySchemaRequests(); - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { $scope.alert = error; $scope.alertnote = error; - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); } @@ -125,6 +125,7 @@ app.controller("execSchemasCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/execTopics.js b/src/main/resources/static/js/execTopics.js index e8ffb33..0a4a932 100644 --- a/src/main/resources/static/js/execTopics.js +++ b/src/main/resources/static/js/execTopics.js @@ -60,14 +60,14 @@ app.controller("execTopicsCtrl", function($scope, $http, $location, $window) { $scope.alert = "Topic Approve Request : "+output.result; $scope.getMyTopicRequests(); - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { $scope.alert = error; $scope.alertnote = error; - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); } @@ -85,14 +85,14 @@ app.controller("execTopicsCtrl", function($scope, $http, $location, $window) { $scope.alert = "Topic Approve Request : "+output.result; $scope.getMyTopicRequests(); - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { $scope.alert = error; $scope.alertnote = error; - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); } @@ -128,6 +128,7 @@ app.controller("execTopicsCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/index.js b/src/main/resources/static/js/index.js index 9845b80..3c7ae85 100644 --- a/src/main/resources/static/js/index.js +++ b/src/main/resources/static/js/index.js @@ -92,6 +92,7 @@ app.controller("dashboardCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.myteamtopics = output.myteamtopics; $scope.kafkawizeversion = output.kafkawizeversion; $scope.notifications = output.notifications; diff --git a/src/main/resources/static/js/indexapp.js b/src/main/resources/static/js/indexapp.js index 464eb51..ed2086f 100644 --- a/src/main/resources/static/js/indexapp.js +++ b/src/main/resources/static/js/indexapp.js @@ -30,6 +30,7 @@ app.controller("indexCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.myteamtopics = output.myteamtopics; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; diff --git a/src/main/resources/static/js/manageUsers.js b/src/main/resources/static/js/manageUsers.js index 7479bc2..0977b30 100644 --- a/src/main/resources/static/js/manageUsers.js +++ b/src/main/resources/static/js/manageUsers.js @@ -101,7 +101,7 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) { data: {'changePwd' : serviceInput} }).success(function(output) { $scope.alert = "Password changed : "+output.result; - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { @@ -131,7 +131,7 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) { }).success(function(output) { $scope.alert = "Delete Team Request : "+output.result; - $scope.showSuccessToast(); + // $scope.showSuccessToast(); $scope.loadTeamsSU(); }).error( function(error) @@ -160,7 +160,7 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) { }).success(function(output) { $scope.alert = "Delete User Request : "+output.result; - $scope.showSuccessToast(); + // $scope.showSuccessToast(); $scope.showUsers(); }).error( function(error) @@ -190,24 +190,6 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) { return; } - if(!$scope.addNewUser.emailid) - { - $scope.alertnote = "Email id is mandatory."; - $scope.showAlertToast(); - return; - } - else if($scope.addNewUser.emailid.length < 7) - { - $scope.alertnote = "Please enter a valid email id."; - $scope.showAlertToast(); - return; - } - else if(!$scope.addNewUser.emailid.includes("@")) - { - $scope.alertnote = "Please enter a valid email id."; - $scope.showAlertToast(); - return; - } if(!$scope.addNewUser.role.value) { @@ -221,7 +203,7 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) { serviceInput['pwd'] = $scope.addNewUser.pwd; serviceInput['team'] = $scope.addNewUser.team.teamname; serviceInput['role'] = $scope.addNewUser.role.value; - serviceInput['mailid'] = $scope.addNewUser.emailid; + serviceInput['mailid'] = ''; if (!window.confirm("Are you sure, you would like to add user : " + $scope.addNewUser.username + ": " + @@ -240,7 +222,7 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) { data: serviceInput }).success(function(output) { $scope.alert = "New User Request : "+output.result; - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { @@ -252,6 +234,7 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) { }; + $scope.cancelRequest = function() { $window.location.href = $window.location.origin + "/kafkawize/teams"; } @@ -302,7 +285,7 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) { data: serviceInput }).success(function(output) { $scope.alert = "New User Team : "+output.result; - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { @@ -360,6 +343,7 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/myRequests.js b/src/main/resources/static/js/myRequests.js index 2bd9e5c..2b8220a 100644 --- a/src/main/resources/static/js/myRequests.js +++ b/src/main/resources/static/js/myRequests.js @@ -30,6 +30,7 @@ app.controller("myRequestsCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/requestAcls.js b/src/main/resources/static/js/requestAcls.js index a4ec876..ae4150b 100644 --- a/src/main/resources/static/js/requestAcls.js +++ b/src/main/resources/static/js/requestAcls.js @@ -36,6 +36,7 @@ app.controller("requestAclsCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; @@ -195,7 +196,7 @@ app.controller("requestAclsCtrl", function($scope, $http, $location, $window) { if($scope.addAcl.topicreqtype.value == 'Consumer' && !$scope.addAcl.consumergroup) { $scope.alertnote = "Consumer group is not filled." - $scope.showAlertToast(); + $scope.showAlertToast(); return; } @@ -213,7 +214,7 @@ app.controller("requestAclsCtrl", function($scope, $http, $location, $window) { { //alert("This topic is not owned by any team. Synchronize the metadata."); $scope.alertnote = "This topic is not owned by any team. Synchronize the metadata."; - $scope.showAlertToast(); + $scope.showAlertToast(); return false; } @@ -222,7 +223,7 @@ app.controller("requestAclsCtrl", function($scope, $http, $location, $window) { else { $scope.alertnote = "Please fill in a valid IP address or SSL-CN Name of the Producer/Consumer client"; - $scope.showAlertToast(); + $scope.showAlertToast(); return; } @@ -235,13 +236,13 @@ app.controller("requestAclsCtrl", function($scope, $http, $location, $window) { data: serviceInput }).success(function(output) { $scope.alert = "Acl Request : "+output.result; - $scope.showSuccessToast(); + $scope.showSuccessToast(); }).error( function(error) { $scope.alert = error; $scope.alertnote = error; - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); diff --git a/src/main/resources/static/js/requestAvroSchemaUpload.js b/src/main/resources/static/js/requestAvroSchemaUpload.js index af4c43c..aa74198 100644 --- a/src/main/resources/static/js/requestAvroSchemaUpload.js +++ b/src/main/resources/static/js/requestAvroSchemaUpload.js @@ -122,14 +122,14 @@ app.controller("requestSchemaCtrl", function($scope, $http, $location, $window) data: serviceInput }).success(function(output) { $scope.alert = "Schema Upload Request : "+output.result; - $scope.showSuccessToast(); + // $scope.showSuccessToast(); }).error( function(error) { $scope.alert = error; //alert("Error : "+error.value); $scope.alertnote = error; - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); @@ -164,6 +164,7 @@ app.controller("requestSchemaCtrl", function($scope, $http, $location, $window) $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/requestTopics.js b/src/main/resources/static/js/requestTopics.js index 0e51b88..14cd1cf 100644 --- a/src/main/resources/static/js/requestTopics.js +++ b/src/main/resources/static/js/requestTopics.js @@ -54,7 +54,7 @@ app.controller("requestTopicsCtrl", function($scope, $http, $location, $window) if(!$scope.addTopic.topicpartitions || $scope.addTopic.topicpartitions == 'selected'){ //alert("Please fill in topic partitions"); $scope.alertnote = "Please select topic partitions."; - $scope.showAlertToast(); + $scope.showAlertToast(); return; } @@ -81,7 +81,7 @@ app.controller("requestTopicsCtrl", function($scope, $http, $location, $window) $scope.alert = error; $scope.alertnote = error; // alert("Error : "+error.value); - $scope.showAlertToast(); + // $scope.showAlertToast(); } ); @@ -137,6 +137,7 @@ app.controller("requestTopicsCtrl", function($scope, $http, $location, $window) $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/serverConfig.js b/src/main/resources/static/js/serverConfig.js index 3ac08a5..421abd7 100644 --- a/src/main/resources/static/js/serverConfig.js +++ b/src/main/resources/static/js/serverConfig.js @@ -64,6 +64,7 @@ app.controller("serverConfigCtrl", function($scope, $http, $location, $window) { $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/showActivityLog.js b/src/main/resources/static/js/showActivityLog.js index d1a11e6..46054c0 100644 --- a/src/main/resources/static/js/showActivityLog.js +++ b/src/main/resources/static/js/showActivityLog.js @@ -46,6 +46,7 @@ app.controller("showActivityLogCtrl", function($scope, $http, $location, $window $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; diff --git a/src/main/resources/static/js/synchronizeAcls.js b/src/main/resources/static/js/synchronizeAcls.js index a90f4f0..3925c9a 100644 --- a/src/main/resources/static/js/synchronizeAcls.js +++ b/src/main/resources/static/js/synchronizeAcls.js @@ -49,6 +49,7 @@ app.controller("synchronizeAclsCtrl", function($scope, $http, $location, $window $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; @@ -89,87 +90,7 @@ app.controller("synchronizeAclsCtrl", function($scope, $http, $location, $window ); } - $scope.updatedSyncArray = []; - $scope.getDetails = function(sequence, req_no, teamselected, topic, consumergroup, acl_ip, acl_ssl, acltype) { - var serviceInput = {}; - - serviceInput['sequence'] = sequence; - serviceInput['req_no'] = req_no; - serviceInput['topicName'] = topic; - serviceInput['teamSelected'] = teamselected; - serviceInput['consumerGroup'] = consumergroup; - serviceInput['aclIp'] = acl_ip; - serviceInput['aclSsl'] = acl_ssl; - serviceInput['aclType'] = acltype; - serviceInput['envSelected'] = $scope.getAcls.envName.name.key; - - $scope.updatedSyncArray.push(serviceInput); - } - - $scope.synchAcls = function() { - - var serviceInput = {}; - - if(!$scope.getAcls.envName) - return; - - if (!window.confirm("Are you sure, you would like to Synchronize this info on "+$scope.getAcls.envName.name.key+ " ?")) { - $scope.updatedSyncArray = []; - return; - } - - $http({ - method: "POST", - url: "updateSyncAcls", - headers : { 'Content-Type' : 'application/json' }, - params: {'syncAclUpdates' : $scope.updatedSyncArray }, - data: $scope.updatedSyncArray - }).success(function(output) { - $scope.alert = "Acl Sync Request : "+output.result; - $scope.updatedSyncArray = []; - $scope.showSuccessToast(); - $scope.getAcls(1); - }).error( - function(error) - { - $scope.alert = error; - $scope.alertnote = error; - $scope.showAlertToast(); - } - ); - - }; - - // We add the "time" query parameter to prevent IE - // from caching ajax results - - $scope.getAcls = function(pageNoSelected) { - - var serviceInput = {}; - serviceInput['env'] = $scope.getAcls.envName.name.key; - - $http({ - method: "GET", - url: "getSyncAcls", - headers : { 'Content-Type' : 'application/json' }, - params: {'env' : $scope.getAcls.envName.name.key, 'topicnamesearch' : $scope.getAcls.topicnamesearch, - 'pageNo' : pageNoSelected } - }).success(function(output) { - $scope.resultBrowse = output; - if(output!=null){ - $scope.resultPages = output[0].allPageNos; - $scope.resultPageSelected = pageNoSelected; - } - }).error( - function(error) - { - $scope.resultBrowse = []; - $scope.alert = error; - } - ); - - }; $scope.getExecAuth = function() { //alert("onload"); diff --git a/src/main/resources/static/js/synchronizeTopics.js b/src/main/resources/static/js/synchronizeTopics.js index be44dbf..3859f67 100644 --- a/src/main/resources/static/js/synchronizeTopics.js +++ b/src/main/resources/static/js/synchronizeTopics.js @@ -58,6 +58,7 @@ app.controller("synchronizeTopicsCtrl", function($scope, $http, $location, $wind $scope.statusauth = output.status; $scope.userlogged = output.username; $scope.teamname = output.teamname; + $scope.userrole = output.userrole; $scope.notifications = output.notifications; $scope.notificationsAcls = output.notificationsAcls; $scope.notificationsSchemas = output.notificationsSchemas; @@ -98,83 +99,6 @@ app.controller("synchronizeTopicsCtrl", function($scope, $http, $location, $wind ); } - $scope.updatedSyncArray = []; - $scope.updateTopicDetails = function(sequence, teamselected,topic, partitions, replicationFactor) { - var serviceInput = {}; - serviceInput['sequence'] = sequence; - serviceInput['topicName'] = topic; - serviceInput['partitions'] = partitions; - serviceInput['replicationFactor'] = replicationFactor; - serviceInput['teamSelected'] = teamselected; - serviceInput['envSelected'] = $scope.getTopics.envName.name.key; - - $scope.updatedSyncArray.push(serviceInput); - } - - $scope.synchTopics = function() { - - var serviceInput = {}; - - if(!$scope.getTopics.envName) - return; - - if (!window.confirm("Are you sure, you would like to Synchronize this info ? "+$scope.getTopics.envName.name.key)) { - $scope.updatedSyncArray = []; - return; - } - - $http({ - method: "POST", - url: "updateSyncTopics", - headers : { 'Content-Type' : 'application/json' }, - params: {'updatedSyncTopics' : $scope.updatedSyncArray}, - data: $scope.updatedSyncArray - }).success(function(output) { - $scope.alert = "Topic Sync Request : "+output.result; - $scope.updatedSyncArray = []; - $scope.showSuccessToast(); - }).error( - function(error) - { - $scope.alert = error; - $scope.alertnote = error; - $scope.showAlertToast(); - } - ); - - }; - - // We add the "time" query parameter to prevent IE - // from caching ajax results - - $scope.getTopics = function(pageNoSelected) { - - var serviceInput = {}; - serviceInput['env'] = $scope.getTopics.envName.name.key; - - $http({ - method: "GET", - url: "getSyncTopics", - headers : { 'Content-Type' : 'application/json' }, - params: {'env' : $scope.getTopics.envName.name.key, 'topicnamesearch' : $scope.getTopics.topicnamesearch, - 'pageNo' : pageNoSelected } - }).success(function(output) { - $scope.resultBrowse = output; - if(output!=null && output.length !=0){ - $scope.resultPages = output[0].allPageNos; - $scope.resultPageSelected = pageNoSelected; - } - $scope.alert = ""; - }).error( - function(error) - { - $scope.resultBrowse = []; - $scope.alert = error; - } - ); - - }; - $scope.getExecAuth = function() { //alert("onload"); $http({ diff --git a/src/main/resources/templates/activityLog.html b/src/main/resources/templates/activityLog.html index afb04c1..aa6cd10 100644 --- a/src/main/resources/templates/activityLog.html +++ b/src/main/resources/templates/activityLog.html @@ -19,7 +19,7 @@ - + @@ -59,23 +59,7 @@ - + @@ -85,12 +69,7 @@ + diff --git a/src/main/resources/templates/addEnv.html b/src/main/resources/templates/addEnv.html index 2778cfd..b6d6536 100644 --- a/src/main/resources/templates/addEnv.html +++ b/src/main/resources/templates/addEnv.html @@ -19,7 +19,7 @@ - + @@ -55,23 +55,7 @@ - + @@ -81,12 +65,7 @@ + @@ -372,7 +377,7 @@

{{userlogged}}

-
+
@@ -401,7 +406,12 @@

{{userlogged}}

- + + + +
@@ -424,10 +434,11 @@

{{userlogged}}

- - - + +
+
@@ -452,13 +463,7 @@

{{userlogged}}

-
-
- - -
-
+
@@ -469,6 +474,15 @@

{{userlogged}}

+
+
+ + +
+ +
diff --git a/src/main/resources/templates/addTeam.html b/src/main/resources/templates/addTeam.html index ec5f83e..a51b623 100644 --- a/src/main/resources/templates/addTeam.html +++ b/src/main/resources/templates/addTeam.html @@ -19,7 +19,7 @@ - + @@ -55,23 +55,7 @@ - + @@ -81,12 +65,7 @@
@@ -197,8 +175,8 @@
Schema Requests
+
diff --git a/src/main/resources/templates/addUser.html b/src/main/resources/templates/addUser.html index f26cdf2..1d30093 100644 --- a/src/main/resources/templates/addUser.html +++ b/src/main/resources/templates/addUser.html @@ -19,7 +19,7 @@ - + @@ -55,23 +55,7 @@ - + @@ -81,12 +65,7 @@ + @@ -432,18 +436,6 @@

{{userlogged}}

-
- -
-
- - -
-
- - - -
diff --git a/src/main/resources/templates/browseAcls.html b/src/main/resources/templates/browseAcls.html index 7c38905..d6fdeb9 100644 --- a/src/main/resources/templates/browseAcls.html +++ b/src/main/resources/templates/browseAcls.html @@ -19,7 +19,7 @@ - + @@ -55,23 +55,7 @@ - + @@ -81,17 +65,11 @@ @@ -146,7 +124,6 @@
Schema Requests
-
@@ -161,8 +138,8 @@
Schema Requests
+
@@ -433,7 +436,6 @@

{{userlogged}}

{{ resultB.acl_ip}} {{ resultB.acl_ssl}} - diff --git a/src/main/resources/templates/browseTopics.html b/src/main/resources/templates/browseTopics.html index cbdce7e..12f8aa8 100644 --- a/src/main/resources/templates/browseTopics.html +++ b/src/main/resources/templates/browseTopics.html @@ -19,7 +19,7 @@ - + @@ -83,23 +83,7 @@ - + @@ -109,12 +93,7 @@ + @@ -515,8 +520,8 @@
Clusters
- +
    diff --git a/src/main/resources/templates/changePwd.html b/src/main/resources/templates/changePwd.html index 67f79db..15dd26f 100644 --- a/src/main/resources/templates/changePwd.html +++ b/src/main/resources/templates/changePwd.html @@ -19,7 +19,7 @@ - + @@ -55,23 +55,7 @@ - + @@ -81,12 +65,7 @@ +
diff --git a/src/main/resources/templates/envs.html b/src/main/resources/templates/envs.html index c445b66..1f5649d 100644 --- a/src/main/resources/templates/envs.html +++ b/src/main/resources/templates/envs.html @@ -19,7 +19,7 @@ - + @@ -59,23 +59,7 @@ - + @@ -85,12 +69,7 @@ + @@ -407,16 +412,14 @@

{{userlogged}}

{{ allenv.host }} {{ allenv.port }} - - PLAIN + + PLAINTEXT - - {{ allenv.protocol}} {{ allenv.type }} {{ allenv.otherParams }} @@ -463,15 +466,13 @@

{{userlogged}}

{{ allenv.host }} {{ allenv.port }} - - PLAIN + + PLAINTEXT - - {{ allenv.protocol}} {{ allenv.type }} diff --git a/src/main/resources/templates/execAcls.html b/src/main/resources/templates/execAcls.html index 3a74056..8656b9a 100644 --- a/src/main/resources/templates/execAcls.html +++ b/src/main/resources/templates/execAcls.html @@ -19,7 +19,7 @@ - + @@ -56,23 +56,7 @@ - + @@ -82,17 +66,11 @@ @@ -143,7 +121,6 @@
Schema Requests
- @@ -158,8 +135,8 @@
Schema Requests
+ @@ -385,7 +388,7 @@
Consumer Group
{{ aclRequest[0].consumergroup }}
IP Address
{{ aclRequest[0].acl_ip }}
-
SSL
{{ aclRequest[0].acl_ssl }} +
Principle
{{ aclRequest[0].acl_ssl }}
Requestor
{{ aclRequest[0].username }} diff --git a/src/main/resources/templates/execSchemas.html b/src/main/resources/templates/execSchemas.html index 523d303..e8bdb69 100644 --- a/src/main/resources/templates/execSchemas.html +++ b/src/main/resources/templates/execSchemas.html @@ -19,7 +19,7 @@ - + @@ -56,23 +56,7 @@ - + @@ -82,12 +66,7 @@
@@ -199,8 +177,8 @@
Schema Requests
+ diff --git a/src/main/resources/templates/execTopics.html b/src/main/resources/templates/execTopics.html index 4281f12..61f03d7 100644 --- a/src/main/resources/templates/execTopics.html +++ b/src/main/resources/templates/execTopics.html @@ -19,7 +19,7 @@ - + @@ -56,23 +56,7 @@ - + @@ -82,12 +66,7 @@ + diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 2fd08f4..9b51bf4 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -21,7 +21,7 @@ - + @@ -56,23 +56,7 @@ - + @@ -82,12 +66,7 @@ + @@ -428,7 +391,7 @@

My Topic Requests

{{ topicRequest.environment }} - {{ topicRequest.username }} + {{ topicRequest.requestor }} @@ -446,7 +409,7 @@

My Topic Requests

{{ topicRequest.requesttimestring }} diff --git a/src/main/resources/templates/requestAcls.html b/src/main/resources/templates/requestAcls.html index d24d1e7..67f0291 100644 --- a/src/main/resources/templates/requestAcls.html +++ b/src/main/resources/templates/requestAcls.html @@ -19,7 +19,7 @@ - + @@ -55,23 +55,7 @@ - + @@ -81,12 +65,7 @@ + @@ -454,7 +458,7 @@

{{userlogged}}

- + @@ -474,7 +478,7 @@

{{userlogged}}

- + diff --git a/src/main/resources/templates/requestSchema.html b/src/main/resources/templates/requestSchema.html index a989da2..9d6794e 100644 --- a/src/main/resources/templates/requestSchema.html +++ b/src/main/resources/templates/requestSchema.html @@ -19,7 +19,7 @@ - + @@ -55,23 +55,7 @@ - + @@ -81,12 +65,7 @@
@@ -197,8 +175,8 @@
Schema Requests
+
diff --git a/src/main/resources/templates/requestTopics.html b/src/main/resources/templates/requestTopics.html index ee03494..027a20c 100644 --- a/src/main/resources/templates/requestTopics.html +++ b/src/main/resources/templates/requestTopics.html @@ -19,7 +19,7 @@ - + @@ -55,23 +55,7 @@ - + @@ -81,12 +65,7 @@ + @@ -414,6 +418,7 @@

{{userlogged}}

+
@@ -431,9 +436,6 @@

{{userlogged}}

- - - diff --git a/src/main/resources/templates/serverConfig.html b/src/main/resources/templates/serverConfig.html index 8af5bb5..715ea2c 100644 --- a/src/main/resources/templates/serverConfig.html +++ b/src/main/resources/templates/serverConfig.html @@ -19,7 +19,7 @@ - + @@ -59,23 +59,7 @@ - + @@ -85,12 +69,7 @@ + diff --git a/src/main/resources/templates/showTeams.html b/src/main/resources/templates/showTeams.html index 3df1877..5549947 100644 --- a/src/main/resources/templates/showTeams.html +++ b/src/main/resources/templates/showTeams.html @@ -19,7 +19,7 @@ - + @@ -59,23 +59,7 @@ - + @@ -85,12 +69,7 @@ + @@ -407,7 +411,7 @@

{{userlogged}}

{{ teamDetails.contactperson }} diff --git a/src/main/resources/templates/showUsers.html b/src/main/resources/templates/showUsers.html index 921a11e..9ff649d 100644 --- a/src/main/resources/templates/showUsers.html +++ b/src/main/resources/templates/showUsers.html @@ -19,7 +19,7 @@ - + @@ -59,23 +59,7 @@ - + @@ -85,12 +69,7 @@ + @@ -381,7 +385,7 @@

{{userlogged}}

- + @@ -413,7 +417,7 @@

{{userlogged}}

diff --git a/src/main/resources/templates/synchronizeAcls.html b/src/main/resources/templates/synchronizeAcls.html index 42da233..a9a8a68 100644 --- a/src/main/resources/templates/synchronizeAcls.html +++ b/src/main/resources/templates/synchronizeAcls.html @@ -19,7 +19,7 @@ - + @@ -84,23 +84,7 @@ - + @@ -110,12 +94,7 @@ + @@ -357,158 +361,24 @@

{{userlogged}}

-
-
-
- - -
-
-
-
- - - -
-
-
- - -
-
-
-
Notification
-

No topics found !! Please check kafka connectivity or if you have selected the right cluster/topics.

-
-
-
-
-
-
-
Notification
-

{{ alerttop }}

-
-
-
- - -
-
-
-
Notification
-

{{ alert }}

-
-
-
-
-
-
-
Notification
-

{{ errorMessage }}

-
-
-
- -
+
Notification
-

You are not authorized to access this page !!

+

Sorry, this feature is removed.

-
-
-
- -
- - - - -

Synchronize Acls - Owners

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TeamTopicNameConsumerGroupHostsPrincipleAclType
- - {{ resultBrowset.topicname}}{{ resultBrowset.consumergroup}}{{ resultBrowset.acl_ip}}{{ resultBrowset.acl_ssl}} - {{ resultBrowset.topictype}} - {{ resultBrowset.topictype}}
-
-
-
-
- - - - -
- -
-
-
{{ alert }}
-
{{ alertnote }}
-
- -
- - -
-
-
diff --git a/src/main/resources/templates/synchronizeTopics.html b/src/main/resources/templates/synchronizeTopics.html index 211dd53..647d6ef 100644 --- a/src/main/resources/templates/synchronizeTopics.html +++ b/src/main/resources/templates/synchronizeTopics.html @@ -19,7 +19,7 @@ - + @@ -84,23 +84,7 @@ - + @@ -110,12 +94,7 @@ +
@@ -357,148 +362,15 @@

{{userlogged}}

-
-
-
- - -
-
-
-
- - - -
-
-
- - -
-
-
-
Notification
-

No topics found !! Please check kafka connectivity or if you have selected the right cluster/topics.

-
-
-
- - - -
-
-
-
Notification
-

{{ alerttop }}

-
-
-
- - - -
-
-
-
Notification
-

{{ alert }}

-
-
-
- - - -
-
-
-
Notification
-

{{ errorMessage }}

-
-
-
- -
+
Notification
-

You are not authorized to access this page !!

+

Sorry, this feature is removed.

-
-
-
-
- - - -

Synchronize Topics - Owners

-
- - - - - - - - - - - - - - - - - - - - -
TopicNamePartitionsReplication FactorTeam
{{ resultBrowset.topicname}}{{ resultBrowset.topicpartitions}}{{ resultBrowset.replicationfactor}} - -
-
-
-
-
- - - - -
-
{{ alert }}
-
{{ alertnote }}
-
- -
- - -
- -
-
- diff --git a/src/test/java/com/kafkamgt/integrationtests/cassandra/TopicAclControllerIT.java b/src/test/java/com/kafkamgt/integrationtests/cassandra/TopicAclControllerIT.java index 788f4c1..ab3943e 100644 --- a/src/test/java/com/kafkamgt/integrationtests/cassandra/TopicAclControllerIT.java +++ b/src/test/java/com/kafkamgt/integrationtests/cassandra/TopicAclControllerIT.java @@ -35,8 +35,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.when; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; @@ -190,24 +189,6 @@ public void test006() throws Exception { assertThat(res, CoreMatchers.containsString("Team1")); } - // Update team of a topic - @Test - public void test007() throws Exception { - List syncTopicUpdates = utilMethods.getSyncTopicUpdates(); - String jsonReq = new ObjectMapper().writer().writeValueAsString(syncTopicUpdates); - - login("superuser","user", "SUPERUSER"); - String response = mvc.perform(MockMvcRequestBuilders - .post("/updateSyncTopics").with(user("superuser").password("user").roles("SUPERUSER")) - .content(jsonReq) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - assertThat(response, CoreMatchers.containsString("success")); - } - // delete a topic request of his own @Test public void test008() throws Exception { @@ -239,7 +220,8 @@ public void test008() throws Exception { // get topics from cluster @Test public void test009() throws Exception { - when(clusterApiService.getAllTopics(anyString())).thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); + when(clusterApiService.getAllTopics(anyString(), eq("PLAINTEXT"))) + .thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); String res = mvc.perform(MockMvcRequestBuilders .get("/getTopics").with(user("uiuser1").password("user")) @@ -259,7 +241,8 @@ public void test009() throws Exception { //get only topic names @Test public void test010() throws Exception { - when(clusterApiService.getAllTopics(anyString())).thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); + when(clusterApiService.getAllTopics(anyString(), eq("PLAINTEXT"))) + .thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); String res = mvc.perform(MockMvcRequestBuilders .get("/getTopicsOnly").with(user("uiuser1").password("user")) @@ -273,25 +256,6 @@ public void test010() throws Exception { assertEquals(1, response.size()); } - // get all topics which can be updated with new team ids - @Test - public void test011() throws Exception { - when(clusterApiService.getAllTopics(anyString())).thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); - - String res = mvc.perform(MockMvcRequestBuilders - .get("/getSyncTopics").with(user("uiuser1").password("user")) - .param("env","DEV") - .param("pageNo","1") - .param("topicnamesearch","testtopic") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - List response = new ObjectMapper().readValue(res, List.class); - assertEquals(10, response.size()); - } - // Get Acl requests before creating one @Test @@ -390,7 +354,7 @@ public void test05() throws Exception { // Request for a acl @Test public void test06() throws Exception { - AclRequests addAclRequest = utilMethods.getAclRequest("testtopic1"); + AclRequests addAclRequest = utilMethods.getAclRequest("testtopic"); String jsonReq = new ObjectMapper().writer().writeValueAsString(addAclRequest); String response = mvc.perform(MockMvcRequestBuilders @@ -458,34 +422,13 @@ public void test08() throws Exception { assertThat(responseNew, CoreMatchers.containsString("success")); } - // update acls with team - sync - @Test - public void test09() throws Exception { - - List syncUpdates = utilMethods.getSyncAclsUpdates(); - - String jsonReq = new ObjectMapper().writer().writeValueAsString(syncUpdates); - - login("superuser","user", "SUPERUSER"); - - String response = mvc.perform(MockMvcRequestBuilders - .post("/updateSyncAcls").with(user("superuser").password("user").roles("SUPERUSER")) - .content(jsonReq) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - assertThat(response, CoreMatchers.containsString("success")); - } - // getacls with topic search filter @Test public void test11() throws Exception { List> aclInfo = new ArrayList<>(utilMethods.getClusterAcls2()); - when(clusterApiService.getAcls(anyString())) + when(clusterApiService.getAcls(anyString(), eq("PLAINTEXT"))) .thenReturn(aclInfo); String res = mvc.perform(get("/getAcls").with(user("uiuser1").password("user")) @@ -499,25 +442,6 @@ public void test11() throws Exception { assertEquals(1, response.getAclInfoList().size()); } - // get acls to be synced - retrieve from Source of truth - @Test - public void test13() throws Exception { - List> aclInfo = utilMethods.getClusterAcls(); - - when(clusterApiService.getAcls(anyString())) - .thenReturn(aclInfo); - - String res = mvc.perform(get("/getSyncAcls").with(user("superuser").password("user").roles("SUPERUSER")) - .param("env","DEV") - .param("pageNo","1") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - List response = new ObjectMapper().readValue(res, List.class); - assertEquals(1, response.size()); - } private void login(String user, String pwd, String role) throws Exception { mvc.perform(get("/login").with(user(user).password(pwd).roles(role)) diff --git a/src/test/java/com/kafkamgt/integrationtests/rdbms/TopicAclControllerIT.java b/src/test/java/com/kafkamgt/integrationtests/rdbms/TopicAclControllerIT.java index a920b39..3f759be 100644 --- a/src/test/java/com/kafkamgt/integrationtests/rdbms/TopicAclControllerIT.java +++ b/src/test/java/com/kafkamgt/integrationtests/rdbms/TopicAclControllerIT.java @@ -186,24 +186,6 @@ public void test006() throws Exception { assertThat(res, CoreMatchers.containsString("Team1")); } - // Update team of a topic - @Test - public void test007() throws Exception { - List syncTopicUpdates = utilMethods.getSyncTopicUpdates(); - String jsonReq = new ObjectMapper().writer().writeValueAsString(syncTopicUpdates); - - login("superuser","user", "SUPERUSER"); - String response = mvc.perform(MockMvcRequestBuilders - .post("/updateSyncTopics").with(user("superuser").password("user").roles("SUPERUSER")) - .content(jsonReq) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - assertThat(response, CoreMatchers.containsString("success")); - } - // delete a topic request of his own @Test public void test008() throws Exception { @@ -235,7 +217,8 @@ public void test008() throws Exception { // get topics from cluster @Test public void test009() throws Exception { - when(clusterApiService.getAllTopics(anyString())).thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); + when(clusterApiService.getAllTopics(anyString(), eq("PLAINTEXT"))) + .thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); String res = mvc.perform(MockMvcRequestBuilders .get("/getTopics").with(user("uiuser1").password("user")) @@ -255,7 +238,8 @@ public void test009() throws Exception { //get only topic names @Test public void test010() throws Exception { - when(clusterApiService.getAllTopics(anyString())).thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); + when(clusterApiService.getAllTopics(anyString(), eq("PLAINTEXT"))) + .thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); String res = mvc.perform(MockMvcRequestBuilders .get("/getTopicsOnly").with(user("uiuser1").password("user")) @@ -269,25 +253,6 @@ public void test010() throws Exception { assertEquals(1, response.size()); } - // get all topics which can be updated with new team ids - @Test - public void test011() throws Exception { - when(clusterApiService.getAllTopics(anyString())).thenReturn(utilMethods.getClusterApiTopics("testtopic",10)); - - String res = mvc.perform(MockMvcRequestBuilders - .get("/getSyncTopics").with(user("uiuser1").password("user")) - .param("env","DEV") - .param("pageNo","1") - .param("topicnamesearch","testtopic") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - List response = new ObjectMapper().readValue(res, List.class); - assertEquals(10, response.size()); - } - // Get Acl requests before creating one @Test @@ -386,7 +351,7 @@ public void test05() throws Exception { // Request for a acl @Test public void test06() throws Exception { - AclRequests addAclRequest = utilMethods.getAclRequest("testtopic1"); + AclRequests addAclRequest = utilMethods.getAclRequest("testtopic"); String jsonReq = new ObjectMapper().writer().writeValueAsString(addAclRequest); String response = mvc.perform(MockMvcRequestBuilders @@ -454,34 +419,13 @@ public void test08() throws Exception { assertThat(responseNew, CoreMatchers.containsString("success")); } - // update acls with team - sync - @Test - public void test09() throws Exception { - - List syncUpdates = utilMethods.getSyncAclsUpdates(); - - String jsonReq = new ObjectMapper().writer().writeValueAsString(syncUpdates); - - login("superuser","user", "SUPERUSER"); - - String response = mvc.perform(MockMvcRequestBuilders - .post("/updateSyncAcls").with(user("superuser").password("user").roles("SUPERUSER")) - .content(jsonReq) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - assertThat(response, CoreMatchers.containsString("success")); - } - // getacls with topic search filter @Test public void test11() throws Exception { List> aclInfo = new ArrayList<>(utilMethods.getClusterAcls2()); - when(clusterApiService.getAcls(anyString())) + when(clusterApiService.getAcls(anyString(), eq("PLAINTEXT"))) .thenReturn(aclInfo); String res = mvc.perform(get("/getAcls").with(user("uiuser1").password("user")) @@ -495,26 +439,6 @@ public void test11() throws Exception { assertEquals(1, response.getAclInfoList().size()); } - // get acls to be synced - retrieve from Source of truth - @Test - public void test13() throws Exception { - List> aclInfo = utilMethods.getClusterAcls(); - - when(clusterApiService.getAcls(anyString())) - .thenReturn(aclInfo); - - String res = mvc.perform(get("/getSyncAcls").with(user("superuser").password("user").roles("SUPERUSER")) - .param("env","DEV") - .param("pageNo","1") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - List response = new ObjectMapper().readValue(res, List.class); - assertEquals(1, response.size()); - } - private void login(String user, String pwd, String role) throws Exception { mvc.perform(get("/login").with(user(user).password(pwd).roles(role)) .contentType(MediaType.APPLICATION_JSON) diff --git a/src/test/java/com/kafkamgt/uiapi/UtilMethods.java b/src/test/java/com/kafkamgt/uiapi/UtilMethods.java index b9ebf5b..23c70c3 100644 --- a/src/test/java/com/kafkamgt/uiapi/UtilMethods.java +++ b/src/test/java/com/kafkamgt/uiapi/UtilMethods.java @@ -69,6 +69,17 @@ public List getUserInfoList(String username, String role){ return userInfoList; } + public List getUserInfoListModel(String username, String role){ + List userInfoList = new ArrayList<>(); + UserInfoModel userInfo = new UserInfoModel(); + userInfo.setTeam("Team1"); + userInfo.setUsername(username); + userInfo.setRole(role); + userInfoList.add(userInfo); + + return userInfoList; + } + public List getLogs(){ List activityLogs = new ArrayList<>(); ActivityLog activityLog = new ActivityLog(); @@ -103,6 +114,7 @@ public List getTopics() { topicRequest.setTopicPK(topicPK); topicRequest.setTeamname("Team1"); + topicRequest.setEnvironment("DEV"); allTopicReqs.add(topicRequest); return allTopicReqs; } diff --git a/src/test/java/com/kafkamgt/uiapi/controller/AclControllerTest.java b/src/test/java/com/kafkamgt/uiapi/controller/AclControllerTest.java index 5546faf..bbbd857 100644 --- a/src/test/java/com/kafkamgt/uiapi/controller/AclControllerTest.java +++ b/src/test/java/com/kafkamgt/uiapi/controller/AclControllerTest.java @@ -70,27 +70,7 @@ public void createAcl() throws Exception { assertEquals("success", response); } - @Test - public void updateSyncAcls() throws Exception { - List syncUpdates = utilMethods.getSyncAclsUpdates(); - - String jsonReq = new ObjectMapper().writer().writeValueAsString(syncUpdates); - HashMap result = new HashMap<>(); - result.put("result","success"); - when(aclControllerService.updateSyncAcls(any())).thenReturn(result); - String response = mvc.perform(MockMvcRequestBuilders - .post("/updateSyncAcls") - .content(jsonReq) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - HashMap actualResult = new ObjectMapper().readValue(response, new TypeReference>(){}); - - assertEquals("success", actualResult.get("result")); - } @Test public void getAclRequests() throws Exception { @@ -208,23 +188,5 @@ public void getAcls2() throws Exception { .andReturn().getResponse().getContentAsString(); } - @Test - public void getSyncAcls() throws Exception { - List aclInfo = utilMethods.getAclInfoList(); - - when(aclControllerService.getSyncAcls(anyString(), anyString(), any())) - .thenReturn(aclInfo); - String res = mvc.perform(MockMvcRequestBuilders - .get("/getSyncAcls") - .param("env","DEV") - .param("pageNo","1") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - List response = new ObjectMapper().readValue(res, List.class); - assertEquals(1, response.size()); - } } \ No newline at end of file diff --git a/src/test/java/com/kafkamgt/uiapi/controller/TopicControllerTest.java b/src/test/java/com/kafkamgt/uiapi/controller/TopicControllerTest.java index f1cc51e..e102a32 100644 --- a/src/test/java/com/kafkamgt/uiapi/controller/TopicControllerTest.java +++ b/src/test/java/com/kafkamgt/uiapi/controller/TopicControllerTest.java @@ -68,26 +68,7 @@ public void createTopics() throws Exception { assertEquals("success", response); } - @Test - public void updateSyncTopics() throws Exception { - List syncTopicUpdates = utilMethods.getSyncTopicUpdates(); - String jsonReq = new ObjectMapper().writer().writeValueAsString(syncTopicUpdates); - HashMap resultMap = new HashMap<>(); - resultMap.put("result","success"); - when(topicControllerService.updateSyncTopics(any())).thenReturn(resultMap); - String response = mvc.perform(MockMvcRequestBuilders - .post("/updateSyncTopics") - .content(jsonReq) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - HashMap actualResult = new ObjectMapper().readValue(response, new TypeReference>(){}); - - assertEquals("success", actualResult.get("result")); - } @Test public void getTopicRequests() throws Exception { @@ -223,23 +204,5 @@ public void getTopicsOnly() throws Exception { assertEquals(2, response.size()); } - @Test - public void getSyncTopics() throws Exception { - List topicRequests = utilMethods.getTopicRequests(); - - when(topicControllerService.getSyncTopics(anyString(), anyString(), anyString())).thenReturn(topicRequests); - String res = mvc.perform(MockMvcRequestBuilders - .get("/getSyncTopics") - .param("env","DEV") - .param("pageNo","1") - .param("topicnamesearch","testtopic") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - List response = new ObjectMapper().readValue(res, List.class); - assertEquals(1, response.size()); - } } \ No newline at end of file diff --git a/src/test/java/com/kafkamgt/uiapi/controller/UiConfigControllerTest.java b/src/test/java/com/kafkamgt/uiapi/controller/UiConfigControllerTest.java index e91d492..b05e110 100644 --- a/src/test/java/com/kafkamgt/uiapi/controller/UiConfigControllerTest.java +++ b/src/test/java/com/kafkamgt/uiapi/controller/UiConfigControllerTest.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.kafkamgt.uiapi.UtilMethods; import com.kafkamgt.uiapi.dao.*; +import com.kafkamgt.uiapi.model.UserInfoModel; import com.kafkamgt.uiapi.service.UiConfigControllerService; import org.hamcrest.CoreMatchers; import org.junit.Before; @@ -325,7 +326,7 @@ public void changePwd() throws Exception { @Test public void showUsers() throws Exception { - List userList = utilMethods.getUserInfoList("uiuser","ADMIN"); + List userList = utilMethods.getUserInfoListModel("uiuser","ADMIN"); when(uiConfigControllerService.showUsers()).thenReturn(userList); String res = mvc.perform(MockMvcRequestBuilders diff --git a/src/test/java/com/kafkamgt/uiapi/controller/UiControllerLoginTest.java b/src/test/java/com/kafkamgt/uiapi/controller/UiControllerLoginTest.java index 1722aa4..6213d86 100644 --- a/src/test/java/com/kafkamgt/uiapi/controller/UiControllerLoginTest.java +++ b/src/test/java/com/kafkamgt/uiapi/controller/UiControllerLoginTest.java @@ -1,5 +1,8 @@ package com.kafkamgt.uiapi.controller; +import com.kafkamgt.uiapi.config.ManageDatabase; +import com.kafkamgt.uiapi.dao.UserInfo; +import com.kafkamgt.uiapi.helpers.HandleDbRequests; import com.kafkamgt.uiapi.service.UtilService; import org.hamcrest.CoreMatchers; import org.junit.Before; @@ -38,6 +41,18 @@ public class UiControllerLoginTest { private UserDetails userDetails; + @Mock + private + HandleDbRequests handleDbRequests; + + @Mock + private + ManageDatabase manageDatabase; + + @Mock + private + UserInfo userInfo; + private MockMvc mvc; @Before @@ -47,6 +62,7 @@ public void setUp() throws Exception { .standaloneSetup(uiControllerLogin) .dispatchOptions(true) .build(); + ReflectionTestUtils.setField(uiControllerLogin, "manageDatabase", manageDatabase); } private void mvcPerformAndAssert(String uri, String fwdedUrl) throws Exception { @@ -65,6 +81,8 @@ private void loginMock(){ SecurityContext securityContext = Mockito.mock(SecurityContext.class); when(securityContext.getAuthentication()).thenReturn(authentication); when(authentication.getPrincipal()).thenReturn(userDetails); + when(manageDatabase.getHandleDbRequests()).thenReturn(handleDbRequests); + when(handleDbRequests.getUsersInfo(userDetails.getUsername())).thenReturn(userInfo); SecurityContextHolder.setContext(securityContext); } @@ -80,6 +98,8 @@ public void login2() throws Exception { SecurityContext securityContext = Mockito.mock(SecurityContext.class); when(securityContext.getAuthentication()).thenReturn(authentication); when(authentication.getPrincipal()).thenReturn(userDetails); + when(manageDatabase.getHandleDbRequests()).thenReturn(handleDbRequests); + when(handleDbRequests.getUsersInfo(userDetails.getUsername())).thenReturn(userInfo); SecurityContextHolder.setContext(securityContext); mvcPerformAndAssert("/login", "index"); diff --git a/src/test/java/com/kafkamgt/uiapi/helpers/db/rdbms/DeleteDataJdbcTest.java b/src/test/java/com/kafkamgt/uiapi/helpers/db/rdbms/DeleteDataJdbcTest.java index c713eb0..f7facee 100644 --- a/src/test/java/com/kafkamgt/uiapi/helpers/db/rdbms/DeleteDataJdbcTest.java +++ b/src/test/java/com/kafkamgt/uiapi/helpers/db/rdbms/DeleteDataJdbcTest.java @@ -90,7 +90,7 @@ public void deleteTeamRequest() { @Test public void deletePrevAclRecs() { List acls = utilMethods.getAclsForDelete(); - when(aclRepo.findAll()).thenReturn(utilMethods.getAllAcls()); + //when(aclRepo.findAll()).thenReturn(utilMethods.getAllAcls()); String result = deleteDataJdbc.deletePrevAclRecs(acls); assertEquals("success", result); diff --git a/src/test/java/com/kafkamgt/uiapi/helpers/db/rdbms/UpdateDataJdbcTest.java b/src/test/java/com/kafkamgt/uiapi/helpers/db/rdbms/UpdateDataJdbcTest.java index a09b8da..881f28c 100644 --- a/src/test/java/com/kafkamgt/uiapi/helpers/db/rdbms/UpdateDataJdbcTest.java +++ b/src/test/java/com/kafkamgt/uiapi/helpers/db/rdbms/UpdateDataJdbcTest.java @@ -4,6 +4,7 @@ import com.kafkamgt.uiapi.dao.AclRequests; import com.kafkamgt.uiapi.dao.SchemaRequest; import com.kafkamgt.uiapi.dao.TopicRequest; +import com.kafkamgt.uiapi.dao.UserInfo; import com.kafkamgt.uiapi.repository.AclRequestsRepo; import com.kafkamgt.uiapi.repository.SchemaRequestRepo; import com.kafkamgt.uiapi.repository.TopicRequestsRepo; @@ -15,6 +16,8 @@ import org.mockito.junit.MockitoJUnitRunner; import org.springframework.test.util.ReflectionTestUtils; +import java.util.Optional; + import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -45,6 +48,9 @@ public class UpdateDataJdbcTest { private UtilMethods utilMethods; + @Mock + UserInfo userInfo; + @Before public void setUp() throws Exception { updateData = new UpdateDataJdbc(topicRequestsRepo, aclRequestsRepo, @@ -98,7 +104,9 @@ public void declineAclRequest() { @Test public void updatePassword() { - String result = updateData.updatePassword("uiuser1", "pwd"); + String user = "uiuser1"; + when(userInfoRepo.findById(user)).thenReturn(Optional.of(userInfo)); + String result = updateData.updatePassword(user, "pwd"); assertEquals("success", result); } diff --git a/src/test/java/com/kafkamgt/uiapi/service/AclControllerServiceTest.java b/src/test/java/com/kafkamgt/uiapi/service/AclControllerServiceTest.java index bfb0733..0ab9ffa 100644 --- a/src/test/java/com/kafkamgt/uiapi/service/AclControllerServiceTest.java +++ b/src/test/java/com/kafkamgt/uiapi/service/AclControllerServiceTest.java @@ -2,10 +2,7 @@ import com.kafkamgt.uiapi.UtilMethods; import com.kafkamgt.uiapi.config.ManageDatabase; -import com.kafkamgt.uiapi.dao.Acl; -import com.kafkamgt.uiapi.dao.AclRequests; -import com.kafkamgt.uiapi.dao.Env; -import com.kafkamgt.uiapi.dao.Team; +import com.kafkamgt.uiapi.dao.*; import com.kafkamgt.uiapi.error.KafkawizeException; import com.kafkamgt.uiapi.helpers.HandleDbRequests; import com.kafkamgt.uiapi.model.AclInfo; @@ -15,7 +12,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; @@ -31,9 +27,7 @@ import java.util.*; import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) @@ -73,6 +67,7 @@ public void setUp() throws Exception { env.setHost("101.10.11.11"); env.setPort("9092"); env.setName("DEV"); + env.setProtocol("PLAINTEXT"); ReflectionTestUtils.setField(aclControllerService, "manageDatabase", manageDatabase); when(manageDatabase.getHandleDbRequests()).thenReturn(handleDbRequests); loginMock(); @@ -93,55 +88,16 @@ private void loginMock(){ @Test public void createAcl() { AclRequests aclRequests = getAclRequest(); + List topicList = utilMethods.getTopics(); + + when(handleDbRequests.getTopics(any())).thenReturn(topicList); when(handleDbRequests.requestForAcl(aclRequests)).thenReturn("success"); String result = aclControllerService.createAcl(aclRequests); assertEquals("{\"result\":\"success\"}",result); } - @Test - public void updateSyncAcls() { - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(true); - when(handleDbRequests.addToSyncacls(anyList())).thenReturn("success"); - - HashMap result = aclControllerService.updateSyncAcls(utilMethods.getSyncAclsUpdates()); - assertEquals("success",result.get("result")); - } - - @Test - public void updateSyncAclsFailure1() { - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(false); - - HashMap result = aclControllerService.updateSyncAcls(utilMethods.getSyncAclsUpdates()); - assertEquals("Not Authorized.",result.get("result")); - } - - @Test - public void updateSyncAclsFailure2() { - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(true); - when(handleDbRequests.addToSyncacls(anyList())).thenThrow(new RuntimeException("Error")); - HashMap result = aclControllerService.updateSyncAcls(utilMethods.getSyncAclsUpdates()); - assertThat(result.get("result"), CoreMatchers.containsString("Failure")); - } - - @Test - public void updateSyncAclsFailure3() { - List updates = new ArrayList<>(); - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(true); - - HashMap result = aclControllerService.updateSyncAcls(updates); - assertEquals("No record updated.",result.get("result")); - } - - @Test - public void updateSyncAclsFailure4() { - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(true); - when(handleDbRequests.addToSyncacls(anyList())).thenThrow(new RuntimeException("Error")); - - HashMap result = aclControllerService.updateSyncAcls(utilMethods.getSyncAclsUpdates()); - assertThat(result.get("result"), CoreMatchers.containsString("Failure")); - } @Test public void getAclRequests() { @@ -294,47 +250,7 @@ public void getAclsSyncFalse2() throws KafkawizeException { assertEquals("2.1.2.1", aclList.get(0).getAcl_ip()); } - @Test - public void getAclsSyncTrue1() throws KafkawizeException { - String envSelected = "DEV", pageNo = "1", topicNameSearch = "testtopic1"; - boolean isSyncAcls = true; - - when(userDetails.getUsername()).thenReturn("uiuser1"); - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(true); - when(handleDbRequests.selectEnvDetails(envSelected)).thenReturn(this.env); - when(clusterApiService.getAcls(any())) - .thenReturn(utilMethods.getClusterAcls()); - when(handleDbRequests.selectAllTeamsOfUsers(any())).thenReturn(getAvailableTeams()); - when(handleDbRequests.getSyncAcls(envSelected)).thenReturn(getAclsSOT0()); - - List aclList = aclControllerService.getSyncAcls(envSelected, pageNo, topicNameSearch); - - assertEquals(1, aclList.size()); - assertEquals("testtopic1",aclList.get(0).getTopicname()); - assertEquals("mygrp1",aclList.get(0).getConsumergroup()); - assertEquals("2.1.2.1", aclList.get(0).getAcl_ip()); - } - @Test - public void getAclsSyncTrue2() throws KafkawizeException { - String envSelected = "DEV", pageNo = "1", topicNameSearch = "test"; - boolean isSyncAcls = true; - - when(userDetails.getUsername()).thenReturn("uiuser1"); - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(true); - when(handleDbRequests.selectEnvDetails(envSelected)).thenReturn(this.env); - when(clusterApiService.getAcls(any())) - .thenReturn(utilMethods.getClusterAcls()); - when(handleDbRequests.selectAllTeamsOfUsers(any())).thenReturn(getAvailableTeams()); - when(handleDbRequests.getSyncAcls(envSelected)).thenReturn(getAclsSOT0()); - - List aclList = aclControllerService.getSyncAcls(envSelected, pageNo, topicNameSearch); - - assertEquals(1, aclList.size()); - assertEquals("testtopic1",aclList.get(0).getTopicname()); - assertEquals("mygrp1",aclList.get(0).getConsumergroup()); - assertEquals("2.1.2.1", aclList.get(0).getAcl_ip()); - } private List getAvailableTeams(){ @@ -397,6 +313,7 @@ private AclRequests getAclRequest(){ aclReq.setTopictype("producer"); aclReq.setRequestingteam("Team1"); aclReq.setReq_no("112"); + aclReq.setEnvironment("DEV"); return aclReq; } diff --git a/src/test/java/com/kafkamgt/uiapi/service/ClusterApiServiceTest.java b/src/test/java/com/kafkamgt/uiapi/service/ClusterApiServiceTest.java index ed60d98..637d4dc 100644 --- a/src/test/java/com/kafkamgt/uiapi/service/ClusterApiServiceTest.java +++ b/src/test/java/com/kafkamgt/uiapi/service/ClusterApiServiceTest.java @@ -12,7 +12,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; @@ -83,7 +82,7 @@ public void getStatusSuccess() { result = clusterApiService.getSchemaClusterStatus(""); assertEquals("success",result); - result = clusterApiService.getKafkaClusterStatus(""); + result = clusterApiService.getKafkaClusterStatus("", "PLAINTEXT"); assertEquals("success",result); } @@ -103,7 +102,7 @@ public void getStatusFailure() { result = clusterApiService.getSchemaClusterStatus(""); assertEquals("OFFLINE",result); - result = clusterApiService.getKafkaClusterStatus(""); + result = clusterApiService.getKafkaClusterStatus("", "PLAINTEXT"); assertEquals("NOT_KNOWN",result); } @@ -119,7 +118,7 @@ public void getAclsSuccess() throws KafkawizeException { eq(Set.class))) .thenReturn(response); - List> result = clusterApiService.getAcls(""); + List> result = clusterApiService.getAcls("", "PLAINTEXT"); assertEquals(result, new ArrayList<>(aclListOriginal)); } @@ -132,7 +131,7 @@ public void getAclsFailure() throws KafkawizeException { eq(Set.class))) .thenThrow(new RuntimeException("error")); - clusterApiService.getAcls(""); + clusterApiService.getAcls("", "PLAINTEXT"); } @Test @@ -146,7 +145,7 @@ public void getAllTopicsSuccess() throws Exception { eq(Set.class))) .thenReturn(response); - List> result = clusterApiService.getAllTopics(""); + List> result = clusterApiService.getAllTopics("", "PLAINTEXT"); assertEquals(result, new ArrayList<>(topicsList)); } @@ -159,7 +158,7 @@ public void getAllTopicsFailure() throws Exception { eq(Set.class))) .thenThrow(new RuntimeException("error")); - clusterApiService.getAllTopics(""); + clusterApiService.getAllTopics("", "PLAINTEXT"); } @Test diff --git a/src/test/java/com/kafkamgt/uiapi/service/TopicControllerServiceTest.java b/src/test/java/com/kafkamgt/uiapi/service/TopicControllerServiceTest.java index fe55a70..88c92d7 100644 --- a/src/test/java/com/kafkamgt/uiapi/service/TopicControllerServiceTest.java +++ b/src/test/java/com/kafkamgt/uiapi/service/TopicControllerServiceTest.java @@ -70,6 +70,7 @@ public void setUp() throws Exception { this.env = new Env(); env.setHost("101.10.11.11"); env.setPort("9092"); + env.setProtocol("PLAINTEXT"); env.setName("DEV"); ReflectionTestUtils.setField(topicControllerService, "manageDatabase", manageDatabase); ReflectionTestUtils.setField(topicControllerService, "syncCluster", "DEV"); @@ -159,39 +160,7 @@ public void createTopicsFailure3() throws KafkawizeException { assertEquals("{\"result\":\"failure\"}",result); } - @Test - public void updateSyncTopicsSuccess() { - String teamSelected = "Team1"; - HashMap resultMap = new HashMap<>(); - resultMap.put("result","success"); - - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(true); - when(handleDbRequests.addToSynctopics(any())).thenReturn("success"); - - HashMap result = topicControllerService.updateSyncTopics(utilMethods.getSyncTopicUpdates()); - - assertEquals("success",result.get("result")); - } - - @Test - public void updateSyncTopicsNoUpdate() { - List topicUpdates = new ArrayList<>(); - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(true); - - HashMap result = topicControllerService.updateSyncTopics(topicUpdates); - - assertEquals("No record updated.",result.get("result")); - } - - @Test - public void updateSyncTopicsNotAuthorized() { - String teamSelected = "Team1"; - when(utilService.checkAuthorizedSU(userDetails)).thenReturn(false); - HashMap result = topicControllerService.updateSyncTopics(utilMethods.getSyncTopicUpdates()); - - assertEquals("Not Authorized.",result.get("result")); - } @Test public void getCreatedTopicRequests1() { @@ -314,18 +283,7 @@ public void getTopicsSearchFailure() throws Exception { assertNull(topicsList); } - @Test - public void getSyncTopics() throws Exception { - String envSel = "DEV", pageNo = "1", topicNameSearch = "top"; - when(handleDbRequests.selectEnvDetails(envSel)).thenReturn(this.env); - when(clusterApiService.getAllTopics(this.env.getHost()+":"+this.env.getPort())) - .thenReturn(utilMethods.getClusterApiTopics("topic",10)); - when(handleDbRequests.selectAllTeamsOfUsers(any())).thenReturn(getAvailableTeams()); - - List topicRequests = topicControllerService.getSyncTopics(envSel, pageNo, topicNameSearch); - assertEquals(topicRequests.size(),10); - } @Test public void declineTopicRequests() throws KafkawizeException { diff --git a/src/test/java/com/kafkamgt/uiapi/service/UiConfigControllerServiceTest.java b/src/test/java/com/kafkamgt/uiapi/service/UiConfigControllerServiceTest.java index 5ec08a6..e804408 100644 --- a/src/test/java/com/kafkamgt/uiapi/service/UiConfigControllerServiceTest.java +++ b/src/test/java/com/kafkamgt/uiapi/service/UiConfigControllerServiceTest.java @@ -7,12 +7,12 @@ import com.kafkamgt.uiapi.dao.UserInfo; import com.kafkamgt.uiapi.error.KafkawizeException; import com.kafkamgt.uiapi.helpers.HandleDbRequests; +import com.kafkamgt.uiapi.model.UserInfoModel; import org.hamcrest.CoreMatchers; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; @@ -20,7 +20,6 @@ import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.test.util.ReflectionTestUtils; @@ -30,6 +29,7 @@ import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) @@ -117,30 +117,30 @@ public void getEnvs1() { when(handleDbRequests.selectAllKafkaEnvs()).thenReturn(getAllEnvs()); List envsList = uiConfigControllerService.getEnvs(true); - assertEquals(3, envsList.size()); + assertEquals(2, envsList.size()); assertEquals(null, envsList.get(0).getEnvStatus()); } @Test public void getEnvs2() throws KafkawizeException { when(handleDbRequests.selectAllKafkaEnvs()).thenReturn(getAllEnvs()); - when(clusterApiService.getKafkaClusterStatus(any())).thenReturn("ONLINE"); + when(clusterApiService.getKafkaClusterStatus(any(), eq("PLAINTEXT"))).thenReturn("ONLINE"); List envsList = uiConfigControllerService.getEnvs(false); - assertEquals(3, envsList.size()); + assertEquals(2, envsList.size()); assertEquals("ONLINE", envsList.get(0).getEnvStatus()); - assertEquals("NOT_KNOWN", envsList.get(2).getEnvStatus()); + assertEquals("ONLINE", envsList.get(1).getEnvStatus()); } @Test public void getEnvs3() throws KafkawizeException { when(handleDbRequests.selectAllKafkaEnvs()).thenReturn(getAllEnvs()); - when(clusterApiService.getKafkaClusterStatus(any())).thenReturn("OFFLINE"); + when(clusterApiService.getKafkaClusterStatus(any(), eq("PLAINTEXT"))).thenReturn("OFFLINE"); List envsList = uiConfigControllerService.getEnvs(false); - assertEquals(3, envsList.size()); + assertEquals(2, envsList.size()); assertEquals("OFFLINE", envsList.get(0).getEnvStatus()); - assertEquals("NOT_KNOWN", envsList.get(2).getEnvStatus()); + assertEquals("OFFLINE", envsList.get(1).getEnvStatus()); } @Test @@ -148,7 +148,7 @@ public void getSchemaRegEnvs() { when(handleDbRequests.selectAllSchemaRegEnvs()).thenReturn(getAllSchemaEnvs()); List envsList = uiConfigControllerService.getSchemaRegEnvs(); - assertEquals(2, envsList.size()); + assertEquals(1, envsList.size()); assertEquals(null, envsList.get(0).getEnvStatus()); } @@ -158,7 +158,7 @@ public void getSchemaRegEnvsStatus1() { when(clusterApiService.getSchemaClusterStatus(any())).thenReturn("ONLINE"); List envsList = uiConfigControllerService.getSchemaRegEnvsStatus(); - assertEquals(2, envsList.size()); + assertEquals(1, envsList.size()); assertEquals("ONLINE", envsList.get(0).getEnvStatus()); } @@ -168,8 +168,8 @@ public void getSchemaRegEnvsStatus2() { when(clusterApiService.getSchemaClusterStatus(any())).thenReturn("OFFLINE"); List envsList = uiConfigControllerService.getSchemaRegEnvsStatus(); - assertEquals(2, envsList.size()); - assertEquals("NOT_KNOWN", envsList.get(1).getEnvStatus()); + assertEquals(1, envsList.size()); + assertEquals("OFFLINE", envsList.get(0).getEnvStatus()); } @Test @@ -404,7 +404,8 @@ public void addNewTeam3() { public void changePwd1() { String pwdUpdate = "{\"pwd\":\"newpasswd\",\"repeatpwd\":\"newpasswd\"}"; - when(handleDbRequests.updatePassword(this.userDetails.getUsername(), "newpasswd")).thenReturn("success"); + when(userDetails.getUsername()).thenReturn("uiuser1"); + when(handleDbRequests.updatePassword(eq("uiuser1"), any())).thenReturn("success"); String result = uiConfigControllerService.changePwd(pwdUpdate); @@ -415,7 +416,9 @@ public void changePwd1() { public void changePwd2() { String pwdUpdate = "{\"pwd\":\"newpasswd\",\"repeatpwd\":\"newpasswd\"}"; - when(handleDbRequests.updatePassword(this.userDetails.getUsername(), "newpasswd")).thenThrow(new RuntimeException("Error")); + when(userDetails.getUsername()).thenReturn("uiuser1"); + when(handleDbRequests.updatePassword(eq("uiuser1"), any())). + thenThrow(new RuntimeException("Error")); String result = uiConfigControllerService.changePwd(pwdUpdate); @@ -425,7 +428,7 @@ public void changePwd2() { @Test public void showUsers() { when(handleDbRequests.selectAllUsersInfo()).thenReturn(getUsernfoList()); - List userInfoList = uiConfigControllerService.showUsers(); + List userInfoList = uiConfigControllerService.showUsers(); assertEquals(1,userInfoList.size()); } @@ -533,14 +536,7 @@ private List getAllSchemaEnvs(){ env.setHost("localhost"); env.setPort("8081"); env.setName("DEV"); - env.setProtocol("plain"); - listEnvs.add(env); - - env = new Env(); - env.setHost("localhost"); - env.setPort("8081"); - env.setName("TST"); - env.setProtocol("ssl"); + env.setProtocol("PLAINTEXT"); listEnvs.add(env); return listEnvs; @@ -553,21 +549,14 @@ private List getAllEnvs(){ env.setHost("localhost"); env.setPort("9092"); env.setName("DEV"); - env.setProtocol("plain"); + env.setProtocol("PLAINTEXT"); listEnvs.add(env); env = new Env(); env.setHost("10.22.34.121"); env.setPort("9092"); env.setName("TST"); - env.setProtocol("plain"); - listEnvs.add(env); - - env = new Env(); - env.setHost("10.23.34.121"); - env.setPort("9093"); - env.setName("ACC"); - env.setProtocol("ssl"); + env.setProtocol("PLAINTEXT"); listEnvs.add(env); return listEnvs; diff --git a/src/test/resources/scripts/base/cassandra/insertdata.sql b/src/test/resources/scripts/base/cassandra/insertdata.sql index b8dde6e..e58c20a 100644 --- a/src/test/resources/scripts/base/cassandra/insertdata.sql +++ b/src/test/resources/scripts/base/cassandra/insertdata.sql @@ -1,18 +1,18 @@ -/* Insert Users */ +/* Insert Users, pwd - base64 encoded */ -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User1','Team1','uiuser1','USER','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User1','Team1','uiuser1','USER','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User2','Team2','uiuser2','USER','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User2','Team2','uiuser2','USER','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User3','Team3','uiuser3','USER','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User3','Team3','uiuser3','USER','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User4','Team1','uiuser4','ADMIN','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User4','Team1','uiuser4','ADMIN','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User5','Team2','uiuser5','ADMIN','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User5','Team2','uiuser5','ADMIN','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User6','Team3','uiuser6','ADMIN','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('User6','Team3','uiuser6','ADMIN','dXNlcg=='); -Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('SuperUser','Team2','superuser','SUPERUSER','user'); +Insert into kafkamanagementapi.users(fullname,team,userid,roleid,pwd) values('SuperUser','Team2','superuser','SUPERUSER','dXNlcg=='); /* Insert Teams */ @@ -36,4 +36,4 @@ Insert into kafkamanagementapi.env(name,host,port,protocol,type) values ('DEV_SC /* Insert product and version */ -Insert into kafkamanagementapi.productdetails(name,version,licensekey) values ('KafkaWize','4.3',''); +Insert into kafkamanagementapi.productdetails(name,version,licensekey) values ('KafkaWize','4.4',''); diff --git a/src/test/resources/scripts/base/rdbms/insertdata.sql b/src/test/resources/scripts/base/rdbms/insertdata.sql index 67ab6e8..ecce485 100644 --- a/src/test/resources/scripts/base/rdbms/insertdata.sql +++ b/src/test/resources/scripts/base/rdbms/insertdata.sql @@ -1,18 +1,18 @@ -/* Insert Users */ +/* Insert Users , pwd: base64 encoded*/ -Insert into users(fullname,team,userid,roleid,pwd) values('User1','Team1','uiuser1','USER','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User1','Team1','uiuser1','USER','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User2','Team2','uiuser2','USER','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User2','Team2','uiuser2','USER','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User3','Team3','uiuser3','USER','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User3','Team3','uiuser3','USER','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User4','Team1','uiuser4','ADMIN','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User4','Team1','uiuser4','ADMIN','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User5','Team2','uiuser5','ADMIN','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User5','Team2','uiuser5','ADMIN','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('User6','Team3','uiuser6','ADMIN','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('User6','Team3','uiuser6','ADMIN','dXNlcg=='); -Insert into users(fullname,team,userid,roleid,pwd) values('SuperUser','Team2','superuser','SUPERUSER','user'); +Insert into users(fullname,team,userid,roleid,pwd) values('SuperUser','Team2','superuser','SUPERUSER','dXNlcg=='); /* Insert Teams */ @@ -36,6 +36,6 @@ Insert into env(name,host,port,protocol,type) values ('DEV_SCH','localhost','808 /* Insert product and version */ -Insert into productdetails(name,version) values ('KafkaWize','4.3'); +Insert into productdetails(name,version) values ('KafkaWize','4.4'); commit; \ No newline at end of file diff --git a/src/test/resources/test-application-cassandra.properties b/src/test/resources/test-application-cassandra.properties index 2db9840..56dd5bc 100644 --- a/src/test/resources/test-application-cassandra.properties +++ b/src/test/resources/test-application-cassandra.properties @@ -2,35 +2,45 @@ server.port:9097 server.servlet.context-path=/kafkawize -# custom.db.storetype should be "cassandra" or "rdbms" -custom.db.storetype=cassandra +server.ssl.key-store=C:/Software/confluent-oss-4.1.1-2.11/dev/etc/certs/new/server.keystore.jks +server.ssl.trust-store=C:/Software/confluent-oss-4.1.1-2.11/dev/etc/certs/new/server.truststore.jks +server.ssl.key-store-password=kafkawize +server.ssl.key-password=kafkawize +server.ssl.trust-store-password=kafkawize +server.ssl.key-store-type=JKS -# cluster api properties -custom.clusterapi.url:http://localhost:9343 -custom.clusterapi.username:user1 -custom.clusterapi.password:pwd +# kafkawize.db.storetype should be "cassandra" or "rdbms" +kafkawize.db.storetype=cassandra -custom.api.username:uiuser4 -custom.api.password:user +# cluster api properties +kafkawize.clusterapi.url:http://localhost:9343 +kafkawize.clusterapi.username:user1 +kafkawize.clusterapi.password:pwd -# db store cassandra properties, to be filled in if custom.db.storetype is cassandra -custom.cassandradb.keyspace:kafkamanagementapi -custom.cassandradb.url:localhost -custom.cassandradb.port:9142 +# db store cassandra properties, to be filled in if kafkawize.db.storetype is cassandra +kafkawize.cassandradb.keyspace:kafkamanagementapi +kafkawize.cassandradb.url:localhost +kafkawize.cassandradb.port:9142 -# db scripts execution auto or manual. If set to manual, user has to execute the scripts from resources dir manually -custom.dbscripts.execution=auto -custom.dbscripts.dropall_recreate=false +# db scripts execution 'auto' or 'manual'. If set to manual, user has to execute the scripts from resources dir manually +kafkawize.dbscripts.execution=auto +# drop all tables and recreate. Be careful with this property. +kafkawize.dbscripts.dropall_recreate=true # default cluster to synchronize data -custom.syncdata.cluster=DEV +kafkawize.syncdata.cluster=DEV + +# order of envs +kafkawize.envs.order=DEV,TST,ACC,PRD -custom.envs.order=DEV,TST,ACC,PRD -custom.request.topics.envs=DEV,TST,ACC,PRD +#request topics in below envs. Promote topics will be in higher envs +kafkawize.request.topics.envs=DEV,TST # licensing info -custom.license.key= -custom.org.name= +kafkawize.license.key=Ee1T4E+EjHfGPlrSSgHc2A==:oiyf5yu0B7yiSkwo1zqDF4o7IC2GfeC56exeNtTrJwiUX2/SgFYuLoq5yUbeNbuU6Sn8ot6vC1qPlNtG3uuB8rOOgH1A4WrYEtPtWm+OKlnt/V+GhmJF3RD4+5sq32PqVFhsUGNtZGhibWw2WVhScGIyNHRTMkZtYTJGM2FYcGxUR2xqWlc1elpVVjRjR2x5ZVVSaGRHRTZNakF5TVMwd01pMHdNUT5ee +kafkawize.org.name=MyOrganization +kafkawize.version=4.4 +kafkawize.invalidkey.msg=Invalid License !! Please request from https://kafkawize.com for a license key. # Spring JPA properties spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 @@ -47,3 +57,4 @@ spring.jpa.generate-ddl=true spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=create +#logging.level.root=debug \ No newline at end of file diff --git a/src/test/resources/test-application-rdbms.properties b/src/test/resources/test-application-rdbms.properties index 0a19795..c609335 100644 --- a/src/test/resources/test-application-rdbms.properties +++ b/src/test/resources/test-application-rdbms.properties @@ -2,31 +2,45 @@ server.port:9097 server.servlet.context-path=/kafkawize -# custom.db.storetype should be "cassandra" or "rdbms" -custom.db.storetype=rdbms +server.ssl.key-store=C:/Software/confluent-oss-4.1.1-2.11/dev/etc/certs/new/server.keystore.jks +server.ssl.trust-store=C:/Software/confluent-oss-4.1.1-2.11/dev/etc/certs/new/server.truststore.jks +server.ssl.key-store-password=kafkawize +server.ssl.key-password=kafkawize +server.ssl.trust-store-password=kafkawize +server.ssl.key-store-type=JKS + +# kafkawize.db.storetype should be "cassandra" or "rdbms" +kafkawize.db.storetype=rdbms # cluster api properties -custom.clusterapi.url:http://localhost:9343 -custom.clusterapi.username:user1 -custom.clusterapi.password:pwd +kafkawize.clusterapi.url:http://localhost:9343 +kafkawize.clusterapi.username:user1 +kafkawize.clusterapi.password:pwd -# db store cassandra properties, to be filled in if custom.db.storetype is cassandra -custom.cassandradb.keyspace:kafkamanagementapi -custom.cassandradb.url:localhost -custom.cassandradb.port:9142 +# db store cassandra properties, to be filled in if kafkawize.db.storetype is cassandra +kafkawize.cassandradb.keyspace:kafkamanagementapi +kafkawize.cassandradb.url:localhost +kafkawize.cassandradb.port:9042 -# db scripts execution auto or manual. If set to manual, user has to execute the scripts from resources dir manually -custom.dbscripts.execution=auto -custom.dbscripts.dropall_recreate=false +# db scripts execution 'auto' or 'manual'. If set to manual, user has to execute the scripts from resources dir manually +kafkawize.dbscripts.execution=auto +# drop all tables and recreate. Be careful with this property. +kafkawize.dbscripts.dropall_recreate=true # default cluster to synchronize data -custom.syncdata.cluster=DEV -custom.envs.order=DEV,TST,ACC,PRD -custom.request.topics.envs=DEV,TST,ACC,PRD +kafkawize.syncdata.cluster=DEV + +# order of envs +kafkawize.envs.order=DEV,TST,ACC,PRD + +#request topics in below envs. Promote topics will be in higher envs +kafkawize.request.topics.envs=DEV,TST # licensing info -custom.license.key= -custom.org.name= +kafkawize.license.key=Ee1T4E+EjHfGPlrSSgHc2A==:oiyf5yu0B7yiSkwo1zqDF4o7IC2GfeC56exeNtTrJwiUX2/SgFYuLoq5yUbeNbuU6Sn8ot6vC1qPlNtG3uuB8rOOgH1A4WrYEtPtWm+OKlnt/V+GhmJF3RD4+5sq32PqVFhsUGNtZGhibWw2WVhScGIyNHRTMkZtYTJGM2FYcGxUR2xqWlc1elpVVjRjR2x5ZVVSaGRHRTZNakF5TVMwd01pMHdNUT5ee +kafkawize.org.name=MyOrganization +kafkawize.version=4.4 +kafkawize.invalidkey.msg=Invalid License !! Please request from https://kafkawize.com for a license key. # Spring JPA properties spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 @@ -43,3 +57,4 @@ spring.jpa.generate-ddl=true spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=create +#logging.level.root=debug