Skip to content

Commit f8ec2ef

Browse files
authored
Fix tests by replacing documentNumbers with working ones. Update dependencies. (#77)
* fix tests by replacing documentNumbers with working ones. update dependencies. * downgrade jersey to 3.0.x as 3.1.x does not work with Java 8 * downgrade resteasy * downgrade resteasy to 6.0.x as higher versions don't work with Java 8 * fix typo in README.md * remove codecov --------- Co-authored-by: juhanaasaru <Juhan.Aasaru@nortal.com>
1 parent 0ebb521 commit f8ec2ef

9 files changed

Lines changed: 61 additions & 93 deletions

File tree

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ env:
1111
before_install:
1212
- eval $(openssl aes-256-cbc -K $encrypted_key -iv $encrypted_iv -in private.key.enc -out private.key -d)
1313
- chmod +x travis.sh
14-
- pip install --user codecov
1514
install: true
16-
after_success:
17-
- codecov
1815
script:
1916
- "./travis.sh"

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ String verificationCode = authenticationHash.calculateVerificationCode();
214214

215215
SmartIdAuthenticationResponse authenticationResponse = client
216216
.createAuthentication()
217-
.withDocumentNumber("PNOLT-30303039914-PBZK-Q")
217+
.withDocumentNumber("PNOLT-30303039914-MOCK-Q")
218218
.withAuthenticationHash(authenticationHash)
219219
.withCertificateLevel("QUALIFIED")
220220
.withAllowedInteractionsOrder(Collections.singletonList(
@@ -291,7 +291,7 @@ To fetch the certificate you can use documentNumber.
291291
```java
292292
SmartIdCertificate responseWithSigningCertificate = client
293293
.getCertificate()
294-
.withDocumentNumber("PNOLT-30303039914-PBZK-Q") // returned as authentication result
294+
.withDocumentNumber("PNOLT-30303039914-MOCK-Q") // returned as authentication result
295295
.withCertificateLevel("QUALIFIED")
296296
.fetch();
297297

@@ -328,7 +328,7 @@ String verificationCode = hashToSign.calculateVerificationCode();
328328

329329
SmartIdSignature smartIdSignature = client
330330
.createSignature()
331-
.withDocumentNumber("PNOLT-30303039914-PBZK-Q") // returned as authentication result
331+
.withDocumentNumber("PNOLT-30303039914-MOCK-Q") // returned as authentication result
332332
.withSignableHash(hashToSign)
333333
.withCertificateLevel("QUALIFIED")
334334
.withAllowedInteractionsOrder(asList(
@@ -372,7 +372,7 @@ Every Smart-ID app supports this interaction flow and there is no need to provid
372372
```java
373373
SmartIdSignature smartIdSignature = client
374374
.createSignature()
375-
.withDocumentNumber("PNOLT-30303039914-PBZK-Q")
375+
.withDocumentNumber("PNOLT-30303039914-MOCK-Q")
376376
.withSignableHash(hashToSign)
377377
.withCertificateLevel("QUALIFIED")
378378
.withAllowedInteractionsOrder(Collections.singletonList(
@@ -394,7 +394,7 @@ If user's app doesn't support displaying verification code choice then system fa
394394
try {
395395
SmartIdSignature smartIdSignature = client
396396
.createSignature()
397-
.withDocumentNumber("PNOLT-30303039914-PBZK-Q")
397+
.withDocumentNumber("PNOLT-30303039914-MOCK-Q")
398398
.withSignableHash(hashToSign)
399399
.withCertificateLevel("QUALIFIED")
400400
.withAllowedInteractionsOrder(Arrays.asList(
@@ -417,7 +417,7 @@ If the Smart-ID app in user's smart device doesn't support this feature then the
417417
```java
418418
SmartIdSignature smartIdSignature = client
419419
.createSignature()
420-
.withDocumentNumber("PNOLT-30303039914-PBZK-Q")
420+
.withDocumentNumber("PNOLT-30303039914-MOCK-Q")
421421
.withSignableHash(hashToSign)
422422
.withCertificateLevel("QUALIFIED")
423423
.withAllowedInteractionsOrder(asList(
@@ -445,7 +445,7 @@ If user picks wrong verification code then the session is cancelled and library
445445
```java
446446
SmartIdSignature smartIdSignature = client
447447
.createSignature()
448-
.withDocumentNumber("PNOLT-30303039914-PBZK-Q")
448+
.withDocumentNumber("PNOLT-30303039914-MOCK-Q")
449449
.withSignableHash(hashToSign)
450450
.withCertificateLevel("QUALIFIED")
451451
.withAllowedInteractionsOrder(asList(
@@ -476,7 +476,7 @@ If End User's phone doesn't support required flow the library throws `RequiredIn
476476
try {
477477
client
478478
.createSignature()
479-
.withDocumentNumber("PNOLT-30303039914-PBZK-Q")
479+
.withDocumentNumber("PNOLT-30303039914-MOCK-Q")
480480
.withSignableHash(hashToSign)
481481
.withCertificateLevel("QUALIFIED")
482482
.withAllowedInteractionsOrder(Collections.singletonList(
@@ -503,7 +503,7 @@ This way it is possible to reduce error handling code to only handle generic par
503503
* UserRefusedConfirmationMessageWithVerificationChoiceException
504504
* UserRefusedDisplayTextAndPinException
505505
* UserRefusedVerificationChoiceException
506-
* UserSelectedWrongVerificationCodeException - 3 different codeuser was displayed 3 codes in app and selected wrong code
506+
* UserSelectedWrongVerificationCodeException - the end user was displayed 3 codes in app and user selected wrong code
507507
* UserAccountException - Exceptions that are caused by user account configuration.
508508
* CertificateLevelMismatchException
509509
* NoSuitableAccountOfRequestedTypeFoundException
@@ -516,7 +516,7 @@ This way it is possible to reduce error handling code to only handle generic par
516516
* ServerMaintenanceException - Server is currently under maintenance
517517
* SmartIdClientException - this exception is a sign of incorrect integration with Smart-ID service (i.e. missing parameters etc)
518518
* RelyingPartyAccountConfigurationException - indicates that RelyingParty configuration at Smart-ID side can be incorrect
519-
* UnprocessableSmartIdResponseException - shouldn't happen under normal condtitions
519+
* UnprocessableSmartIdResponseException - shouldn't happen under normal conditions
520520
* SessionNotFoundException - When session was not found. Usually this is also caused by problems with implementation.
521521

522522

pom.xml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
<developer>
2828
<name>Juhan Aasaru</name>
2929
<organization>Nortal</organization>
30-
<organizationUrl>http://www.nortal.com</organizationUrl>
30+
<organizationUrl>https://www.nortal.com</organizationUrl>
3131
</developer>
3232
<developer>
3333
<name>Andreas Valdma</name>
3434
<organization>Nortal</organization>
35-
<organizationUrl>http://www.nortal.com</organizationUrl>
35+
<organizationUrl>https://www.nortal.com</organizationUrl>
3636
</developer>
3737
</developers>
3838

@@ -45,19 +45,13 @@
4545
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4646
<maven.compiler.source>1.8</maven.compiler.source>
4747
<maven.compiler.target>1.8</maven.compiler.target>
48-
<jackson.version>2.13.4</jackson.version>
49-
<jackson.annotations.version>2.13.4</jackson.annotations.version>
50-
<jersey.version>3.0.8</jersey.version>
51-
<rs-api.version>3.0.0</rs-api.version>
52-
<resteasy.version>6.0.3.Final</resteasy.version>
48+
<jackson.version>2.14.2</jackson.version>
49+
<jackson.annotations.version>2.14.2</jackson.annotations.version>
50+
<jersey.version>3.0.10</jersey.version><!-- NB! 3.1.x does not work with Java 8 -->
51+
<resteasy.version>6.0.3.Final</resteasy.version><!-- 6.1+ doesn't work with Java 8 -->
5352
</properties>
5453

5554
<dependencies>
56-
<dependency>
57-
<groupId>org.glassfish.jersey.core</groupId>
58-
<artifactId>jersey-client</artifactId>
59-
<version>${jersey.version}</version>
60-
</dependency>
6155
<dependency>
6256
<groupId>org.glassfish.jersey.media</groupId>
6357
<artifactId>jersey-media-json-jackson</artifactId>
@@ -69,12 +63,6 @@
6963
<version>${jersey.version}</version>
7064
</dependency>
7165

72-
<dependency>
73-
<groupId>jakarta.ws.rs</groupId>
74-
<artifactId>jakarta.ws.rs-api</artifactId>
75-
<version>${rs-api.version}</version>
76-
</dependency>
77-
7866
<dependency>
7967
<groupId>org.glassfish.jersey.connectors</groupId>
8068
<artifactId>jersey-apache-connector</artifactId>
@@ -245,10 +233,10 @@
245233
<plugin>
246234
<groupId>org.owasp</groupId>
247235
<artifactId>dependency-check-maven</artifactId>
248-
<version>7.3.0</version>
236+
<version>8.2.1</version>
249237
<configuration>
250238
<skipTestScope>true</skipTestScope>
251-
<skip>true</skip>
239+
<skip>false</skip>
252240
</configuration>
253241
<executions>
254242
<execution>

src/main/java/ee/sk/smartid/AuthenticationResponseValidator.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ public AuthenticationResponseValidator(X509Certificate[] trustedCertificates) {
8585
}
8686

8787
/**
88-
* Validates the authentication response and returns the its result
89-
*
90-
* Performs following validations:
88+
* Validates the authentication response and returns the result.
89+
* Performs the following validations:
9190
* "result.endResult" has the value "OK"
9291
* "signature.value" is the valid signature over the same "hash", which was submitted by the RP.
9392
* "signature.value" is the valid signature, verifiable with the public key inside the certificate of the user, given in the field "cert.value"
@@ -121,7 +120,7 @@ public AuthenticationIdentity validate(SmartIdAuthenticationResponse authenticat
121120
* Gets the list of trusted CA certificates
122121
* <p>
123122
* Authenticating person's certificate has to be issued by
124-
* one of the trusted CA certificates. Otherwise the person's
123+
* one of the trusted CA certificates. Otherwise, the person's
125124
* authentication is deemed untrusted and therefore not valid.
126125
*
127126
* @return list of trusted CA certificates
@@ -134,7 +133,7 @@ public List<X509Certificate> getTrustedCACertificates() {
134133
* Adds a certificate to the list of trusted CA certificates
135134
* <p>
136135
* Authenticating person's certificate has to be issued by
137-
* one of the trusted CA certificates. Otherwise the person's
136+
* one of the trusted CA certificates. Otherwise, the person's
138137
* authentication is deemed untrusted and therefore not valid.
139138
*
140139
* @param certificate trusted CA certificate
@@ -148,7 +147,7 @@ public void addTrustedCACertificate(X509Certificate certificate) {
148147
* adds it into the list of trusted CA certificates
149148
* <p>
150149
* Authenticating person's certificate has to be issued by
151-
* one of the trusted CA certificates. Otherwise the person's
150+
* one of the trusted CA certificates. Otherwise, the person's
152151
* authentication is deemed untrusted and therefore not valid.
153152
*
154153
* @throws CertificateException when there was an error constructing the certificate from bytes
@@ -166,7 +165,7 @@ public void addTrustedCACertificate(byte[] certificateBytes) throws CertificateE
166165
* and adds it into the list of trusted CA certificates
167166
* <p>
168167
* Authenticating person's certificate has to be issued by
169-
* one of the trusted CA certificates. Otherwise the person's
168+
* one of the trusted CA certificates. Otherwise, the person's
170169
* authentication is deemed untrusted and therefore not valid.
171170
*
172171
* @throws IOException when there is an error reading the file

src/test/java/ee/sk/smartid/EndpointSslVerificationIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class EndpointSslVerificationIntegrationTest {
5555
private static final String LIVE_HOST_URL = "https://rp-api.smart-id.com/v1";
5656
private static final String DEMO_RELYING_PARTY_UUID = "00000000-0000-0000-0000-000000000000";
5757
private static final String DEMO_RELYING_PARTY_NAME = "DEMO";
58-
private static final String DEMO_DOCUMENT_NUMBER = "PNOLT-30303039914-PBZK-Q";
58+
private static final String DEMO_DOCUMENT_NUMBER = "PNOLT-30303039914-MOCK-Q";
5959

6060
public static final String LIVE_HOST_SSL_CERTIFICATE = "-----BEGIN CERTIFICATE-----\nMIIGjjCCBXagAwIBAgIQA6feGFsbcuz3yYop3036xzANBgkqhkiG9w0BAQsFADBN\nMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5E\naWdpQ2VydCBTSEEyIFNlY3VyZSBTZXJ2ZXIgQ0EwHhcNMTkxMTAxMDAwMDAwWhcN\nMjExMTA1MTIwMDAwWjBaMQswCQYDVQQGEwJFRTEQMA4GA1UEBxMHVGFsbGlubjEb\nMBkGA1UEChMSU0sgSUQgU29sdXRpb25zIEFTMRwwGgYDVQQDExNycC1hcGkuc21h\ncnQtaWQuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuycMJZaS\nlaHLAYvqSFLoTZUF61EPrU4SiYmNqpvoAR7A/ywfjsZUyil1xBYwKI9+wZ4fW1Lj\njgzAY5p26ueGQSx/qHSU5D4ISL6dYvV1zvg5KRYtf1PxPFCOIhwzvoj8XnuiJoBt\n/wZmekB90giFRaeUmM2hCU9j78AM6hVJxMsvjP9Kpua4Hc4RJJSZwpnjO8nLO1BO\ndRf1M6TFqkYqUYtSJ8Y2NTalgo2gcPw+peN74MomRRB7oIRK6jUsUzwMDaJ0GTan\ngnLY1VIgdJhN9EIrIkisJMQJYcabh6KV/s1JG+wTpoC8usqFE/r4ILmTU+BeXL38\nyJXHoGhmkyvCBQIDAQABo4IDWzCCA1cwHwYDVR0jBBgwFoAUD4BhHIIxYdUvKOeN\nRji0LOHG2eIwHQYDV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Iun0gIgG1ar0X2/vLa7PKlgCWmnzNM1\nfM2ex6zBYjjBHNjN5GAwDQYJKoZIhvcNAQELBQADggEBACko+lWd1cqdlSv2GDU2\nFJC6f3rMLOcUr/H6A6taaThUQ9gJ1W/xtlSAldHkwC/X2J9Zuw3MbKn+jV17SFEg\nlWu4iMlOSd5RPM51Dc7DyALAceau/I5rchKrYH3hhspJydZhz1ghgyZ3mdwkQE6t\nYv5v+G4jeHwUXxJ5dFFnRLNCHeTDqpa2zOglA/ORRM83NDt4cKTl3CqXWeeteFyu\nulnrt7w+IuCVhV6zywolQsqI5T77nQ4GfB6Cco3s01JWTaOg+DcPnobjwqk0o0mi\n/rBcmf49zy9T5O8CW6sABOqRV7RKIRSPEiv3M9IKJd621F/OfgGYwWDepBIk4ex3\ndgE=\n-----END CERTIFICATE-----\n";
6161

src/test/java/ee/sk/smartid/rest/SmartIdRestConnectorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import ee.sk.smartid.rest.dao.*;
3737
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
3838
import org.glassfish.jersey.client.ClientConfig;
39+
import org.hamcrest.MatcherAssert;
3940
import org.junit.Before;
4041
import org.junit.Rule;
4142
import org.junit.Test;
@@ -65,7 +66,6 @@ public void setUp() {
6566
@Test(expected = SessionNotFoundException.class)
6667
public void getNotExistingSessionStatus() {
6768
stubNotFoundResponse("/session/de305d54-75b4-431b-adb2-eb6b9e546016");
68-
SessionStatusRequest request = new SessionStatusRequest("de305d54-75b4-431b-adb2-eb6b9e546016");
6969
connector.getSessionStatus("de305d54-75b4-431b-adb2-eb6b9e546016");
7070
}
7171

@@ -92,7 +92,7 @@ public void getSessionStatus_forSuccessfulCertificateRequest() {
9292
SessionStatus sessionStatus = getStubbedSessionStatusWithResponse("responses/sessionStatusForSuccessfulCertificateRequest.json");
9393
assertSuccessfulResponse(sessionStatus);
9494
assertNotNull(sessionStatus.getCert());
95-
assertThat(sessionStatus.getCert().getValue(), startsWith("MIIHhjCCBW6gAwIBAgIQDNYLtVwrKURYStrYApYViTANBgkqhkiG9"));
95+
MatcherAssert.assertThat(sessionStatus.getCert().getValue(), startsWith("MIIHhjCCBW6gAwIBAgIQDNYLtVwrKURYStrYApYViTANBgkqhkiG9"));
9696
assertEquals("QUALIFIED", sessionStatus.getCert().getCertificateLevel());
9797
}
9898

@@ -101,7 +101,7 @@ public void getSessionStatus_forSuccessfulSigningRequest() {
101101
SessionStatus sessionStatus = getStubbedSessionStatusWithResponse("responses/sessionStatusForSuccessfulSigningRequest.json");
102102
assertSuccessfulResponse(sessionStatus);
103103
assertNotNull(sessionStatus.getSignature());
104-
assertThat(sessionStatus.getSignature().getValue(), startsWith("luvjsi1+1iLN9yfDFEh/BE8hXtAKhAIxilv"));
104+
MatcherAssert.assertThat(sessionStatus.getSignature().getValue(), startsWith("luvjsi1+1iLN9yfDFEh/BE8hXtAKhAIxilv"));
105105
assertEquals("sha256WithRSAEncryption", sessionStatus.getSignature().getAlgorithm());
106106
}
107107

src/test/java/ee/sk/smartid/rest/SmartIdRestIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public class SmartIdRestIntegrationTest {
4848

4949
private static final String RELYING_PARTY_UUID = "00000000-0000-0000-0000-000000000000";
5050
private static final String RELYING_PARTY_NAME = "DEMO";
51-
private static final String DOCUMENT_NUMBER = "PNOLT-30303039903-FMB7-Q";
52-
private static final String DOCUMENT_NUMBER_LT = "PNOLT-30303039914-PBZK-Q";
51+
private static final String DOCUMENT_NUMBER = "PNOLT-30303039903-MOCK-Q";
52+
private static final String DOCUMENT_NUMBER_LT = "PNOLT-30303039914-MOCK-Q";
5353
private static final String DATA_TO_SIGN = "Hello World!";
5454
private static final String CERTIFICATE_LEVEL_QUALIFIED = "QUALIFIED";
5555
private SmartIdConnector connector;

0 commit comments

Comments
 (0)