Skip to content

Commit 5beb0c5

Browse files
committed
add unit test for unsupported objectarrays
1 parent ce8b284 commit 5beb0c5

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lightblue-ldap-crud/src/test/java/com/redhat/lightblue/crud/ldap/EntryBuilderTest.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public void testFieldIsObjectType() throws Exception{
8989
* it requires two fields.
9090
*/
9191
@Test
92-
public void testFieldIsArrayField() throws Exception{
93-
String arrayFieldName = "someArray";
92+
public void testFieldIsSimpleArrayField() throws Exception{
93+
String arrayFieldName = "someSimpleArray";
9494
String arrayCountFieldName = LightblueUtil.createArrayCountFieldName(arrayFieldName);
9595
Entry entry = buildEntry(
9696
arrayCountFieldName,
@@ -110,6 +110,24 @@ public void testFieldIsArrayFieldWithoutMatchArray() throws Exception{
110110
assertNotNull(entry.getAttribute(arrayCountFieldName));
111111
}
112112

113+
/**
114+
* This test is kind of hacky as it requires json injection in order to make it work because
115+
* it requires two fields.
116+
* ObjectFields are not currently supported in LDAP, an exception should be thrown indicating as such.
117+
*/
118+
@Test(expected = UnsupportedOperationException.class)
119+
public void testObjectArrayField_ThrowsException() throws Exception{
120+
String arrayFieldName = "someObjectArray";
121+
String arrayCountFieldName = LightblueUtil.createArrayCountFieldName(arrayFieldName);
122+
Entry entry = buildEntry(
123+
arrayCountFieldName,
124+
"{\"type\": \"integer\"}, " + quote(arrayFieldName) + ": {\"type\": \"array\", \"items\": {\"type\": \"object\",\"fields\": {\"someField\": {\"type\": \"string\"}}}}",
125+
"1," + quote(arrayFieldName) + ":[{\"someField\":\"hello\"}]");
126+
127+
assertNotNull(entry);
128+
assertNull(entry.getAttribute(arrayFieldName));
129+
}
130+
113131
@Test(expected = IllegalArgumentException.class)
114132
public void testFieldIsDN() throws Exception{
115133
buildEntry(LdapConstant.ATTRIBUTE_DN, "{\"type\": \"string\"}", quote("uid=someuid,dc=example,dc=com"));

0 commit comments

Comments
 (0)