use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class AuthnRequestFromTransactionValidatorTest method validateRequest_shouldThrowExceptionIfIsDuplicateRequestIdIsPresent.
@Test
public void validateRequest_shouldThrowExceptionIfIsDuplicateRequestIdIsPresent() {
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();
validateException(assertThrows(SamlTransformationErrorException.class, () -> validator.validate(duplicateIdAuthnRequest)), SamlTransformationErrorFactory.duplicateRequestId(requestId, duplicateIdAuthnRequest.getIssuer().getValue()));
}
use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class AuthnRequestFromTransactionValidatorTest method validate_shouldThrowExceptionIfVersionNumberIsMissing.
@Test
public void validate_shouldThrowExceptionIfVersionNumberIsMissing() {
AuthnRequest authnRequest = anAuthnRequest().withVersionNumber(null).build();
validateException(assertThrows(SamlTransformationErrorException.class, () -> validator.validate(authnRequest)), SamlTransformationErrorFactory.missingRequestVersion(authnRequest.getID()));
}
use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class AuthnRequestFromTransactionValidatorTest method validateRequest_shouldThrowExceptionIfRequestIsTooOld.
@Test
public void validateRequest_shouldThrowExceptionIfRequestIsTooOld() {
DateTimeFreezer.freezeTime();
String requestId = generateRequestId();
DateTime issueInstant = DateTime.now().minusMinutes(5).minusSeconds(1);
final AuthnRequest authnRequest = anAuthnRequest().withId(requestId).withIssueInstant(issueInstant).build();
validateException(assertThrows(SamlTransformationErrorException.class, () -> validator.validate(authnRequest)), SamlTransformationErrorFactory.requestTooOld(requestId, issueInstant.withZone(DateTimeZone.UTC), DateTime.now()));
}
use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class AuthnRequestFromTransactionValidatorTest method validate_shouldThrowExceptionIfIssueInstantIsMissing.
@Test
public void validate_shouldThrowExceptionIfIssueInstantIsMissing() {
AuthnRequest authnRequest = anAuthnRequest().withIssueInstant(null).build();
validateException(assertThrows(SamlTransformationErrorException.class, () -> validator.validate(authnRequest)), SamlTransformationErrorFactory.missingRequestIssueInstant(authnRequest.getID()));
}
use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class SamlMessageReceiverApiTest method handleRequestPost_shouldLogSamlRequestInCorrectFormat.
@Test
public void handleRequestPost_shouldLogSamlRequestInCorrectFormat() {
AuthnRequest authnRequest = anAuthnRequest().withIssuer(anIssuer().withIssuerId(ISSUER_ID).build()).withDestination(DESTINATION).build();
when(samlMessageSignatureValidator.validate(any(AuthnRequest.class), any(QName.class))).thenReturn(SamlValidationResponse.aValidResponse());
when(stringSamlAuthnRequestTransformer.apply(SAML_REQUEST)).thenReturn(authnRequest);
when(sessionProxy.createSession(any(SamlAuthnRequestContainerDto.class))).thenReturn(SESSION_ID);
samlMessageReceiverApi.handleRequestPost(SAML_REQUEST_DTO);
verify(protectiveMonitoringLogger).logAuthnRequest(authnRequest, Direction.INBOUND, SignatureStatus.VALID_SIGNATURE);
}
Aggregations