From 39db9df40964d8800d3d937ed6777a54cfa4b90a Mon Sep 17 00:00:00 2001 From: Raju Beemreddy Date: Wed, 26 Oct 2022 17:48:28 +0530 Subject: [PATCH 01/10] Missing the encryption of the passwords when updating the subscription. Fixed the issue by encrypting the passwords when updation of the subscription. Also updated the code not to print the passwords in debug logs. --- .../ericsson/ei/services/SubscriptionService.java | 10 +++++++--- .../ei/subscription/SubscriptionHandler.java | 12 +++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/ericsson/ei/services/SubscriptionService.java b/src/main/java/com/ericsson/ei/services/SubscriptionService.java index 6af2eca42..e670ee540 100644 --- a/src/main/java/com/ericsson/ei/services/SubscriptionService.java +++ b/src/main/java/com/ericsson/ei/services/SubscriptionService.java @@ -50,7 +50,7 @@ public class SubscriptionService implements ISubscriptionService { private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionService.class); @Value("${spring.application.name}") - private String SpringApplicationName; + private String springApplicationName; @Value("${spring.data.mongodb.database}") private String dataBaseName; @@ -99,7 +99,7 @@ public Subscription getSubscription(String subscriptionName) try { subscription = mapper.readValue(input, Subscription.class); // Inject aggregationtype - subscription.setAggregationtype(SpringApplicationName); + subscription.setAggregationtype(springApplicationName); return subscription; } catch (IOException e) { LOGGER.error("Malformed JSON string", e); @@ -129,6 +129,10 @@ public boolean modifySubscription(Subscription subscription, String subscription ObjectMapper mapper = new ObjectMapper(); Document result = null; try { + String password = subscription.getPassword(); + if (isEncryptionReady(subscription.getAuthenticationType(), subscription.getUserName(), password)) { + subscription.setPassword(encryptPassword(password)); + } String stringSubscription = mapper.writeValueAsString(subscription); final MongoCondition subscriptionNameCondition = MongoCondition.subscriptionNameCondition( @@ -196,7 +200,7 @@ public List getSubscriptions() throws SubscriptionNotFoundExceptio try { subscription = mapper.readValue(input, Subscription.class); // Inject aggregationtype - subscription.setAggregationtype(SpringApplicationName); + subscription.setAggregationtype(springApplicationName); subscriptions.add(subscription); } catch (IOException e) { LOGGER.error("Failed to get subscription.", e); diff --git a/src/main/java/com/ericsson/ei/subscription/SubscriptionHandler.java b/src/main/java/com/ericsson/ei/subscription/SubscriptionHandler.java index c6b4f7864..49c72bbad 100644 --- a/src/main/java/com/ericsson/ei/subscription/SubscriptionHandler.java +++ b/src/main/java/com/ericsson/ei/subscription/SubscriptionHandler.java @@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import lombok.Getter; import lombok.Setter; @@ -97,11 +98,16 @@ private void extractConditions(String aggregatedObject, try { JsonNode subscriptionJson = new ObjectMapper().readTree( subscriptionData); - LOGGER.debug("SubscriptionJson : " + subscriptionJson.toString()); - LOGGER.debug("Aggregated Object : " + aggregatedObject + " for the event id: " + id); + + // Remove password from subscription details and put empty value before logging. + JsonNode subscriptoinToDisplay = new ObjectMapper().readTree(subscriptionJson.toString()); + LOGGER.debug("SubscriptionJson : {}", + ((ObjectNode) subscriptoinToDisplay).put("password", "").toPrettyString()); + + LOGGER.debug("Aggregated Object : {} for event id: {}", aggregatedObject, id); ArrayNode requirementNode = (ArrayNode) subscriptionJson.get( "requirements"); - LOGGER.debug("Requirements : " + requirementNode.toString()); + LOGGER.debug("Requirements : {}", requirementNode); Iterator requirementIterator = requirementNode.elements(); SubscriptionField subscriptionField = new SubscriptionField(subscriptionJson); String subscriptionName = subscriptionField.get("subscriptionName"); From 743527e73854cef82700749cd133e99b674f93ba Mon Sep 17 00:00:00 2001 From: RajuBeemreddy1 <77657521+RajuBeemreddy1@users.noreply.github.com> Date: Wed, 26 Oct 2022 18:44:25 +0530 Subject: [PATCH 02/10] Update main.yml updated the main.yml to trigger local changes --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8784ebb77..c9158cf1b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ on: jobs: # This workflow contains a single job called "build" unitAndFunctionalTests: - if: github.repository == 'eiffel-community/eiffel-intelligence' + # if: github.repository == 'eiffel-community/eiffel-intelligence' # The type of runner that the job will run on runs-on: ubuntu-18.04 env: @@ -60,7 +60,7 @@ jobs: mvn test -DskipITs -Dsurefire.rerunFailingTestsCount=2 -Djasypt.encryptor.password=secret -Dspring.config.location=src/functionaltests/resources/application.properties -B integrationTests: - if: github.repository == 'eiffel-community/eiffel-intelligence' + # if: github.repository == 'eiffel-community/eiffel-intelligence' # The type of runner that the job will run on runs-on: ubuntu-18.04 env: From ecb53940045e4ce00306cf9593a8555385ac166f Mon Sep 17 00:00:00 2001 From: RajuBeemreddy1 <77657521+RajuBeemreddy1@users.noreply.github.com> Date: Wed, 23 Nov 2022 19:27:29 +0530 Subject: [PATCH 03/10] Revert the change to enable only for community branch --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c9158cf1b..6b96e91ce 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,7 @@ jobs: mvn test -DskipITs -Dsurefire.rerunFailingTestsCount=2 -Djasypt.encryptor.password=secret -Dspring.config.location=src/functionaltests/resources/application.properties -B integrationTests: - # if: github.repository == 'eiffel-community/eiffel-intelligence' + if: github.repository == 'eiffel-community/eiffel-intelligence' # The type of runner that the job will run on runs-on: ubuntu-18.04 env: From 67649c88c69fb22abfcb982913180256083d0fc0 Mon Sep 17 00:00:00 2001 From: RajuBeemreddy1 <77657521+RajuBeemreddy1@users.noreply.github.com> Date: Wed, 23 Nov 2022 19:34:46 +0530 Subject: [PATCH 04/10] Revert work flow changes --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b96e91ce..8784ebb77 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ on: jobs: # This workflow contains a single job called "build" unitAndFunctionalTests: - # if: github.repository == 'eiffel-community/eiffel-intelligence' + if: github.repository == 'eiffel-community/eiffel-intelligence' # The type of runner that the job will run on runs-on: ubuntu-18.04 env: From e81f0374f1c402356f94edf4786acac4f50a4831 Mon Sep 17 00:00:00 2001 From: Raju Beemreddy Date: Wed, 26 Oct 2022 17:48:28 +0530 Subject: [PATCH 05/10] Missing the encryption of the passwords when updating the subscription. Fixed the issue by encrypting the passwords when updation of the subscription. Also updated the code not to print the passwords in debug logs. --- .../ericsson/ei/services/SubscriptionService.java | 10 +++++++--- .../ei/subscription/SubscriptionHandler.java | 12 +++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/ericsson/ei/services/SubscriptionService.java b/src/main/java/com/ericsson/ei/services/SubscriptionService.java index 6af2eca42..e670ee540 100644 --- a/src/main/java/com/ericsson/ei/services/SubscriptionService.java +++ b/src/main/java/com/ericsson/ei/services/SubscriptionService.java @@ -50,7 +50,7 @@ public class SubscriptionService implements ISubscriptionService { private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionService.class); @Value("${spring.application.name}") - private String SpringApplicationName; + private String springApplicationName; @Value("${spring.data.mongodb.database}") private String dataBaseName; @@ -99,7 +99,7 @@ public Subscription getSubscription(String subscriptionName) try { subscription = mapper.readValue(input, Subscription.class); // Inject aggregationtype - subscription.setAggregationtype(SpringApplicationName); + subscription.setAggregationtype(springApplicationName); return subscription; } catch (IOException e) { LOGGER.error("Malformed JSON string", e); @@ -129,6 +129,10 @@ public boolean modifySubscription(Subscription subscription, String subscription ObjectMapper mapper = new ObjectMapper(); Document result = null; try { + String password = subscription.getPassword(); + if (isEncryptionReady(subscription.getAuthenticationType(), subscription.getUserName(), password)) { + subscription.setPassword(encryptPassword(password)); + } String stringSubscription = mapper.writeValueAsString(subscription); final MongoCondition subscriptionNameCondition = MongoCondition.subscriptionNameCondition( @@ -196,7 +200,7 @@ public List getSubscriptions() throws SubscriptionNotFoundExceptio try { subscription = mapper.readValue(input, Subscription.class); // Inject aggregationtype - subscription.setAggregationtype(SpringApplicationName); + subscription.setAggregationtype(springApplicationName); subscriptions.add(subscription); } catch (IOException e) { LOGGER.error("Failed to get subscription.", e); diff --git a/src/main/java/com/ericsson/ei/subscription/SubscriptionHandler.java b/src/main/java/com/ericsson/ei/subscription/SubscriptionHandler.java index c6b4f7864..49c72bbad 100644 --- a/src/main/java/com/ericsson/ei/subscription/SubscriptionHandler.java +++ b/src/main/java/com/ericsson/ei/subscription/SubscriptionHandler.java @@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import lombok.Getter; import lombok.Setter; @@ -97,11 +98,16 @@ private void extractConditions(String aggregatedObject, try { JsonNode subscriptionJson = new ObjectMapper().readTree( subscriptionData); - LOGGER.debug("SubscriptionJson : " + subscriptionJson.toString()); - LOGGER.debug("Aggregated Object : " + aggregatedObject + " for the event id: " + id); + + // Remove password from subscription details and put empty value before logging. + JsonNode subscriptoinToDisplay = new ObjectMapper().readTree(subscriptionJson.toString()); + LOGGER.debug("SubscriptionJson : {}", + ((ObjectNode) subscriptoinToDisplay).put("password", "").toPrettyString()); + + LOGGER.debug("Aggregated Object : {} for event id: {}", aggregatedObject, id); ArrayNode requirementNode = (ArrayNode) subscriptionJson.get( "requirements"); - LOGGER.debug("Requirements : " + requirementNode.toString()); + LOGGER.debug("Requirements : {}", requirementNode); Iterator requirementIterator = requirementNode.elements(); SubscriptionField subscriptionField = new SubscriptionField(subscriptionJson); String subscriptionName = subscriptionField.get("subscriptionName"); From 82481cdcf0ef644f6b641ef9d33829657db6e303 Mon Sep 17 00:00:00 2001 From: RajuBeemreddy1 <77657521+RajuBeemreddy1@users.noreply.github.com> Date: Wed, 26 Oct 2022 18:44:25 +0530 Subject: [PATCH 06/10] Update main.yml updated the main.yml to trigger local changes --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d14146b36..97d6a419e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ on: jobs: # This workflow contains a single job called "build" unitAndFunctionalTests: - if: github.repository == 'eiffel-community/eiffel-intelligence' + # if: github.repository == 'eiffel-community/eiffel-intelligence' # The type of runner that the job will run on runs-on: ubuntu-latest env: @@ -53,7 +53,7 @@ jobs: mvn test -DskipITs -Dsurefire.rerunFailingTestsCount=2 -Djasypt.encryptor.password=secret -Dspring.config.location=src/functionaltests/resources/application.properties -B integrationTests: - if: github.repository == 'eiffel-community/eiffel-intelligence' + # if: github.repository == 'eiffel-community/eiffel-intelligence' # The type of runner that the job will run on runs-on: ubuntu-latest From df1db7d0df4b9b665526b019c29169fb80f68744 Mon Sep 17 00:00:00 2001 From: RajuBeemreddy1 <77657521+RajuBeemreddy1@users.noreply.github.com> Date: Wed, 23 Nov 2022 19:27:29 +0530 Subject: [PATCH 07/10] Revert the change to enable only for community branch --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 97d6a419e..77b234fcc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,7 +53,7 @@ jobs: mvn test -DskipITs -Dsurefire.rerunFailingTestsCount=2 -Djasypt.encryptor.password=secret -Dspring.config.location=src/functionaltests/resources/application.properties -B integrationTests: - # if: github.repository == 'eiffel-community/eiffel-intelligence' + if: github.repository == 'eiffel-community/eiffel-intelligence' # The type of runner that the job will run on runs-on: ubuntu-latest From 52487ab79b6f6faace1c566a3bcbb0f16734eeb3 Mon Sep 17 00:00:00 2001 From: RajuBeemreddy1 <77657521+RajuBeemreddy1@users.noreply.github.com> Date: Wed, 23 Nov 2022 19:34:46 +0530 Subject: [PATCH 08/10] Revert work flow changes --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 77b234fcc..d14146b36 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ on: jobs: # This workflow contains a single job called "build" unitAndFunctionalTests: - # if: github.repository == 'eiffel-community/eiffel-intelligence' + if: github.repository == 'eiffel-community/eiffel-intelligence' # The type of runner that the job will run on runs-on: ubuntu-latest env: From 31fde53e4ad196c4c5f3f0a432bbeba1895ba374 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:05:01 +0530 Subject: [PATCH 09/10] Rebase master --- .github/workflows/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d14146b36..fafc8607c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,8 +27,8 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' @@ -64,8 +64,8 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' @@ -101,8 +101,8 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' From a6cdc6337c1ba5f8c5cb3fa43bd09a10e2f4b83c Mon Sep 17 00:00:00 2001 From: Jainad Chinta Date: Wed, 10 Apr 2024 21:09:53 +0530 Subject: [PATCH 10/10] Added Nidhi changes for testcases --- pom.xml | 2 +- .../com/ericsson/ei/logFilter/LogFilter.java | 40 ++++++ .../ei/services/SubscriptionServiceTest.java | 115 ++++++++++++++---- src/test/resources/application.properties | 85 +++++++++++++ src/test/resources/logback.xml | 16 ++- src/test/resources/subscription_CLME.json | 1 + 6 files changed, 231 insertions(+), 28 deletions(-) create mode 100644 src/test/java/com/ericsson/ei/logFilter/LogFilter.java create mode 100644 src/test/resources/application.properties diff --git a/pom.xml b/pom.xml index 355e5100e..d67468a66 100644 --- a/pom.xml +++ b/pom.xml @@ -441,7 +441,7 @@ ch.qos.logback logback-classic - 1.2.13 + 1.2.11 diff --git a/src/test/java/com/ericsson/ei/logFilter/LogFilter.java b/src/test/java/com/ericsson/ei/logFilter/LogFilter.java new file mode 100644 index 000000000..7822b7765 --- /dev/null +++ b/src/test/java/com/ericsson/ei/logFilter/LogFilter.java @@ -0,0 +1,40 @@ +package com.ericsson.ei.logFilter; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; +import org.springframework.context.annotation.PropertySource; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; + +@PropertySource("classpath:logback.xml") +public class LogFilter extends Filter { + +public boolean filter(LocalDateTime start, LocalDateTime end, String logLine) { + DateTimeFormatter logFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss,SSS"); + LocalDateTime current=start; + while(current.isBefore(end)) + { + String time=current.format(logFormatter); + if(logLine.contains(time)) + { + return (true); + } + else + { + current=current.plus(1, ChronoUnit.MILLIS); + } + + + } + return (false); + } + + @Override + public FilterReply decide(ILoggingEvent iLoggingEvent) { + return null; + } +} + diff --git a/src/test/java/com/ericsson/ei/services/SubscriptionServiceTest.java b/src/test/java/com/ericsson/ei/services/SubscriptionServiceTest.java index c6450ed69..81cb0b3f9 100644 --- a/src/test/java/com/ericsson/ei/services/SubscriptionServiceTest.java +++ b/src/test/java/com/ericsson/ei/services/SubscriptionServiceTest.java @@ -16,17 +16,19 @@ */ package com.ericsson.ei.services; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.PostConstruct; - +import com.ericsson.ei.App; +import com.ericsson.ei.controller.model.Subscription; +import com.ericsson.ei.exception.SubscriptionNotFoundException; +import com.ericsson.ei.logFilter.LogFilter; +import com.ericsson.ei.mongo.MongoCondition; +import com.ericsson.ei.mongo.MongoDBHandler; +import com.ericsson.ei.test.utils.TestConfigs; +import com.ericsson.ei.utils.TestContextInitializer; +import com.ericsson.eiffelcommons.subscriptionobject.RestPostSubscriptionObject; +import com.ericsson.eiffelcommons.subscriptionobject.SubscriptionObject; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.mongodb.BasicDBObject; +import com.mongodb.client.MongoClient; import org.apache.commons.io.FileUtils; import org.json.JSONArray; import org.json.JSONException; @@ -49,18 +51,18 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.ericsson.ei.App; -import com.ericsson.ei.controller.model.Subscription; -import com.ericsson.ei.exception.SubscriptionNotFoundException; -import com.ericsson.ei.mongo.MongoCondition; -import com.ericsson.ei.mongo.MongoDBHandler; -import com.ericsson.ei.test.utils.TestConfigs; -import com.ericsson.ei.utils.TestContextInitializer; -import com.ericsson.eiffelcommons.subscriptionobject.RestPostSubscriptionObject; -import com.ericsson.eiffelcommons.subscriptionobject.SubscriptionObject; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mongodb.BasicDBObject; -import com.mongodb.client.MongoClient; +import javax.annotation.PostConstruct; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +import static org.junit.Assert.*; @TestPropertySource(properties = { "spring.data.mongodb.database: SubscriptionServiceTest", @@ -88,6 +90,9 @@ public class SubscriptionServiceTest { @Autowired private ISubscriptionService subscriptionService; + @Autowired + private SubscriptionService subService; + @Autowired private MongoDBHandler mongoDBHandler; @@ -360,4 +365,66 @@ private void deleteSubscriptionsByName(String subscriptionName) throws AccessExc Mockito.when(authentication.getName()).thenReturn("ABC"); subscriptionService.deleteSubscription(subscriptionName); } -} + + @Test + public void testLogForPasswordAdd() throws Exception { + Path logFilePath= Paths.get("/var/tmp/eiffel-intelligence.log"); + try { + + Scanner scanner = new Scanner(logFilePath); + LocalDateTime start = LocalDateTime.now(); + Subscription subscription2 = mapper.readValue(jsonArray.getJSONObject(0).toString(), Subscription.class); + String expectedSubscriptionName = subscription2.getSubscriptionName(); + subscription2.setAuthenticationType("BASIC_AUTH"); + String expectedSubscriptionPassword = subscription2.getPassword(); + subService.addSubscription(subscription2); + LocalDateTime end = LocalDateTime.now(); + LogFilter log = new LogFilter(); + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + if (log.filter(start, end, line)) { + if ((line.contains(expectedSubscriptionName) && (line.contains("password")))) { + assertFalse(line.contains(expectedSubscriptionPassword)); + } + } + } + scanner.close(); + } + catch(Exception e) { + LOGGER.error(e.getMessage(),e); + } finally { + Files.write(logFilePath, new byte[0]); + } + } + @Test + public void testLogForPasswordUpdate() throws Exception { + Path logFilePath=Paths.get("/var/tmp/eiffel-intelligence.log"); + try { + + Scanner scanner = new Scanner(logFilePath); + LocalDateTime start = LocalDateTime.now(); + Subscription subscription2 = mapper.readValue(jsonArray.getJSONObject(0).toString(), Subscription.class); + String expectedSubscriptionName = subscription2.getSubscriptionName(); + subscription2.setAuthenticationType("BASIC_AUTH"); + subscription2.setPassword("token123"); + String expectedSubscriptionPassword = subscription2.getPassword(); + subscriptionService.modifySubscription(subscription2,expectedSubscriptionName); + LocalDateTime end = LocalDateTime.now(); + LogFilter log = new LogFilter(); + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + if (log.filter(start, end, line)) { + if ((line.contains(expectedSubscriptionName) && (line.contains("password")))) { + assertFalse(line.contains(expectedSubscriptionPassword)); + } + } + } + scanner.close(); + } + catch(Exception e) { + LOGGER.error(e.getMessage(),e); + } finally { + Files.write(logFilePath, new byte[0]); + } + } +} \ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100644 index 000000000..108f68f32 --- /dev/null +++ b/src/test/resources/application.properties @@ -0,0 +1,85 @@ +# Configuration documentation can be found here: +# https://github.com/eiffel-community/eiffel-intelligence/blob/master/wiki/configuration.md +spring.application.name: eiffel-intelligence +server.port: 8090 +spring.mvc.pathmatch.matching-strategy: ANT_PATH_MATCHER +logging.level.root: INFO +logging.level.org.springframework.web: ERROR +logging.level.com.ericsson.ei: ERROR + +rules.path: /rules/ArtifactRules-Eiffel-Agen-Version.json +rules.replacement.marker: %IdentifyRulesEventId% + +# WARNING! Do not enable this in a production environment! +test.aggregation.enabled: false + +rabbitmq.host: localhost +rabbitmq.port: 5672 +rabbitmq.user: myuser +rabbitmq.password: myuser +rabbitmq.tls.version: +rabbitmq.exchange.name: ei-exchange +rabbitmq.domain.id: ei-domain +rabbitmq.component.name: eiffel-intelligence +rabbitmq.queue.suffix: messageQueue +rabbitmq.queue.durable: true +rabbitmq.binding.key: # +rabbitmq.waitlist.queue.suffix: waitList + +bindingkeys.collection.name: binding_keys + +spring.data.mongodb.uri: mongodb://localhost:27017 +spring.data.mongodb.database: eiffel_intelligence + +server.session.timeout: 1200 +sessions.collection.name: sessions + +aggregations.collection.name: aggregations +aggregations.collection.ttl: +event.object.map.collection.name: event_object_map +subscriptions.collection.name: subscriptions +subscriptions.repeat.handler.collection.name: subscriptions_repeat_handler +waitlist.collection.name: wait_list +waitlist.collection.ttl: 600 +waitlist.resend.initial.delay: 2000 +waitlist.resend.fixed.rate: 15000 +failed.notifications.collection.name: failed_notifications +failed.notifications.collection.ttl: 600 +notification.retry: 3 +notification.httpRequest.timeout: 5000 + +email.sender: noreply@domain.com +email.subject: Email Subscription Notification + +spring.mail.host: +spring.mail.port: +spring.mail.username: +spring.mail.password: +spring.mail.properties.mail.smtp.auth: false +spring.mail.properties.mail.smtp.starttls.enable: false + +event.repository.url: +event.repository.shallow: true + +ldap.enabled: false +ldap.server.list: [{\ + "url": "",\ + "base.dn": "",\ + "username": "",\ + "password": "",\ + "user.filter": ""\ + }] + +### DEVELOPER SETTINGS + +spring.mongodb.embedded.version: 3.4.1 +# We remove the embedded mongodb in tests since in most of them we set up our own before Spring +# starts and activate it manually in tests where we need the Spring's own embedded mongo DB +spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration + +threads.core.pool.size: 200 +threads.queue.capacity: 7000 +threads.max.pool.size: 250 +scheduled.threadpool.size: 200 +jasypt.encryptor.password=test + diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml index b95b27f52..1ddfe15bf 100644 --- a/src/test/resources/logback.xml +++ b/src/test/resources/logback.xml @@ -5,8 +5,18 @@ %d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n - + + + /var/tmp/eiffel-intelligence.log + + %date %level [%thread] %logger{10} [%file:%line] %msg%n + + + + + + - - \ No newline at end of file + + diff --git a/src/test/resources/subscription_CLME.json b/src/test/resources/subscription_CLME.json index ba2680166..a37a0636b 100644 --- a/src/test/resources/subscription_CLME.json +++ b/src/test/resources/subscription_CLME.json @@ -26,6 +26,7 @@ ], "subscriptionName" : "Single_CLME_Subscription_Test", "userName" : "ABC", + "password": "token", "ldapUserName": "" } ] \ No newline at end of file