Skip to content

Commit

Permalink
Fix test with legacy DGWS 1.0 IdCard by setting the same timezone tha…
Browse files Browse the repository at this point in the history
…t STS uses
  • Loading branch information
jsotrifork committed Oct 24, 2024
1 parent 1fb1fe9 commit 4692b71
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/test/java/com/trifork/unsealed/IDCardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.time.ZonedDateTime;
import java.util.TimeZone;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
Expand Down Expand Up @@ -164,20 +165,30 @@ void canSignIdCardUsingLegacySTSService() throws Exception {
@Test
void canSignDGWS_1_0_IdCard() throws Exception {

IdCard idCard = new IdCardBuilder()
.uselegacyDGWS_1_0(true)
.env(NSPTestEnv.TEST1_CNSP)
.certAndKey(moces3CertAndKey)
.cpr("0501792275")
.role("role")
.occupation("occupation")
.authorizationCode("J0184")
.systemName("systemname")
.buildUserIdCard();

idCard.sign();

idCard.validate();
TimeZone defaultTimeZone = TimeZone.getDefault();
try {
// Legacy IDWS 1.0 IdCard use date/time with no timezone, and SOSI STS is placed in Denmark. But when building with
// GitHup Actions, we are in another timezone. Set timezone to Europe/Copenhagen to align with STS just for this test.
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Copenhagen"));

IdCard idCard = new IdCardBuilder()
.uselegacyDGWS_1_0(true)
.env(NSPTestEnv.TEST1_CNSP)
.certAndKey(moces3CertAndKey)
.cpr("0501792275")
.role("role")
.occupation("occupation")
.authorizationCode("J0184")
.systemName("systemname")
.buildUserIdCard();

idCard.sign();

idCard.validate();
} finally {
// Switch back to jvm default timezone..
TimeZone.setDefault(defaultTimeZone);
}
}

@Disabled
Expand Down

0 comments on commit 4692b71

Please sign in to comment.