1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package org.xwiki.crypto.pkix.params.x509certificate; |
22 |
|
|
23 |
|
import java.io.IOException; |
24 |
|
|
25 |
|
import org.bouncycastle.asn1.x500.X500Name; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.crypto.pkix.params.PrincipalIndentifier; |
28 |
|
|
29 |
|
import static org.hamcrest.CoreMatchers.equalTo; |
30 |
|
import static org.hamcrest.CoreMatchers.not; |
31 |
|
import static org.junit.Assert.assertThat; |
32 |
|
|
|
|
| 81% |
Uncovered Elements: 4 (21) |
Complexity: 5 |
Complexity Density: 0.31 |
|
33 |
|
public class DistinguishedNameTest |
34 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
35 |
1 |
@Test... |
36 |
|
public void testEquality() throws Exception |
37 |
|
{ |
38 |
1 |
PrincipalIndentifier john = new DistinguishedName("CN=John Doe"); |
39 |
1 |
PrincipalIndentifier jane = new DistinguishedName("CN=Jane Doe"); |
40 |
1 |
PrincipalIndentifier johnAlias = new DistinguishedName(new X500Name("CN=John Doe")); |
41 |
1 |
PrincipalIndentifier johnOtherImpl = new PrincipalIndentifier() |
42 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
43 |
0 |
@Override... |
44 |
|
public byte[] getEncoded() throws IOException |
45 |
|
{ |
46 |
0 |
return new X500Name("CN=John Doe").getEncoded(); |
47 |
|
} |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
1 |
@Override... |
50 |
|
public String getName() |
51 |
|
{ |
52 |
1 |
return "CN=John Doe"; |
53 |
|
} |
54 |
|
}; |
55 |
1 |
PrincipalIndentifier janeOtherImpl = new PrincipalIndentifier() |
56 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
0 |
@Override... |
58 |
|
public byte[] getEncoded() throws IOException |
59 |
|
{ |
60 |
0 |
return new X500Name("CN=Jane Doe").getEncoded(); |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
1 |
@Override... |
64 |
|
public String getName() |
65 |
|
{ |
66 |
1 |
return "CN=Jane Doe"; |
67 |
|
} |
68 |
|
}; |
69 |
|
|
70 |
1 |
assertThat(john, equalTo(john)); |
71 |
1 |
assertThat(john, equalTo(johnAlias)); |
72 |
1 |
assertThat(john, equalTo(johnOtherImpl)); |
73 |
1 |
assertThat(john, not(equalTo(jane))); |
74 |
1 |
assertThat(jane, not(equalTo(john))); |
75 |
1 |
assertThat(john, not(equalTo(janeOtherImpl))); |
76 |
1 |
assertThat(john, not(equalTo(new Object()))); |
77 |
|
} |
78 |
|
} |