- /*@Test
- public void testProtected() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- Method newTransMethod = AuthzTransFilter.class.getDeclaredMethod("newTrans");
- newTransMethod.setAccessible(true);
-
- newTransMethod.invoke(authzTransFilter);
- }*/
-
- @Test
- public void testAuthenticated() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, CadiException {
- Principal p = mock(Principal.class);
- AuthzTransFilter aTF = new AuthzTransFilter(authzEnvMock, connectorMock, trustCheckerMock, null);
- Class c = aTF.getClass();
- Class[] cArg = new Class[2];
- cArg[0] = AuthzTrans.class;
- cArg[1] = Principal.class; //Steps to test a protected method
- Method authenticatedMethod = c.getDeclaredMethod("authenticated", cArg);
- authenticatedMethod.setAccessible(true);
- authenticatedMethod.invoke(aTF,authzTransMock, null);
- }
-
- @Test
- public void testTallyHo() throws CadiException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- Slot specialLogSlot = authzEnvMock.slot("SPECIAL_LOG_SLOT");
- LogTarget lt = mock(LogTarget.class);
- AuthzTransFilter aTF = new AuthzTransFilter(authzEnvMock, connectorMock, trustCheckerMock, additionalTafLurs);
- TaggedPrincipal tPrin = mock(TaggedPrincipal.class);
- Metric met = new Metric();
- met.total = 199.33F;
- met.entries = 15;
- met.buckets = new float[] {199.33F,99.33F};
- Class c = aTF.getClass();
- Class[] cArg = new Class[1];
- cArg[0] = AuthzTrans.class; //Steps to test a protected method
- Method tallyHoMethod = c.getDeclaredMethod("tallyHo", cArg);
- StringBuilder sb = new StringBuilder("AuditTrail\n");
- when(authzTransMock.auditTrail(((LogTarget)any()), anyInt(),(StringBuilder)any(),anyInt(),anyInt())).thenReturn(met);
- tallyHoMethod.setAccessible(true);
- when(authzTransMock.get(specialLogSlot, false)).thenReturn(false);
- when(authzTransMock.warn()).thenReturn(lt);
- when(authzTransMock.info()).thenReturn(lt);
- tallyHoMethod.invoke(aTF,authzTransMock);
- when(authzTransMock.getUserPrincipal()).thenReturn(tPrin);
- tallyHoMethod.invoke(aTF,authzTransMock);
-
- }
-
-
-
-