X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fresources%2FAAFAuthenticationFilterTest.java;h=76fe91410844cb449e0d96850ddad5030959ad7d;hb=18eaae524174fac4f21d83c94bb8347a29d9f879;hp=d5ae5fd4e9bc3013aadefd63ac6e0d94de31d7d5;hpb=03b16f6df6fe5545a4ed219916c77dd696694ea2;p=dmaap%2Fdbcapi.git 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 d5ae5fd..76fe914 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 @@ -118,16 +118,33 @@ public class AAFAuthenticationFilterTest { } @Test - public void init_shouldInitializeCADI_whenAafIsUsed_andCadiPropertiesSet() throws Exception { + public void init_shouldFail_whenAafIsUsed_andInvalidCadiPropertiesSet() throws Exception { //given - doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.AAF_AUTHN_FLAG), anyString()); - doReturn("cadi.properties").when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES); + String invalidFilePath = "src/test/resources/notExisting.properties"; + doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.CADI_AUTHN_FLAG), anyString()); + doReturn(invalidFilePath).when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES); + + //then + thrown.expect(ServletException.class); + thrown.expectMessage("Could not load CADI properties file: "+invalidFilePath); + + //when + filter.init(filterConfig); + } + + /* + * See https://jira.onap.org/browse/DMAAP-1361 for why this is commented out + @Test + public void init_shouldInitializeCADI_whenAafIsUsed_andValidCadiPropertiesSet() throws Exception { + //given + 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()); } @@ -169,10 +186,10 @@ public class AAFAuthenticationFilterTest { } private void initCADIFilter() throws Exception{ - doReturn("true").when(dmaapConfig).getProperty(eq(AAFAuthenticationFilter.AAF_AUTHN_FLAG), anyString()); - doReturn("cadi.properties").when(dmaapConfig).getProperty(AAFAuthenticationFilter.CADI_PROPERTIES); + 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); } - +*/ } \ No newline at end of file