summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorTomek Kaminski <tomasz.kaminski@nokia.com>2019-04-29 10:57:38 +0200
committerTomek Kaminski <tomasz.kaminski@nokia.com>2019-04-29 10:57:38 +0200
commit682f1965193e672620bc8766fec6bcb2648aa8e5 (patch)
tree722aa7558a6fa672032020f5cbad3171d9347c40 /src/test
parent40e1e60eb8d8cc18d8542dbd7c00f69a9cc3042d (diff)
move authN and authZ filter decission to enableCADI flag
Change-Id: If4aa4fb58c0eb4431ec6a6377db12fa3da23682e Issue-ID: DMAAP-1181 Signed-off-by: Tomek Kaminski <tomasz.kaminski@nokia.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilterTest.java16
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthorizationFilterTest.java8
2 files changed, 12 insertions, 12 deletions
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilterTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilterTest.java
index 53c8021..137c518 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilterTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthenticationFilterTest.java
@@ -78,20 +78,20 @@ public class AAFAuthenticationFilterTest {
@Test
public void init_shouldNotInitializeCADI_whenAafIsNotUsed() throws Exception {
//given
- doReturn("false").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.AAF_AUTHN_FLAG), anyString());
+ doReturn("false").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString());
//when
filter.init(filterConfig);
//then
- assertFalse(filter.isAafEnabled());
+ assertFalse(filter.isCadiEnabled());
assertNull(filter.getCadiFilter());
}
@Test
public void doFilter_shouldSkipCADI_whenAafIsNotUsed() throws Exception {
//given
- doReturn("false").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.AAF_AUTHN_FLAG), anyString());
+ doReturn("false").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString());
filter.init(filterConfig);
filter.setCadiFilter(cadiFilterMock);
@@ -106,7 +106,7 @@ public class AAFAuthenticationFilterTest {
@Test
public void init_shouldFail_whenAafIsUsed_andCadiPropertiesHasNotBeenSet() throws Exception {
//given
- doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.AAF_AUTHN_FLAG), anyString());
+ doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString());
doReturn("").when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES);
//then
@@ -121,7 +121,7 @@ public class AAFAuthenticationFilterTest {
public void init_shouldFail_whenAafIsUsed_andInvalidCadiPropertiesSet() throws Exception {
//given
String invalidFilePath = "src/test/resources/notExisting.properties";
- doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.AAF_AUTHN_FLAG), anyString());
+ doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString());
doReturn(invalidFilePath).when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES);
//then
@@ -135,14 +135,14 @@ public class AAFAuthenticationFilterTest {
@Test
public void init_shouldInitializeCADI_whenAafIsUsed_andValidCadiPropertiesSet() throws Exception {
//given
- doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.AAF_AUTHN_FLAG), anyString());
+ doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString());
doReturn("src/test/resources/cadi.properties").when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES);
//when
filter.init(filterConfig);
//then
- assertTrue(filter.isAafEnabled());
+ assertTrue(filter.isCadiEnabled());
assertNotNull(filter.getCadiFilter());
}
@@ -184,7 +184,7 @@ public class AAFAuthenticationFilterTest {
}
private void initCADIFilter() throws Exception{
- doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.AAF_AUTHN_FLAG), anyString());
+ doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString());
doReturn("src/test/resources/cadi.properties").when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES);
filter.init(filterConfig);
filter.setCadiFilter(cadiFilterMock);
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthorizationFilterTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthorizationFilterTest.java
index 73794cd..a935bc2 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthorizationFilterTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/AAFAuthorizationFilterTest.java
@@ -107,7 +107,7 @@ public class AAFAuthorizationFilterTest {
@Test
public void doFilter_shouldSkipAuthorization_whenAAFnotUsed() throws Exception {
//given
- filter.setAafEnabled(false);
+ filter.setCadiEnabled(false);
//when
filter.doFilter(servletRequest,servletResponse,filterChain);
@@ -125,7 +125,7 @@ public class AAFAuthorizationFilterTest {
String permission = "org.onap.dmaap-bc.api.topics|mr|GET";
when(permissionBuilder.buildPermission(servletRequest)).thenReturn(permission);
configureServletRequest(permission, user, true);
- filter.setAafEnabled(true);
+ filter.setCadiEnabled(true);
//when
filter.doFilter(servletRequest,servletResponse,filterChain);
@@ -143,7 +143,7 @@ public class AAFAuthorizationFilterTest {
String permission = "org.onap.dmaap-bc.api.topics|mr|GET";
when(permissionBuilder.buildPermission(servletRequest)).thenReturn(permission);
configureServletRequest(permission, user, false);
- filter.setAafEnabled(true);
+ filter.setCadiEnabled(true);
String errorMsgJson = "{\"code\":403,\"message\":\"User "+user+" does not have permission "
+ permission +"\",\"fields\":\"Authorization\",\"2xx\":false}";
@@ -167,6 +167,6 @@ public class AAFAuthorizationFilterTest {
}
private void configureAAFUsage(Boolean isUsed) {
- doReturn(isUsed.toString()).when(dmaapConfig).getProperty(eq(AAFAuthorizationFilter.AAF_AUTHZ_FLAG), anyString());
+ doReturn(isUsed.toString()).when(dmaapConfig).getProperty(eq(AAFAuthorizationFilter.CADI_AUTHZ_FLAG), anyString());
}
} \ No newline at end of file