11/*
2- * Copyright (c) 2020 The Web eID Project
2+ * Copyright (c) 2020, 2021 The Web eID Project
33 *
44 * Permission is hereby granted, free of charge, to any person obtaining a copy
55 * of this software and associated documentation files (the "Software"), to deal
2222
2323package org .webeid .security .validator ;
2424
25+ import org .junit .jupiter .api .AfterEach ;
2526import org .junit .jupiter .api .BeforeEach ;
2627import org .junit .jupiter .api .Test ;
27- import org .webeid .security .exceptions .*;
28+ import org .webeid .security .exceptions .TokenParseException ;
29+ import org .webeid .security .exceptions .TokenSignatureValidationException ;
30+ import org .webeid .security .exceptions .UserCertificateDisallowedPolicyException ;
31+ import org .webeid .security .exceptions .UserCertificateMissingPurposeException ;
32+ import org .webeid .security .exceptions .UserCertificateWrongPurposeException ;
2833import org .webeid .security .testutil .AbstractTestWithValidatorAndCorrectNonce ;
2934import org .webeid .security .testutil .Dates ;
3035import org .webeid .security .testutil .Tokens ;
3136
3237import java .text .ParseException ;
3338
3439import static org .assertj .core .api .Assertions .assertThatThrownBy ;
35- import static org .webeid .security .testutil .Dates .setMockedDefaultJwtParserDate ;
40+ import static org .webeid .security .testutil .Dates .resetMockedFunctionalSubjectCertificateValidatorsDate ;
41+ import static org .webeid .security .testutil .Dates .setMockedFunctionalSubjectCertificateValidatorsDate ;
3642
3743class X5cTest extends AbstractTestWithValidatorAndCorrectNonce {
3844
@@ -41,13 +47,24 @@ class X5cTest extends AbstractTestWithValidatorAndCorrectNonce {
4147 protected void setup () {
4248 super .setup ();
4349 try {
44- // Ensure that certificate is valid
45- setMockedDefaultJwtParserDate (Dates .create ("2020-09-25 " ));
50+ // Ensure that the certificates do not expire.
51+ setMockedFunctionalSubjectCertificateValidatorsDate (Dates .create ("2021-01-01 " ));
4652 } catch (ParseException | NoSuchFieldException | IllegalAccessException e ) {
4753 throw new RuntimeException (e );
4854 }
4955 }
5056
57+ @ Override
58+ @ AfterEach
59+ public void tearDown () {
60+ super .tearDown ();
61+ try {
62+ resetMockedFunctionalSubjectCertificateValidatorsDate ();
63+ } catch (NoSuchFieldException | IllegalAccessException e ) {
64+ throw new RuntimeException (e );
65+ }
66+ }
67+
5168 @ Test
5269 void testX5cMissing () {
5370 assertThatThrownBy (() -> validator .validate (Tokens .X5C_MISSING ))
0 commit comments