This is an automated email from the ASF dual-hosted git repository.

ikamga pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-notifications.git

commit 184aea0f5afe0a4c80e217b3fac53cf2e827000d
Author: Ebenezer Graham <[email protected]>
AuthorDate: Thu May 9 07:54:23 2019 +0400

    Changed Notification Admin to OrgAdmin
---
 .gitignore                                         |   8 +-
 .../cn/notification/EmailApiDocumentation.java     |  81 +++++-
 .../notification/NotificationApiDocumentation.java | 289 ---------------------
 .../cn/notification/SmsApiDocumentation.java       |  94 +++++--
 .../TestApplicationAuthentication.java             |  48 ----
 .../fineract/cn/notification/TestEmailService.java |   2 +-
 .../fineract/cn/notification/TestSMSService.java   |   2 +-
 .../apache/fineract/cn/notification/TestSuite.java |   4 +-
 .../internal/config/NotificationProperties.java    |   9 +
 .../identity/NotificationAuthentication.java       |  23 +-
 .../internal/service/NotificationService.java      |   5 +-
 service/src/main/resources/application.yml         |   3 +-
 .../db/migrations/mariadb/V1__initial_setup.sql    |   4 +-
 13 files changed, 188 insertions(+), 384 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3349144..f295929 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,12 +2,8 @@
 .idea
 build/
 target/
-api/out/
-api/build/
-service/out/
-service/build/
-component-test/out/
-component-test/build/
+**/out/
+**/build/
 
 # Ignore Gradle GUI config
 gradle-app.setting
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/EmailApiDocumentation.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/EmailApiDocumentation.java
index 1632f0c..3aa0e48 100644
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/EmailApiDocumentation.java
+++ 
b/component-test/src/main/java/org/apache/fineract/cn/notification/EmailApiDocumentation.java
@@ -37,10 +37,9 @@ import org.springframework.web.context.WebApplicationContext;
 
 import static 
org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
 import static 
org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
-import static 
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
-import static 
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
-import static 
org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
-import static 
org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
+import static 
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
+import static 
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete;
+import static 
org.springframework.restdocs.operation.preprocess.Preprocessors.*;
 import static org.springframework.restdocs.payload.PayloadDocumentation.*;
 import static 
