aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/LoggerControllerTest.java15
3 files changed, 20 insertions, 3 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
index 7233a67e3..f5b325b4a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
@@ -66,7 +66,7 @@ public class LoggerController extends RestrictedBaseController {
this.logfilePathCreator = logfilePathCreator;
}
- @GetMapping(value = "/{loggerName:audit|audit2019|error|metrics|metrics2019}")
+ @GetMapping(value = "/{loggerName:audit|audit2019|error|metrics|metrics2019|debug}")
public String getLog(@PathVariable String loggerName, HttpServletRequest request,
@RequestParam(value="limit", defaultValue = "5000") Integer limit) throws IOException {
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
index c50578e82..cfb848007 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
@@ -69,6 +69,7 @@ import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.togglz.core.manager.FeatureManager;
@@ -222,7 +223,8 @@ public class WebConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(new VidLoggingInterceptor(
- new ControllersUtils(new SystemPropertiesWrapper())));
+ registry.addInterceptor(
+ new VidLoggingInterceptor(new ControllersUtils(new SystemPropertiesWrapper()))
+ ).order(Ordered.HIGHEST_PRECEDENCE);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/LoggerControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/LoggerControllerTest.java
index fdc0f44d1..f0d840929 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/LoggerControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/LoggerControllerTest.java
@@ -108,4 +108,19 @@ public class LoggerControllerTest {
.andExpect(content().string(""))
.andExpect(status().isOk());
}
+
+ @Test
+ public void shouldReturnEmptyString_whenDebugLogFileIsEmpty() throws Exception {
+ List<Role> list = ImmutableList.of(new Role(EcompRole.READ, "subName1", "servType1", "tenant1"));
+
+ given(provider.getUserRoles(argThat(req -> req.getRequestedSessionId().equals("id1")))).willReturn(list);
+ given(provider.userPermissionIsReadLogs(list)).willReturn(true);
+ given(creator.getLogfilePath("debug")).willReturn(EMPTY_LOG_PATH);
+
+ mockMvc.perform(get("/logger/debug")
+ .with(req -> {req.setRequestedSessionId("id1");
+ return req;}))
+ .andExpect(content().string(""))
+ .andExpect(status().isOk());
+ }
}