1
1
/*
2
- * Copyright (c) 2020 The Web eID Project
2
+ * Copyright (c) 2020, 2021 The Web eID Project
3
3
*
4
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
* of this software and associated documentation files (the "Software"), to deal
22
22
23
23
package org .webeid .security .validator ;
24
24
25
+ import org .junit .jupiter .api .AfterEach ;
25
26
import org .junit .jupiter .api .BeforeEach ;
26
27
import 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 ;
28
33
import org .webeid .security .testutil .AbstractTestWithValidatorAndCorrectNonce ;
29
34
import org .webeid .security .testutil .Dates ;
30
35
import org .webeid .security .testutil .Tokens ;
31
36
32
37
import java .text .ParseException ;
33
38
34
39
import 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 ;
36
42
37
43
class X5cTest extends AbstractTestWithValidatorAndCorrectNonce {
38
44
@@ -41,13 +47,24 @@ class X5cTest extends AbstractTestWithValidatorAndCorrectNonce {
41
47
protected void setup () {
42
48
super .setup ();
43
49
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 " ));
46
52
} catch (ParseException | NoSuchFieldException | IllegalAccessException e ) {
47
53
throw new RuntimeException (e );
48
54
}
49
55
}
50
56
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
+
51
68
@ Test
52
69
void testX5cMissing () {
53
70
assertThatThrownBy (() -> validator .validate (Tokens .X5C_MISSING ))
0 commit comments