Skip to content

Commit

Permalink
[ELY-2625] Add a test to X500AttributePrincipalDecoderTest that makes…
Browse files Browse the repository at this point in the history
… use of the PrincipalDecoder#aggregate method
  • Loading branch information
gerjantd committed Oct 6, 2023
1 parent 0cd6610 commit 136f74e
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,19 @@ public void testDecodeAttributeWithSubrange() {

@Test
public void testDecodeWithAggregation() {
X500Principal principal;
PrincipalDecoder dcDecoder, dcDecoder1, cnDecoder, ouDecoder, aggregateDecoder;
principal = new X500Principal("cn=bob.smith,cn=bob,ou=people,dc=example,dc=redhat,dc=com");
dcDecoder = new X500AttributePrincipalDecoder(X500.OID_DC);
cnDecoder = new X500AttributePrincipalDecoder(X500.OID_AT_COMMON_NAME, 1);
aggregateDecoder = PrincipalDecoder.aggregate(cnDecoder, dcDecoder);
X500Principal principal = new X500Principal("cn=bob.smith,cn=bob,ou=people,dc=example,dc=redhat,dc=com");
PrincipalDecoder dcDecoder = new X500AttributePrincipalDecoder(X500.OID_DC);
PrincipalDecoder cnDecoder = new X500AttributePrincipalDecoder(X500.OID_AT_COMMON_NAME, 1);
PrincipalDecoder aggregateDecoder = PrincipalDecoder.aggregate(cnDecoder, dcDecoder);
assertEquals("bob.smith", aggregateDecoder.getName(principal));
aggregateDecoder = PrincipalDecoder.aggregate(dcDecoder, cnDecoder);
assertEquals("example.redhat.com", aggregateDecoder.getName(principal));

principal = new X500Principal("cn=bob.smith,ou=people,dc=example,dc=redhat");
cnDecoder = new X500AttributePrincipalDecoder(X500.OID_AT_COMMON_NAME);
ouDecoder = new X500AttributePrincipalDecoder(X500.OID_AT_ORGANIZATIONAL_UNIT_NAME, 1);
PrincipalDecoder ouDecoder = new X500AttributePrincipalDecoder(X500.OID_AT_ORGANIZATIONAL_UNIT_NAME, 1);
dcDecoder = new X500AttributePrincipalDecoder(X500.OID_DC, 1);
dcDecoder1 = new X500AttributePrincipalDecoder(X500.OID_DC, 1, 1);
PrincipalDecoder dcDecoder1 = new X500AttributePrincipalDecoder(X500.OID_DC, 1, 1);
aggregateDecoder = PrincipalDecoder.aggregate(dcDecoder1, dcDecoder, ouDecoder, cnDecoder);
assertEquals("redhat", aggregateDecoder.getName(principal));
aggregateDecoder = PrincipalDecoder.aggregate(dcDecoder, dcDecoder1, ouDecoder, cnDecoder);
Expand Down

0 comments on commit 136f74e

Please sign in to comment.