1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.crypto.signer.internal.factory; |
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
import org.junit.Before; |
43 |
|
import org.junit.Rule; |
44 |
|
import org.junit.Test; |
45 |
|
import org.xwiki.crypto.internal.asymmetric.keyfactory.BcRSAKeyFactory; |
46 |
|
import org.xwiki.crypto.internal.encoder.Base64BinaryStringEncoder; |
47 |
|
import org.xwiki.crypto.signer.SignerFactory; |
48 |
|
import org.xwiki.test.annotation.ComponentList; |
49 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
50 |
|
|
51 |
|
@ComponentList({Base64BinaryStringEncoder.class, BcRSAKeyFactory.class}) |
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 8 |
Complexity Density: 1 |
|
52 |
|
public class BcDigestWithRsaSignerFactoryTest extends AbstractRsaSignerFactoryTest |
53 |
|
{ |
54 |
|
@Rule |
55 |
|
public final MockitoComponentMockingRule<SignerFactory> mocker = |
56 |
|
new MockitoComponentMockingRule<SignerFactory>(BcSHA1withRsaSignerFactory.class); |
57 |
|
|
58 |
|
@Rule |
59 |
|
public final MockitoComponentMockingRule<SignerFactory> mockerSha224 = |
60 |
|
new MockitoComponentMockingRule<SignerFactory>(BcSHA224withRsaSignerFactory.class); |
61 |
|
|
62 |
|
@Rule |
63 |
|
public final MockitoComponentMockingRule<SignerFactory> mockerSha256 = |
64 |
|
new MockitoComponentMockingRule<SignerFactory>(BcSHA256withRsaSignerFactory.class); |
65 |
|
|
66 |
|
@Rule |
67 |
|
public final MockitoComponentMockingRule<SignerFactory> mockerSha384 = |
68 |
|
new MockitoComponentMockingRule<SignerFactory>(BcSHA384withRsaSignerFactory.class); |
69 |
|
|
70 |
|
@Rule |
71 |
|
public final MockitoComponentMockingRule<SignerFactory> mockerSha512 = |
72 |
|
new MockitoComponentMockingRule<SignerFactory>(BcSHA512withRsaSignerFactory.class); |
73 |
|
|
74 |
|
@Rule |
75 |
|
public final MockitoComponentMockingRule<SignerFactory> mockerMD5 = |
76 |
|
new MockitoComponentMockingRule<SignerFactory>(BcMD5withRsaSignerFactory.class); |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
6 |
@Before... |
79 |
|
public void configure() throws Exception |
80 |
|
{ |
81 |
6 |
setupTest(mocker); |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
6 |
private void runTest(MockitoComponentMockingRule<SignerFactory> mocker) throws Exception... |
85 |
|
{ |
86 |
6 |
runTestSignatureVerification( |
87 |
|
mocker.getComponentUnderTest().getInstance(true, privateKey), |
88 |
|
mocker.getComponentUnderTest().getInstance(false, publicKey) |
89 |
|
); |
90 |
|
} |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
92 |
1 |
@Test... |
93 |
|
public void testSha1SignatureVerification() throws Exception |
94 |
|
{ |
95 |
1 |
runTest(mocker); |
96 |
|
} |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
98 |
1 |
@Test... |
99 |
|
public void testSha224SignatureVerification() throws Exception |
100 |
|
{ |
101 |
1 |
runTest(mockerSha224); |
102 |
|
} |
103 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
104 |
1 |
@Test... |
105 |
|
public void testSha256SignatureVerification() throws Exception |
106 |
|
{ |
107 |
1 |
runTest(mockerSha256); |
108 |
|
} |
109 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
110 |
1 |
@Test... |
111 |
|
public void testSha384SignatureVerification() throws Exception |
112 |
|
{ |
113 |
1 |
runTest(mockerSha384); |
114 |
|
} |
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
116 |
1 |
@Test... |
117 |
|
public void testSha512SignatureVerification() throws Exception |
118 |
|
{ |
119 |
1 |
runTest(mockerSha512); |
120 |
|
} |
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
122 |
1 |
@Test... |
123 |
|
public void testMd5SignatureVerification() throws Exception |
124 |
|
{ |
125 |
1 |
runTest(mockerMD5); |
126 |
|
} |
127 |
|
} |