### Question:
AuthnRequestFromTransactionValidator implements SamlValidator<AuthnRequest> { @Override public void validate(AuthnRequest request) { issuerValidator.validate(request.getIssuer()); validateRequestId(request); validateIssueInstant(request); validateSignaturePresence(request); validateVersion(request); validateNameIdPolicy(request); validateScoping(request); validateProtocolBinding(request); validatePassiveXSBoolean(request); } AuthnRequestFromTransactionValidator(
            IssuerValidator issuerValidator,
            DuplicateAuthnRequestValidator duplicateAuthnRequestValidator,
            AuthnRequestIssueInstantValidator issueInstantValidator); @Override void validate(AuthnRequest request);  }### Answer:
@Test public void validate_shouldDoNothingIfIdIsValid() throws Exception { validator.validate(anAuthnRequest().withId("a43qif88dsfv").build()); validator.validate(anAuthnRequest().withId("_443qif88dsfv").build()); }
@Test public void validateRequest_shouldDoNothingIfRequestIsSigned() throws Exception { validator.validate(anAuthnRequest().build()); }
@Test public void validateIssuer_shouldDoNothingIfFormatAttributeIsMissing() throws Exception { validator.validate(anAuthnRequest().withIssuer(anIssuer().withFormat(null).build()).build()); }
@Test public void validateIssuer_shouldDoNothingIfFormatAttributeHasValidValue() throws Exception { validator.validate(anAuthnRequest().withIssuer(anIssuer().withFormat(NameIDType.ENTITY).build()).build()); }
@Test public void validateNameIdPolicy_shouldDoNothingIfNameIdPolicyIsMissing() throws Exception { validator.validate(anAuthnRequest().build()); }
@Test public void validateNameIdPolicy_shouldDoNothingIfNameIdPolicyFormatHasValidValue() throws Exception { validator.validate(anAuthnRequest().withNameIdPolicy(aNameIdPolicy().withFormat(NameIDType.PERSISTENT).build()).build()); }
@Test public void validateProtocolBinding_shouldDoNothingIfProtocolBindingHasValidValue() throws Exception { validator.validate(anAuthnRequest().withProtocolBinding(SAMLConstants.SAML2_POST_BINDING_URI).build()); }
@Test(expected = SamlDuplicateRequestIdException.class) public void validateRequest_shouldThrowExceptionIfIsDuplicateRequestIdIsPresent() throws Exception { final String requestId = generateRequestId(); final String oneIssuerId = "some-issuer-id"; final String anotherIssuerId = "some-other-issuer-id"; final AuthnRequest authnRequest = anAuthnRequest().withId(requestId).withIssuer(anIssuer().withIssuerId(oneIssuerId).build()).build(); validator.validate(authnRequest); final AuthnRequest duplicateIdAuthnRequest = anAuthnRequest().withId(requestId).withIssuer(anIssuer().withIssuerId(anotherIssuerId).build()).build(); validateThrows( duplicateIdAuthnRequest, SamlTransformationErrorFactory.duplicateRequestId(requestId, duplicateIdAuthnRequest.getIssuer().getValue()) ); }
@Test public void validate_shouldDoNothingIfVersionNumberIsTwoPointZero() throws Exception { validator.validate(anAuthnRequest().withVersionNumber(SAML_VERSION_NUMBER).build()); }