Source:
public void testCreateAuthenticationDecisionStatements() throws PropertyAccessException { final CallbackProperties callbackProps = mock(CallbackProperties.class); final Subject subject = mock(Subject.class); final DateTime beforeCreation = new DateTime(); when(callbackProps.getAuthorizationStatementExists()).thenReturn(true); final List<AuthzDecisionStatement> statementList = new HOKSAMLAssertionBuilder() .createAuthorizationDecisionStatements(callbackProps, subject); assertFalse(statementList.isEmpty()); final AuthzDecisionStatement statement = statementList.get(0); assertEquals(statement.getDecision(), DecisionTypeEnumeration.PERMIT); final Action action = statement.getActions().get(0); assertEquals(action.getAction(), SAMLAssertionBuilder.AUTHZ_DECISION_ACTION_EXECUTE); final Evidence evidence = statement.getEvidence(); final Assertion assertion = evidence.getAssertions().get(0); assertTrue(assertion.getID().startsWith("_")); assertTrue(beforeCreation.isBefore(assertion.getIssueInstant()) || beforeCreation.isEqual(assertion.getIssueInstant())); final Issuer issuer = assertion.getIssuer(); assertEquals(issuer.getFormat(), SAMLAssertionBuilder.X509_NAME_ID); final Conditions conditions = assertion.getConditions(); assertNull(conditions); final List<AttributeStatement> attributeStatement = assertion.getAttributeStatements(); assertEquals(attributeStatement.get(0).getAttributes().size(), 2); final Attribute firstAttribute = attributeStatement.get(0).getAttributes().get(0); final Attribute secondAttribute = attributeStatement.get(0).getAttributes().get(1); assertEquals(firstAttribute.getName(), "AccessConsentPolicy"); assertEquals(secondAttribute.getName(), "InstanceAccessConsentPolicy"); }

Target:
public void testCreateAuthenticationDecisionStatements() throws PropertyAccessException { final CallbackProperties callbackProps = mock(CallbackProperties.class); final Subject subject = mock(Subject.class); final DateTime beforeCreation = new DateTime(); final DateTime conditionNotBefore = new DateTime(); final DateTime conditionNotAfter = conditionNotBefore.plusMinutes(5); when(callbackProps.getEvidenceConditionNotBefore()).thenReturn(conditionNotBefore); when(callbackProps.getEvidenceConditionNotAfter()).thenReturn(conditionNotAfter); when(callbackProps.getAuthorizationStatementExists()).thenReturn(true); final List<AuthzDecisionStatement> statementList = getHOKSAMLAssertionBuilder() .createAuthorizationDecisionStatements(callbackProps, subject); assertFalse(statementList.isEmpty()); final AuthzDecisionStatement statement = statementList.get(0); assertEquals(statement.getDecision(), DecisionTypeEnumeration.PERMIT); final Action action = statement.getActions().get(0); assertEquals(action.getAction(), SAMLAssertionBuilder.AUTHZ_DECISION_ACTION_EXECUTE); final Evidence evidence = statement.getEvidence(); final Assertion assertion = evidence.getAssertions().get(0); assertTrue(assertion.getID().startsWith("_")); assertTrue(beforeCreation.isBefore(assertion.getIssueInstant()) || beforeCreation.isEqual(assertion.getIssueInstant())); final Issuer issuer = assertion.getIssuer(); assertEquals(issuer.getFormat(), SAMLAssertionBuilder.X509_NAME_ID); final Conditions conditions = assertion.getConditions(); assertEquals(conditions.getNotBefore(), conditionNotBefore.withZone(DateTimeZone.UTC)); assertEquals(conditions.getNotOnOrAfter(), conditionNotAfter.withZone(DateTimeZone.UTC)); final List<AttributeStatement> attributeStatement = assertion.getAttributeStatements(); assertEquals(attributeStatement.get(0).getAttributes().size(), 2); final Attribute firstAttribute = attributeStatement.get(0).getAttributes().get(0); final Attribute secondAttribute = attributeStatement.get(0).getAttributes().get(1); assertEquals(firstAttribute.getName(), "AccessConsentPolicy"); assertEquals(secondAttribute.getName(), "InstanceAccessConsentPolicy"); }