public static SamlAuthenticationStatus getSamlAuthenticationStatus(String samlResponse, Auth auth, SamlSettings samlSettings) {

    SamlAuthenticationStatus samlAuthenticationStatus = new SamlAuthenticationStatus();

    try {
      auth.processResponse();
    } catch (Exception e) {
      samlAuthenticationStatus.getErrors().add(e.getMessage());
    }

    samlAuthenticationStatus.getErrors().addAll(auth.getErrors().stream().filter(Objects::nonNull).toList());
    if (auth.getLastErrorReason() != null) {
      samlAuthenticationStatus.getErrors().add(auth.getLastErrorReason());
    }
    if (samlAuthenticationStatus.getErrors().isEmpty()) {
      samlAuthenticationStatus.getErrors().addAll(generateMappingErrors(auth, samlSettings));
    }
    samlAuthenticationStatus.setAvailableAttributes(auth.getAttributes());
    samlAuthenticationStatus.setMappedAttributes(getAttributesMapping(auth, samlSettings));

    samlAuthenticationStatus.setSignatureEnabled(isSignatureEnabled(auth, samlSettings));
    samlAuthenticationStatus.setEncryptionEnabled(isEncryptionEnabled(auth, samlResponse));

    samlAuthenticationStatus.setWarnings(samlAuthenticationStatus.getErrors().isEmpty() ? generateWarnings(auth, samlSettings) : new ArrayList<>());
    samlAuthenticationStatus.setStatus(samlAuthenticationStatus.getErrors().isEmpty() ? "success" : "error");

    return samlAuthenticationStatus;

  }
@Test
  public void authentication_has_no_warnings_when_optional_mappings_are_not_provided() {
    setSettings();
    settings.setProperty("sonar.auth.saml.sp.privateKey.secured", (String) null);
    settings.setProperty(USER_EMAIL_ATTRIBUTE, (String) null);
    settings.setProperty(GROUP_NAME_ATTRIBUTE, (String) null);
    getResponseAttributes().forEach((key, value) -> when(auth.getAttribute(key)).thenReturn(value));

    samlAuthenticationStatus = getSamlAuthenticationStatus(BASE64_SAML_RESPONSE, auth, new SamlSettings(settings.asConfig()));

    assertEquals("success", samlAuthenticationStatus.getStatus());
    assertTrue(samlAuthenticationStatus.getErrors().isEmpty());
    assertTrue(samlAuthenticationStatus.getWarnings().isEmpty());
  }