org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
@@ -50,8 +49,9 @@ public class EmailApiDocumentation extends 
AbstractNotificationTest {
 
   @Autowired
   private WebApplicationContext context;
-
-  private MockMvc mockMvc;
+       private Gson gson = new Gson();
+       
+       private MockMvc mockMvc;
 
   @Autowired
   private NotificationManager notificationManager;
@@ -71,12 +71,11 @@ public class EmailApiDocumentation extends 
AbstractNotificationTest {
   public void documentCreateEmailConfiguration() throws Exception {
     final EmailConfiguration emailConfiguration = 
DomainObjectGenerator.emailConfiguration();
 
-    Gson gson = new Gson();
-    this.mockMvc.perform(post("/notification/email/create")
+    this.mockMvc.perform(post("/configuration/email/create")
             .accept(MediaType.APPLICATION_JSON_VALUE)
             .contentType(MediaType.APPLICATION_JSON_VALUE)
             .content(gson.toJson(emailConfiguration)))
-            .andExpect(status().isAccepted())
+            .andExpect(status().isCreated())
             .andDo(document("document-create-emailconfiguration", 
preprocessRequest(prettyPrint()),
                     requestFields(
                             
fieldWithPath("identifier").description("EmailConfiguration's identifier"),
@@ -107,7 +106,7 @@ public class EmailApiDocumentation extends 
AbstractNotificationTest {
     this.notificationManager.createEmailConfiguration(emailConfiguration);
     eventRecorder.wait(NotificationEventConstants.POST_EMAIL_CONFIGURATION, 
EmailConfiguration.class);
 
-    this.mockMvc.perform(get("/notification/email/" + 
emailConfiguration.getIdentifier())
+    this.mockMvc.perform(get("/configuration/email/" + 
emailConfiguration.getIdentifier())
             .accept(MediaType.ALL_VALUE)
             .contentType(MediaType.APPLICATION_JSON_VALUE))
             .andExpect(status().isOk())
@@ -125,4 +124,66 @@ public class EmailApiDocumentation extends 
AbstractNotificationTest {
                     )
             ));
   }
+  
+  @Test
+  public void documentUpdateEmailConfiguration() throws Exception {
+    
+    final EmailConfiguration randomEmailConfiguration = 
DomainObjectGenerator.emailConfiguration();
+    final EmailConfiguration newRandomConfiguration = 
DomainObjectGenerator.emailConfiguration();
+    
+    
this.notificationManager.createEmailConfiguration(randomEmailConfiguration);
+    
+    
super.eventRecorder.wait(NotificationEventConstants.POST_EMAIL_CONFIGURATION, 
randomEmailConfiguration.getIdentifier());
+    
+    
newRandomConfiguration.setIdentifier(randomEmailConfiguration.getIdentifier());
+    newRandomConfiguration.setHost("new.host.com");
+    newRandomConfiguration.setApp_password("changePassword");
+    newRandomConfiguration.setPort("554");
+    newRandomConfiguration.setProtocol("pop3");
+    newRandomConfiguration.setUsername("[email protected]");
+    newRandomConfiguration.setSmtp_auth("false");
+    newRandomConfiguration.setStart_tls("false");
+    newRandomConfiguration.setState("ACTIVE");
+    
+    notificationManager.updateEmailConfiguration(newRandomConfiguration);
+    
+    
super.eventRecorder.wait(NotificationEventConstants.UPDATE_EMAIL_CONFIGURATION, 
newRandomConfiguration.getIdentifier());
+    
+    this.mockMvc.perform(put("/configuration/sms/update")
+        .accept(MediaType.APPLICATION_JSON_VALUE)
+        .contentType(MediaType.APPLICATION_JSON_VALUE)
+        .content(gson.toJson(newRandomConfiguration)))
+        .andExpect(status().isAccepted())
+        .andDo(document("document-update-email-configuration", 
preprocessRequest(prettyPrint()),
+            requestFields(
+                fieldWithPath("identifier").description("Configuration Id for 
Email Server"),
+                fieldWithPath("host").description("Email Server host address"),
+                fieldWithPath("port").description("Email Server port number"),
+                fieldWithPath("protocol").description("Type of protocol in use 
" +
+                    "\nSMTP" +
+                    "\nPOP3" +
+                    "\nIMAP"),
+                fieldWithPath("username").description("Email address"),
+                fieldWithPath("app_password").description("Email app password 
or normal password"),
+                fieldWithPath("smtp_auth").description("Enable SMTP"),
+                fieldWithPath("start_tls").description("Enable TLS"),
+                fieldWithPath("state").description("" +
+                    "\n ACTIVE for Gateway to be used" +
+                    "\n DEACTIVATED for inactive gateways")
+            )));
+  }
+  
+  @Test
+  public void documentDeleteEmailConfiguration() throws Exception {
+    final EmailConfiguration randomConfiguration = 
DomainObjectGenerator.emailConfiguration();
+    
+    notificationManager.createEmailConfiguration(randomConfiguration);
+    
super.eventRecorder.wait(NotificationEventConstants.DELETE_EMAIL_CONFIGURATION, 
randomConfiguration.getIdentifier());
+    
+    this.mockMvc.perform(delete("/configuration/email/delete/" + 
randomConfiguration.getIdentifier())
+        .accept(MediaType.APPLICATION_JSON_VALUE)
+        .contentType(MediaType.APPLICATION_JSON_VALUE))
+        .andExpect(status().isOk())
+        .andDo(document("document-delete-email-configuration", 
preprocessResponse(prettyPrint())));
+  }
 }
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/NotificationApiDocumentation.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/NotificationApiDocumentation.java
deleted file mode 100644
index 2473159..0000000
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/NotificationApiDocumentation.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.fineract.cn.notification;
-
-import com.google.gson.Gson;
-import org.apache.fineract.cn.notification.api.v1.client.NotificationManager;
-import org.apache.fineract.cn.notification.api.v1.domain.EmailConfiguration;
-import org.apache.fineract.cn.notification.api.v1.domain.SMSConfiguration;
-import 
org.apache.fineract.cn.notification.api.v1.events.NotificationEventConstants;
-import org.apache.fineract.cn.notification.util.DomainObjectGenerator;
-import org.junit.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.restdocs.JUnitRestDocumentation;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import org.springframework.web.context.WebApplicationContext;
-
-import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.*;
-import static 
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
-import static 
org.springframework.restdocs.operation.preprocess.Preprocessors.*;
-import static org.springframework.restdocs.payload.PayloadDocumentation.*;
-import static 
org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-@SuppressWarnings("Unused")
-public class NotificationApiDocumentation extends TestNotification {
-       
-       @Rule
-       public final JUnitRestDocumentation restDocumentation = new 
JUnitRestDocumentation("build/doc/generated-snippets/test-notification");
-       
-       private final Gson serialize = new Gson();
-       private MockMvc mockMvc;
-       
-       @Autowired
-       NotificationManager notificationManager;
-       @Autowired
-       private WebApplicationContext context;
-       
-       public NotificationApiDocumentation() {
-               super();
-       }
-       
-       @Before
-       public void setUp() {
-               this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
-                               
.apply(documentationConfiguration(this.restDocumentation))
-                               .alwaysDo(document("{method-name}", 
preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint())))
-                               .build();
-       }
-       
-       @Test
-       public void documentCreateSMSConfiguration() throws Exception {
-               final SMSConfiguration randomSMSConfiguration = 
DomainObjectGenerator.smsConfiguration();
-               
-               this.mockMvc.perform(post("/configuration/sms/create")
-                               .accept(MediaType.APPLICATION_JSON_VALUE)
-                               .contentType(MediaType.APPLICATION_JSON_VALUE)
-                               
.content(serialize.toJson(randomSMSConfiguration)))
-                               .andExpect(status().isCreated())
-                               
.andDo(document("document-create-sms-configuration", 
preprocessRequest(prettyPrint()),
-                                               requestFields(
-                                                               
fieldWithPath("identifier").description("Configuration Id for SMS Gateway"),
-                                                               
fieldWithPath("auth_token").description("SMS API authentication token"),
-                                                               
fieldWithPath("account_sid").description("SMS API account SID"),
-                                                               
fieldWithPath("sender_number").description("SMS API sender number"),
-                                                               
fieldWithPath("state").description("The state of the Gateway" +
-                                                                               
"\n ACTIVE for Gateway to be used" +
-                                                                               
"\n DEACTIVATED for inactive gateways")
-                                               )));
-       }
-       
-       @Test
-       public void documentCreateEmailConfiguration() throws Exception {
-               final EmailConfiguration randomEmailConfiguration = 
DomainObjectGenerator.emailConfiguration();
-               
-               this.mockMvc.perform(post("/configuration/email/create")
-                               .accept(MediaType.APPLICATION_JSON_VALUE)
-                               .contentType(MediaType.APPLICATION_JSON_VALUE)
-                               
.content(serialize.toJson(randomEmailConfiguration)))
-                               .andExpect(status().isCreated())
-                               
.andDo(document("document-create-email-configuration", 
preprocessRequest(prettyPrint()),
-                                               requestFields(
-                                                               
fieldWithPath("identifier").description("Configuration Id for Email Server"),
-                                                               
fieldWithPath("host").description("Email Server host address"),
-                                                               
fieldWithPath("port").description("Email Server port number"),
-                                                               
fieldWithPath("protocol").description("Type of protocol in use " +
-                                                                               
"\nSMTP" +
-                                                                               
"\nPOP3" +
-                                                                               
"\nIMAP"),
-                                                               
fieldWithPath("username").description("Email address"),
-                                                               
fieldWithPath("app_password").description("Email app password or normal 
password"),
-                                                               
fieldWithPath("smtp_auth").description("Enable SMTP"),
-                                                               
fieldWithPath("start_tls").description("Enable TLS"),
-                                                               
fieldWithPath("state").description("" +
-                                                                               
"\n ACTIVE for Gateway to be used" +
-                                                                               
"\n DEACTIVATED for inactive gateways")
-                                               )));
-       }
-       
-       @Test
-       public void documentFindSMSConfiguration() throws Exception {
-               final SMSConfiguration randomSMSConfiguration = 
DomainObjectGenerator.smsConfiguration();
-               
-               
this.notificationManager.createSMSConfiguration(randomSMSConfiguration);
-               
-               
super.eventRecorder.wait(NotificationEventConstants.POST_SMS_CONFIGURATION, 
randomSMSConfiguration.getIdentifier());
-               
-               
notificationManager.findSMSConfigurationByIdentifier(randomSMSConfiguration.getIdentifier());
-               
-               this.mockMvc.perform(get("/configuration/sms/" + 
randomSMSConfiguration.getIdentifier())
-                               .accept(MediaType.APPLICATION_JSON_VALUE)
-                               .contentType(MediaType.APPLICATION_JSON_VALUE)
-                               
.content(serialize.toJson(randomSMSConfiguration.getIdentifier())))
-                               .andExpect(status().isOk())
-                               
.andDo(document("document-find-sms-configuration", 
preprocessRequest(prettyPrint()),
-                                               responseFields(
-                                                               
fieldWithPath("identifier").description("Configuration Id for SMS Gateway"),
-                                                               
fieldWithPath("auth_token").description("SMS API authentication token"),
-                                                               
fieldWithPath("account_sid").description("SMS API account SID"),
-                                                               
fieldWithPath("sender_number").description("SMS API sender number"),
-                                                               
fieldWithPath("type").description("Type of Configuration"),
-                                                               
fieldWithPath("state").description("The state of the Gateway" +
-                                                                               
"\n ACTIVE for Gateway to be used" +
-                                                                               
"\n DEACTIVATED for inactive gateways")
-                                               )));
-       }
-       
-       @Test
-       public void documentFindEmailConfiguration() throws Exception {
-               final EmailConfiguration randomEmailConfiguration = 
DomainObjectGenerator.emailConfiguration();
-               
-               
this.notificationManager.createEmailConfiguration(randomEmailConfiguration);
-               
-               
super.eventRecorder.wait(NotificationEventConstants.POST_EMAIL_CONFIGURATION, 
randomEmailConfiguration.getIdentifier());
-               
-               
this.notificationManager.findEmailConfigurationByIdentifier(randomEmailConfiguration.getIdentifier());
-               
-               this.mockMvc.perform(get("/configuration/email/" + 
randomEmailConfiguration.getIdentifier())
-                               .accept(MediaType.APPLICATION_JSON_VALUE)
-                               .contentType(MediaType.APPLICATION_JSON_VALUE)
-                               
.content(serialize.toJson(randomEmailConfiguration.getIdentifier())))
-                               .andExpect(status().isOk())
-                               
.andDo(document("document-find-email-configuration", 
preprocessRequest(prettyPrint()),
-                                               responseFields(
-                                                               
fieldWithPath("identifier").description("Configuration Id for Email Server"),
-                                                               
fieldWithPath("host").description("Email Server host address"),
-                                                               
fieldWithPath("port").description("Email Server port number"),
-                                                               
fieldWithPath("protocol").description("Type of protocol being used by server " +
-                                                                               
"\nSMTP" +
-                                                                               
"\nPOP3" +
-                                                                               
"\nIMAP"),
-                                                               
fieldWithPath("username").description("Email address"),
-                                                               
fieldWithPath("app_password").description("Email app password or normal 
password"),
-                                                               
fieldWithPath("smtp_auth").description("Enable SMTP"),
-                                                               
fieldWithPath("start_tls").description("Enable TLS"),
-                                                               
fieldWithPath("state").description("" +
-                                                                               
"\n ACTIVE for Gateway to be used" +
-                                                                               
"\n DEACTIVATED for inactive gateways")
-                                               )));
-       }
-       
-       @Test
-       public void documentUpdateEmailConfiguration() throws Exception {
-               
-               final EmailConfiguration randomEmailConfiguration = 
DomainObjectGenerator.emailConfiguration();
-               final EmailConfiguration newRandomConfiguration = 
DomainObjectGenerator.emailConfiguration();
-               
-               
this.notificationManager.createEmailConfiguration(randomEmailConfiguration);
-               
-               
super.eventRecorder.wait(NotificationEventConstants.POST_EMAIL_CONFIGURATION, 
randomEmailConfiguration.getIdentifier());
-               
-               
newRandomConfiguration.setIdentifier(randomEmailConfiguration.getIdentifier());
-               newRandomConfiguration.setHost("new.host.com");
-               newRandomConfiguration.setApp_password("changePassword");
-               newRandomConfiguration.setPort("554");
-               newRandomConfiguration.setProtocol("pop3");
-               newRandomConfiguration.setUsername("[email protected]");
-               newRandomConfiguration.setSmtp_auth("false");
-               newRandomConfiguration.setStart_tls("false");
-               newRandomConfiguration.setState("ACTIVE");
-               
-               
notificationManager.updateEmailConfiguration(newRandomConfiguration);
-               
-               
super.eventRecorder.wait(NotificationEventConstants.UPDATE_EMAIL_CONFIGURATION, 
newRandomConfiguration.getIdentifier());
-               
-               this.mockMvc.perform(put("/configuration/sms/update")
-                               .accept(MediaType.APPLICATION_JSON_VALUE)
-                               .contentType(MediaType.APPLICATION_JSON_VALUE)
-                               
.content(serialize.toJson(newRandomConfiguration)))
-                               .andExpect(status().isAccepted())
-                               
.andDo(document("document-update-email-configuration", 
preprocessRequest(prettyPrint()),
-                                               requestFields(
-                                                               
fieldWithPath("identifier").description("Configuration Id for Email Server"),
-                                                               
fieldWithPath("host").description("Email Server host address"),
-                                                               
fieldWithPath("port").description("Email Server port number"),
-                                                               
fieldWithPath("protocol").description("Type of protocol in use " +
-                                                                               
"\nSMTP" +
-                                                                               
"\nPOP3" +
-                                                                               
"\nIMAP"),
-                                                               
fieldWithPath("username").description("Email address"),
-                                                               
fieldWithPath("app_password").description("Email app password or normal 
password"),
-                                                               
fieldWithPath("smtp_auth").description("Enable SMTP"),
-                                                               
fieldWithPath("start_tls").description("Enable TLS"),
-                                                               
fieldWithPath("state").description("" +
-                                                                               
"\n ACTIVE for Gateway to be used" +
-                                                                               
"\n DEACTIVATED for inactive gateways")
-                                               )));
-       }
-       
-       @Test
-       public void documentUpdateSMSConfiguration() throws Exception {
-               final SMSConfiguration newRandomConfiguration = 
DomainObjectGenerator.smsConfiguration();
-               final SMSConfiguration randomSMSConfiguration = 
DomainObjectGenerator.smsConfiguration();
-               
-               
this.notificationManager.createSMSConfiguration(randomSMSConfiguration);
-               
-               
super.eventRecorder.wait(NotificationEventConstants.POST_SMS_CONFIGURATION, 
randomSMSConfiguration.getIdentifier());
-               
-               
newRandomConfiguration.setIdentifier(randomSMSConfiguration.getIdentifier());
-               newRandomConfiguration.setSender_number("new.host.com");
-               newRandomConfiguration.setState("ACTIVE");
-               newRandomConfiguration.setAccount_sid("asdLAKSKFssdfasdf554");
-               newRandomConfiguration.setAuth_token("aalkeifjlasdfalje333");
-               
-               
notificationManager.updateSMSConfiguration(randomSMSConfiguration);
-               
-               this.mockMvc.perform(put("/configuration/sms/update")
-                               .accept(MediaType.APPLICATION_JSON_VALUE)
-                               .contentType(MediaType.APPLICATION_JSON_VALUE)
-                               
.content(serialize.toJson(randomSMSConfiguration)))
-                               .andExpect(status().isAccepted())
-                               
.andDo(document("document-update-sms-configuration", 
preprocessRequest(prettyPrint()),
-                                               requestFields(
-                                                               
fieldWithPath("identifier").description("Configuration Id for SMS Gateway"),
-                                                               
fieldWithPath("auth_token").description("SMS API authentication token"),
-                                                               
fieldWithPath("account_sid").description("SMS API account SID"),
-                                                               
fieldWithPath("sender_number").description("SMS API sender number"),
-                                                               
fieldWithPath("state").description("The state of the Gateway" +
-                                                                               
"\n ACTIVE for Gateway to be used" +
-                                                                               
"\n DEACTIVATED for inactive gateways")
-                                               )));
-       }
-       
-       @Test
-       public void documentDeleteSMSConfiguration() throws Exception {
-               final SMSConfiguration randomSMSConfiguration = 
DomainObjectGenerator.smsConfiguration();
-               
-               
this.notificationManager.createSMSConfiguration(randomSMSConfiguration);
-               
-               
super.eventRecorder.wait(NotificationEventConstants.POST_SMS_CONFIGURATION, 
randomSMSConfiguration.getIdentifier());
-               
-               System.out.println(randomSMSConfiguration.getIdentifier());
-               this.mockMvc.perform(delete("/configuration/sms/delete/" + 
randomSMSConfiguration.getIdentifier())
-                               .accept(MediaType.APPLICATION_JSON_VALUE)
-                               .contentType(MediaType.APPLICATION_JSON_VALUE))
-                               .andExpect(status().isOk())
-                               
.andDo(document("document-delete-sms-configuration", 
preprocessRequest(prettyPrint())));
-       }
-       
-       @Test
-       public void documentDeleteEmailConfiguration() throws Exception {
-               final EmailConfiguration randomConfiguration = 
DomainObjectGenerator.emailConfiguration();
-               
-               
notificationManager.createEmailConfiguration(randomConfiguration);
-               
super.eventRecorder.wait(NotificationEventConstants.DELETE_EMAIL_CONFIGURATION, 
randomConfiguration.getIdentifier());
-               
-               this.mockMvc.perform(delete("/configuration/email/delete/" + 
randomConfiguration.getIdentifier())
-                               .accept(MediaType.APPLICATION_JSON_VALUE)
-                               .contentType(MediaType.APPLICATION_JSON_VALUE))
-                               .andExpect(status().isOk())
-                               
.andDo(document("document-delete-email-configuration", 
preprocessResponse(prettyPrint())));
-       }
-}
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/SmsApiDocumentation.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/SmsApiDocumentation.java
index 1655289..7566309 100644
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/SmsApiDocumentation.java
+++ 
b/component-test/src/main/java/org/apache/fineract/cn/notification/SmsApiDocumentation.java
@@ -37,8 +37,8 @@ import org.springframework.web.context.WebApplicationContext;
 
 import static 
org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
 import static 
org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
-import static 
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
-import static 
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
+import static 
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
+import static 
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete;
 import static 
org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
 import static 
org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
 import static org.springframework.restdocs.payload.PayloadDocumentation.*;
@@ -50,7 +50,9 @@ public class SmsApiDocumentation extends 
AbstractNotificationTest {
 
   @Autowired
   private WebApplicationContext context;
-
+  private Gson gson = new Gson();
+  
+  
   private MockMvc mockMvc;
 
   @Autowired
@@ -69,23 +71,23 @@ public class SmsApiDocumentation extends 
AbstractNotificationTest {
 
   @Test
   public void documentCreateSMSConfiguration() throws Exception {
-    final SMSConfiguration smsConfiguration = 
DomainObjectGenerator.smsConfiguration();
-
-    Gson gson = new Gson();
-    this.mockMvc.perform(post("/notification/sms/create")
-            .accept(MediaType.APPLICATION_JSON_VALUE)
-            .contentType(MediaType.APPLICATION_JSON_VALUE)
-            .content(gson.toJson(smsConfiguration)))
-            .andExpect(status().isAccepted())
-            .andDo(document("document-create-smsconfiguration", 
preprocessRequest(prettyPrint()),
-                    requestFields(
-                            
fieldWithPath("identifier").description("SMSConfiguration's identifier"),
-                            
fieldWithPath("auth_token").description("SMSConfiguration's auth_token"),
-                            
fieldWithPath("account_sid").description("SMSConfiguration's account_sid"),
-                            
fieldWithPath("sender_number").description("Sender's number"),
-                            
fieldWithPath("state").description("SMSConfiguration's state")
-                    )
-            ));
+    final SMSConfiguration randomSMSConfiguration = 
DomainObjectGenerator.smsConfiguration();
+  
+    this.mockMvc.perform(post("/configuration/sms/create")
+        .accept(MediaType.APPLICATION_JSON_VALUE)
+        .contentType(MediaType.APPLICATION_JSON_VALUE)
+        .content(gson.toJson(randomSMSConfiguration)))
+        .andExpect(status().isCreated())
+        .andDo(document("document-create-sms-configuration", 
preprocessRequest(prettyPrint()),
+            requestFields(
+                fieldWithPath("identifier").description("Configuration Id for 
SMS Gateway"),
+                fieldWithPath("auth_token").description("SMS API 
authentication token"),
+                fieldWithPath("account_sid").description("SMS API account 
SID"),
+                fieldWithPath("sender_number").description("SMS API sender 
number"),
+                fieldWithPath("state").description("The state of the Gateway" +
+                    "\n ACTIVE for Gateway to be used" +
+                    "\n DEACTIVATED for inactive gateways")
+            )));
   }
 
   @Test
@@ -100,7 +102,7 @@ public class SmsApiDocumentation extends 
AbstractNotificationTest {
     this.notificationManager.createSMSConfiguration(smsConfiguration);
     this.eventRecorder.wait(NotificationEventConstants.POST_SMS_CONFIGURATION, 
SMSConfiguration.class);
 
-    this.mockMvc.perform(get("/notification/sms/" + 
smsConfiguration.getIdentifier())
+    this.mockMvc.perform(get("/configuration/sms/" + 
smsConfiguration.getIdentifier())
             .accept(MediaType.ALL_VALUE)
             .contentType(MediaType.APPLICATION_JSON_VALUE))
             .andExpect(status().isOk())
@@ -115,4 +117,54 @@ public class SmsApiDocumentation extends 
AbstractNotificationTest {
                     )
             ));
   }
+  
+  @Test
+  public void documentUpdateSMSConfiguration() throws Exception {
+    final SMSConfiguration newRandomConfiguration = 
DomainObjectGenerator.smsConfiguration();
+    final SMSConfiguration randomSMSConfiguration = 
DomainObjectGenerator.smsConfiguration();
+    
+    this.notificationManager.createSMSConfiguration(randomSMSConfiguration);
+    
+    
super.eventRecorder.wait(NotificationEventConstants.POST_SMS_CONFIGURATION, 
randomSMSConfiguration.getIdentifier());
+    
+    
newRandomConfiguration.setIdentifier(randomSMSConfiguration.getIdentifier());
+    newRandomConfiguration.setSender_number("new.host.com");
+    newRandomConfiguration.setState("ACTIVE");
+    newRandomConfiguration.setAccount_sid("asdLAKSKFssdfasdf554");
+    newRandomConfiguration.setAuth_token("aalkeifjlasdfalje333");
+    
+    notificationManager.updateSMSConfiguration(randomSMSConfiguration);
+    
+    this.mockMvc.perform(put("/configuration/sms/update")
+        .accept(MediaType.APPLICATION_JSON_VALUE)
+        .contentType(MediaType.APPLICATION_JSON_VALUE)
+        .content(gson.toJson(randomSMSConfiguration)))
+        .andExpect(status().isAccepted())
+        .andDo(document("document-update-sms-configuration", 
preprocessRequest(prettyPrint()),
+            requestFields(
+                fieldWithPath("identifier").description("Configuration Id for 
SMS Gateway"),
+                fieldWithPath("auth_token").description("SMS API 
authentication token"),
+                fieldWithPath("account_sid").description("SMS API account 
SID"),
+                fieldWithPath("sender_number").description("SMS API sender 
number"),
+                fieldWithPath("state").description("The state of the Gateway" +
+                    "\n ACTIVE for Gateway to be used" +
+                    "\n DEACTIVATED for inactive gateways")
+            )));
+  }
+  
+  @Test
+  public void documentDeleteSMSConfiguration() throws Exception {
+    final SMSConfiguration randomSMSConfiguration = 
DomainObjectGenerator.smsConfiguration();
+    
+    this.notificationManager.createSMSConfiguration(randomSMSConfiguration);
+    
+    
super.eventRecorder.wait(NotificationEventConstants.POST_SMS_CONFIGURATION, 
randomSMSConfiguration.getIdentifier());
+    
+    System.out.println(randomSMSConfiguration.getIdentifier());
+    this.mockMvc.perform(delete("/configuration/sms/delete/" + 
randomSMSConfiguration.getIdentifier())
+        .accept(MediaType.APPLICATION_JSON_VALUE)
+        .contentType(MediaType.APPLICATION_JSON_VALUE))
+        .andExpect(status().isOk())
+        .andDo(document("document-delete-sms-configuration", 
preprocessRequest(prettyPrint())));
+  }
 }
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestApplicationAuthentication.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/TestApplicationAuthentication.java
deleted file mode 100644
index 49479be..0000000
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestApplicationAuthentication.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.fineract.cn.notification;
-
-import org.apache.fineract.cn.notification.api.v1.client.NotificationManager;
-import 
org.apache.fineract.cn.notification.service.internal.identity.NotificationAuthentication;
-import org.apache.fineract.cn.test.listener.EventRecorder;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Optional;
-
-public class TestApplicationAuthentication extends TestNotification {
-       
-       private final String applicationIdentifier = "customer-v1";
-       
-       @Autowired
-       NotificationAuthentication notificationAuthenticationMock;
-       
-       
-       public TestApplicationAuthentication() {
-               super();
-       }
-       
-       @Test
-       public void createApplicationPermissionForCustomerService() {
-               //Todo : look at it later
-               
//Assert.assertFalse(this.notificationAuthenticationMock.authenticateWithCustomerService(super.tenantDataStoreContext.getTenantName()));
-       }
-       
-}
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestEmailService.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/TestEmailService.java
index 65adbc6..6808678 100644
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestEmailService.java
+++ 
b/component-test/src/main/java/org/apache/fineract/cn/notification/TestEmailService.java
@@ -51,7 +51,7 @@ public class TestEmailService extends 
AbstractNotificationTest {
        
        
        @Test
-       public void sendEmail() throws InterruptedException {
+       public void shouldSendAnEmail() throws InterruptedException {
                this.logger.info("Send Email Notification");
                String messageHash = 
notificationService.sendEmail("[email protected]",
                                "[email protected]",
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestSMSService.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/TestSMSService.java
index 315c79b..37ab85f 100644
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestSMSService.java
+++ 
b/component-test/src/main/java/org/apache/fineract/cn/notification/TestSMSService.java
@@ -85,7 +85,7 @@ public class TestSMSService extends AbstractNotificationTest {
        }
        
        @Test
-       public void sendSMS() {
+       public void shouldSendAnSMS() {
                this.logger.info("Send SMS Notification");
                String messageHash = 
this.notificationService.sendSMS("+23058409206",
                                "Dear Valued Customer\n\nTalk is cheap show me 
the code\n\nBest Regards\nYour MFI");
diff --git 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestSuite.java
 
b/component-test/src/main/java/org/apache/fineract/cn/notification/TestSuite.java
index af10e31..ad4208a 100644
--- 
a/component-test/src/main/java/org/apache/fineract/cn/notification/TestSuite.java
+++ 
b/component-test/src/main/java/org/apache/fineract/cn/notification/TestSuite.java
@@ -25,8 +25,8 @@ import org.junit.runners.Suite;
 @Suite.SuiteClasses({
                TestEmailService.class,
                TestSMSService.class,
-               TestApplicationAuthentication.class,
-               NotificationApiDocumentation.class
+               EmailApiDocumentation.class,
+               SmsApiDocumentation.class,
 })
 public class TestSuite extends SuiteTestEnvironment {
 }
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/config/NotificationProperties.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/config/NotificationProperties.java
index a24b62c..93e31ba 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/config/NotificationProperties.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/config/NotificationProperties.java
@@ -46,6 +46,7 @@ import org.springframework.stereotype.Component;
 public class NotificationProperties {
        
        private String user;
+       private String password;
        
        public NotificationProperties() {
        }
@@ -57,4 +58,12 @@ public class NotificationProperties {
        public void setUser(String user) {
                this.user = user;
        }
+       
+       public String getPassword() {
+               return password;
+       }
+       
+       public void setPassword(String password) {
+               this.password = password;
+       }
 }
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/NotificationAuthentication.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/NotificationAuthentication.java
index d38ba3f..b3c357b 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/NotificationAuthentication.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/identity/NotificationAuthentication.java
@@ -20,8 +20,14 @@ package 
org.apache.fineract.cn.notification.service.internal.identity;
 
 import org.apache.fineract.cn.api.context.AutoUserContext;
 import org.apache.fineract.cn.api.util.InvalidTokenException;
+import org.apache.fineract.cn.api.util.UserContextHolder;
+import org.apache.fineract.cn.customer.api.v1.client.CustomerManager;
+import org.apache.fineract.cn.customer.api.v1.client.CustomerNotFoundException;
 import org.apache.fineract.cn.customer.api.v1.domain.Customer;
+import org.apache.fineract.cn.identity.api.v1.client.IdentityManager;
+import org.apache.fineract.cn.identity.api.v1.domain.Authentication;
 import org.apache.fineract.cn.lang.AutoTenantContext;
+import org.apache.fineract.cn.lang.TenantContextHolder;
 import org.apache.fineract.cn.notification.service.ServiceConstants;
 import 
org.apache.fineract.cn.notification.service.internal.config.NotificationProperties;
 import 
org.apache.fineract.cn.permittedfeignclient.service.ApplicationAccessTokenService;
@@ -29,6 +35,7 @@ import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
+import org.springframework.util.Base64Utils;
 
 import java.util.Optional;
 
@@ -38,16 +45,20 @@ public class NotificationAuthentication {
        private Logger logger;
        private CustomerPermittedClient customerPermittedClient;
        private NotificationProperties notificationProperties;
+       private IdentityManager identityManager;
+       
        
        @Autowired
        public NotificationAuthentication(final NotificationProperties 
notificationPropertities,
-                                         final CustomerPermittedClient 
customerPermittedClient,
+                                         final IdentityManager identityManager,
+                                                     final 
CustomerPermittedClient customerPermittedClient,
                                          
@SuppressWarnings("SpringJavaAutowiringInspection")final 
ApplicationAccessTokenService applicationAccessTokenService,
                                          
@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
                this.logger = logger;
                this.customerPermittedClient = customerPermittedClient;
                this.notificationProperties = notificationPropertities;
                this.applicationAccessTokenService = 
applicationAccessTokenService;
+               this.identityManager = identityManager;
        }
        
        public Optional<Customer> getCustomer(String tenantIdentifier, String 
customerId) {
@@ -65,4 +76,14 @@ public class NotificationAuthentication {
                                return Optional.empty();
                        }
        }
+       
+       public void authenticate(String tenant) {
+               TenantContextHolder.clear();
+               TenantContextHolder.setIdentifier(tenant);
+               
+               final Authentication authentication =
+                               
this.identityManager.login(notificationProperties.getUser(), 
Base64Utils.encodeToString(notificationProperties.getPassword().getBytes()));
+               UserContextHolder.clear();
+               
UserContextHolder.setAccessToken(notificationProperties.getUser(), 
authentication.getAccessToken());
+       }
 }
diff --git 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/NotificationService.java
 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/NotificationService.java
index 783adc8..02b3621 100644
--- 
a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/NotificationService.java
+++ 
b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/NotificationService.java
@@ -60,8 +60,9 @@ public class NotificationService {
        }
        
        public Optional<Customer> findCustomer(final String customerIdentifier, 
String tenant) {
-               return 
notificationAuthentication.getCustomer(tenant,customerIdentifier);
-               //return 
Optional.of(this.customerPermittedClient.findCustomer(customerIdentifier));
+               notificationAuthentication.authenticate(tenant);
+               //return 
notificationAuthentication.getCustomer(tenant,customerIdentifier);
+               return customerService.findCustomer(customerIdentifier);
        }
        
        //SMS Related Operations
diff --git a/service/src/main/resources/application.yml 
b/service/src/main/resources/application.yml
index a1d6207..d1c0460 100644
--- a/service/src/main/resources/application.yml
+++ b/service/src/main/resources/application.yml
@@ -83,4 +83,5 @@ flyway:
   enabled: false
 
 notification:
-  user: wadaadmin
\ No newline at end of file
+  user: operator
+  password: init1@l
diff --git 
a/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql 
b/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
index 7f66214..9e1aba3 100644
--- a/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
+++ b/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
@@ -66,5 +66,5 @@ CREATE TABLE wada_templates (
   PRIMARY KEY (id)
 );
 
-INSERT INTO wada_sms_gateway_configurations VALUES ('1', 'Twilio', 
'AC1fde2c6f26f367b93231c5fdb944c908', 'bc9a53e41745b8471e0ecafc859d86aa', '+1 
510-944-1898', 'ACTIVE');
-INSERT INTO wada_email_gateway_configurations VALUES ('1', 'Gmail', 
'smtp.gmail.com', '587','[email protected]', 
'pnuugpwmcibipdpw', 'smtp', 'true', 'true', 'ACTIVE');
\ No newline at end of file
+INSERT INTO wada_sms_gateway_configurations VALUES ('1', 'Twilio', 
'ACdc00866577a42133e16d98456ad15592', '0b2f78b1c083eb71599d014d1af5748e', 
'+12055486680', 'ACTIVE');
+INSERT INTO wada_email_gateway_configurations VALUES ('1', 'Gmail', 
'smtp.gmail.com', '587','[email protected]', 
'pnuugpwmcibipdpw', 'smtp', 'true', 'true', 'ACTIVE');

Reply via email to