Skip to content

Commit 4a734fd

Browse files
committed
start adding integration testing
1 parent 6e37b6e commit 4a734fd

File tree

25 files changed

+468
-44
lines changed

25 files changed

+468
-44
lines changed

lightblue-ldap-common/src/main/java/com/redhat/lightblue/common/ldap/DBResolver.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
4+
This file is part of lightblue.
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
119
package com.redhat.lightblue.common.ldap;
220

321
import com.redhat.lightblue.metadata.DataStore;

lightblue-ldap-common/src/test/java/com/redhat/lightblue/common/ldap/LdapDataStoreTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
4+
This file is part of lightblue.
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
119
package com.redhat.lightblue.common.ldap;
220

321
import static org.junit.Assert.assertEquals;

lightblue-ldap-config/src/main/java/com/redhat/lightblue/config/ldap/LdapDBResolver.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
4+
This file is part of lightblue.
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
119
package com.redhat.lightblue.config.ldap;
220

321
import java.util.Map;

lightblue-ldap-config/src/test/java/com/redhat/lightblue/config/ldap/LdapControllerFactoryTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
4+
This file is part of lightblue.
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
119
package com.redhat.lightblue.config.ldap;
220

321
import static org.junit.Assert.assertNotNull;

lightblue-ldap-config/src/test/java/com/redhat/lightblue/config/ldap/LdapDBResolverTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
Copyright 2014 Red Hat, Inc. and/or its affiliates.
3+
4+
This file is part of lightblue.
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
119
package com.redhat.lightblue.config.ldap;
220

321
import java.util.HashMap;

lightblue-ldap-config/src/test/java/com/redhat/lightblue/config/ldap/LdapDataSourceConfigurationTest.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,29 @@
2222
import static org.junit.Assert.assertNotNull;
2323

2424
import java.io.IOException;
25-
import java.util.LinkedHashMap;
2625

26+
import org.junit.BeforeClass;
2727
import org.junit.Rule;
2828
import org.junit.Test;
2929

3030
import com.fasterxml.jackson.databind.JsonNode;
3131
import com.redhat.lightblue.ldap.test.LdapServerExternalResource;
3232
import com.redhat.lightblue.ldap.test.LdapServerExternalResource.InMemoryLdapServer;
33-
import com.unboundid.ldap.sdk.Attribute;
3433
import com.unboundid.ldap.sdk.LDAPConnection;
3534
import com.unboundid.ldap.sdk.LDAPException;
3635
import com.unboundid.ldif.LDIFException;
3736

3837
@InMemoryLdapServer
3938
public class LdapDataSourceConfigurationTest {
4039

41-
@SuppressWarnings("serial")
4240
@Rule
43-
public LdapServerExternalResource ldapServer = new LdapServerExternalResource(new LinkedHashMap<String, Attribute[]>(){{
44-
put("dc=com", new Attribute[]{
45-
new Attribute("objectClass", "top"),
46-
new Attribute("objectClass", "domain"),
47-
new Attribute("dc", "com")});
48-
put("dc=example,dc=com", new Attribute[]{
49-
new Attribute("objectClass", "top"),
50-
new Attribute("objectClass", "domain"),
51-
new Attribute("dc", "example")});
52-
}});
41+
public LdapServerExternalResource ldapServer = LdapServerExternalResource.createDefaultInstance();
42+
43+
@BeforeClass
44+
public static void beforeClass(){
45+
System.setProperty("ldap.host", "localhost");
46+
System.setProperty("ldap.port", String.valueOf(LdapServerExternalResource.DEFAULT_PORT));
47+
}
5348

5449
@Test
5550
public void testGetMetadataDataStoreParser(){

lightblue-ldap-crud/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<groupId>com.redhat.lightblue.ldap</groupId>
5050
<artifactId>lightblue-ldap-test</artifactId>
5151
<scope>test</scope>
52-
</dependency>
52+
</dependency>
5353
</dependencies>
5454

5555
</project>

lightblue-ldap-crud/src/main/java/com/redhat/lightblue/crud/ldap/LdapCRUDController.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.slf4j.Logger;
2424
import org.slf4j.LoggerFactory;
2525

26+
import com.fasterxml.jackson.databind.node.ObjectNode;
2627
import com.redhat.lightblue.common.ldap.DBResolver;
2728
import com.redhat.lightblue.crud.CRUDController;
2829
import com.redhat.lightblue.crud.CRUDDeleteResponse;
@@ -61,9 +62,10 @@ public LdapCRUDController(DBResolver dbResolver){
6162
public CRUDInsertionResponse insert(CRUDOperationContext ctx,
6263
Projection projection) {
6364
CRUDInsertionResponse response = new CRUDInsertionResponse();
65+
response.setNumInserted(0);
66+
6467
List<DocCtx> documents = ctx.getDocumentsWithoutErrors();
6568
if (documents == null || documents.isEmpty()) {
66-
response.setNumInserted(0);
6769
return response;
6870
}
6971

@@ -90,8 +92,18 @@ public CRUDInsertionResponse insert(CRUDOperationContext ctx,
9092
LDAPResult result = command.execute();
9193
if(result.getResultCode() != ResultCode.SUCCESS){
9294
//TODO: Do something to indicate unsuccessful status
95+
continue;
96+
}
97+
98+
if(projector != null){
99+
JsonDoc jsonDoc = null; //TODO: actually populate field.
100+
document.setOutputDocument(projector.project(jsonDoc, ctx.getFactory().getNodeFactory()));
101+
}
102+
else{
103+
document.setOutputDocument(new JsonDoc(new ObjectNode(ctx.getFactory().getNodeFactory())));
93104
}
94105

106+
response.setNumInserted(response.getNumInserted() + 1);
95107
}
96108
}
97109
catch (LDAPException e) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"objectType": "some_entity",
3+
"client": {"id": "1"},
4+
"execution": {
5+
"timeLimit": 5000,
6+
"asynchronous": 4500
7+
},
8+
"projection": {
9+
"field": "firstname",
10+
"include": true,
11+
"recursive": true
12+
},
13+
"data": [
14+
{
15+
"objectType": "some_entity",
16+
"login": "nmalik1"
17+
},
18+
{
19+
"objectType": "some_entity",
20+
"login": "nmalik2"
21+
}
22+
]
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"objectType": "some_entity",
3+
"client": {"id": "1"},
4+
"execution": {
5+
"timeLimit": 5000,
6+
"asynchronous": 4500
7+
},
8+
"projection": {
9+
"field": "uid",
10+
"include": true,
11+
"recursive": true
12+
},
13+
"data": {
14+
"objectType": "some_entity",
15+
"dn": "uid=john.doe,dc=example,dc=com",
16+
"objectClass": ["top", "person", "organizationalPerson", "inetOrgPerson"],
17+
"uid": "john.doe",
18+
"givenName": "John",
19+
"sn": "Doe",
20+
"cn": "John Doe"
21+
}
22+
}

0 commit comments

Comments
 (0)