### Question:
SignatureVerifierImpl implements SignatureVerifier { @Override public boolean verify(String signature, String tppEncodedCert, Map<String, String> headers, String method, String url) { X509Certificate certificate = X509CertUtils.parse( CertificateUtils.normalizeCertificate(tppEncodedCert) ); if (certificate == null) { log.warn("TPP Certificate couldn't be parsed!"); return false; } Signature signatureData = Signature.fromString(signature); if (!isKeyIdValid(certificate, signatureData.getKeyId())) { log.warn("Key ID is invalid!"); return false; } Map<String, String> headersMap = RequestHeaders.fromMap(headers).toMap(); try { Verifier verifier = new Verifier(certificate.getPublicKey(), signatureData); return verifier.verify(method, url, headersMap); } catch (Exception e) { log.warn("Signature verification has an error: {}", e.getMessage()); return false; } }  @Override boolean verify(String signature, String tppEncodedCert, Map<String, String> headers, String method, String url);  }### Answer:
@Test void verify_success_POST() { boolean actualResult = signatureVerifier.verify(signature(), certificate(), headerMap, POST_METHOD, URI); assertThat(actualResult).isTrue(); }
@Test void verify_nonNormalisedCertificate_success_POST() { boolean actualResult = signatureVerifier.verify(signature(), nonNormalizedCertificate(), headerMap, POST_METHOD, URI); assertThat(actualResult).isTrue(); }
@Test void verify_success_GET() { boolean actualResult = signatureVerifier.verify(signature(), certificate(), headerMap, GET_METHOD, URI); assertThat(actualResult).isTrue(); }
@Test void verify_emptySomeHeaders() { headerMap.remove("x-request-id"); headerMap.remove("psu-ip-address"); boolean actualResult = signatureVerifier.verify(signature(), certificate(), headerMap, POST_METHOD, URI); assertThat(actualResult).isFalse(); }
@Test void verify_wrongSignatureHash() { boolean actualResult = signatureVerifier.verify(wrongSignatureHash(), certificate(), headerMap, POST_METHOD, URI); assertThat(actualResult).isFalse(); }
@Test void verify_wrongSignatureHeader() { boolean actualResult = signatureVerifier.verify(signatureWrongHeaders(), certificate(), headerMap, POST_METHOD, URI); assertThat(actualResult).isFalse(); }
@Test void verify_wrongSignatureKeyId() { boolean actualResult = signatureVerifier.verify(signatureWrongKeyId(), certificate(), headerMap, POST_METHOD, URI); assertThat(actualResult).isFalse(); }
@Test void verify_wrongTppCertificate() { boolean actualResult = signatureVerifier.verify(signature(), wrongCertificate(), headerMap, POST_METHOD, URI); assertThat(actualResult).isFalse(); }