| | |
| | | */ |
| | | @Test |
| | | public void testReadEntryBase64Encoded() throws Exception { |
| | | try (LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList( |
| | | // @formatter:off |
| | | final LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList( |
| | | "version: 1", |
| | | "dn: cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", |
| | | "objectclass: top", |
| | |
| | | + "IGlzIGJhc2UtNjQtZW5jb2RlZCBiZWNhdXNlIGl0IGhhcyBhIGNvbnRyb2wgY2hhcmFjdG" |
| | | + "VyIGluIGl0IChhIENSKS4NICBCeSB0aGUgd2F5LCB5b3Ugc2hvdWxkIHJlYWxseSBnZXQg" |
| | | + "b3V0IG1vcmUu") |
| | | ); |
| | | // @formatter:on |
| | | |
| | | try { |
| | | )) { |
| | | assertThat(reader.hasNext()); |
| | | final Entry entry = reader.readEntry(); |
| | | assertThat(entry).isNotNull(); |
| | |
| | | + "b3V0IG1vcmUu"); |
| | | assertThat(entry.getAttribute("description").firstValueAsString()).contains( |
| | | "What a careful reader you are!"); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Test |
| | | public void testReadEntryBase64EncodedDN() throws Exception { |
| | | try (LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList( |
| | | // @formatter:off |
| | | final LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList( |
| | | "dn:: dWlkPXJvZ2FzYXdhcmEsb3U95Za25qWt6YOoLG89QWlyaXVz", // adding space before ok, after : ko |
| | | "# dn:: uid=<uid>,ou=<JapaneseOU>,o=Airius", |
| | | "objectclass: top", |
| | |
| | | "cn: Gern O Jensen", |
| | | "sn: Jensen", |
| | | "uid: gernj" |
| | | )); |
| | | // @formatter:on |
| | | try { |
| | | ))) { |
| | | assertThat(reader.hasNext()); |
| | | final Entry entry = reader.readEntry(); |
| | | assertThat(reader.hasNext()).isFalse(); |
| | | assertThat(entry.getName().toString()).isEqualTo("uid=rogasawara,ou=営業部,o=Airius"); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Test(expectedExceptions = DecodeException.class) |
| | | public void testReadEntryBase64EncodedDNMalformedThrowsError() throws Exception { |
| | | |
| | | try (LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList( |
| | | // @formatter:off |
| | | final LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList( |
| | | "dn:: dWlkPXJvZ2FzYXdh!!!OOOpppps!!!25qWt6YOoLG89QWlyaXVz", |
| | | "# dn:: uid=<uid>,ou=<JapaneseOU>,o=Airius", |
| | | "objectclass: top", |
| | |
| | | "cn: Gern O Jensen", |
| | | "sn: Jensen", |
| | | "uid: gernj" |
| | | )); |
| | | // @formatter:on |
| | | |
| | | try { |
| | | ))) { |
| | | reader.readEntry(); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Test |
| | | public void testLDIFEntryReaderEntryAsArray() throws Exception { |
| | | final LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList(getStandardEntry())); |
| | | |
| | | try { |
| | | try (LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList(getStandardEntry()))) { |
| | | assertThat(reader.hasNext()); |
| | | assertThat(reader.readEntry().getAttributeCount()).isEqualTo(nbStandardEntryAttributes); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |