Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pipeline{
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew -i marklogic-client-api:test || true
./gradlew marklogic-client-api-functionaltests:runFastFunctionalTests || true
'''
junit '**/build/**/TEST*.xml'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public void testBlackListHost() throws Exception {
final AtomicInteger successCount = new AtomicInteger(0);
final AtomicBoolean containsBLHost = new AtomicBoolean(false);
final AtomicBoolean failState = new AtomicBoolean(false);
SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("admin", "admin");
SecurityContext secContext = newSecurityContext("admin", "admin");
DatabaseClient dbClient = DatabaseClientFactory.newClient(hostLists.get(3), 8000, secContext, getConnType());
DataMovementManager dmManager = dbClient.newDataMovementManager();
WriteBatcher ihb2 = dmManager.newWriteBatcher();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public static void initializeClients() throws Exception {
adminModulesClient = getDatabaseClientOnDatabase(getRestServerHostName(), getRestServerPort(), modulesDbName, getAdminUser(), getAdminPassword(), getConnType());
} else {
schemasClient = DatabaseClientFactory.newClient(getRestServerHostName(), getRestServerPort(), schemasDbName,
new DatabaseClientFactory.DigestAuthContext(OPTIC_USER, OPTIC_USER_PASSWORD));
newSecurityContext(OPTIC_USER, OPTIC_USER_PASSWORD));
client = DatabaseClientFactory.newClient(getRestServerHostName(), getRestServerPort(),
new DatabaseClientFactory.DigestAuthContext(OPTIC_USER, OPTIC_USER_PASSWORD));
newSecurityContext(OPTIC_USER, OPTIC_USER_PASSWORD));
adminModulesClient = DatabaseClientFactory.newClient(getRestServerHostName(), getRestServerPort(), modulesDbName,
new DatabaseClientFactory.DigestAuthContext(getAdminUser(), getAdminPassword()));
newSecurityContext(getAdminUser(), getAdminPassword()));
}

// Required to ensure that tests using the "/ext/" prefix work reliably. Expand to other directories as needed.
Expand Down Expand Up @@ -155,12 +155,12 @@ protected final String toWKT(String latLon) {

protected static DatabaseClient connectAsRestWriter() {
return DatabaseClientFactory.newClient(getRestServerHostName(), getRestServerPort(),
new DatabaseClientFactory.DigestAuthContext("rest-writer", "x"), getConnType());
newSecurityContext("rest-writer", "x"), getConnType());
}

protected static DatabaseClient connectAsAdmin() {
return DatabaseClientFactory.newClient(getRestServerHostName(), getRestServerPort(),
new DatabaseClientFactory.DigestAuthContext(getAdminUser(), getAdminPassword()), getConnType());
newSecurityContext(getAdminUser(), getAdminPassword()), getConnType());
}

protected static void removeFieldIndices() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void setUp() throws Exception {
if (isLBHost())
client = getDatabaseClient("eval-user", "x", getConnType());
else {
SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("eval-user", "x");
SecurityContext secContext = newSecurityContext("eval-user", "x");
client = DatabaseClientFactory.newClient(appServerHostname, uberPort, "java-functest", secContext, getConnType());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@
import com.marklogic.client.DatabaseClientFactory.SecurityContext;
import com.marklogic.client.io.InputStreamHandle;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;

import static org.junit.Assert.assertEquals;

Expand All @@ -42,13 +39,14 @@ public class TestDatabaseAuthentication extends AbstractFunctionalTest {
private static String restServerName = "java-functest";

@After
public void testCleanUp() throws Exception {
deleteDocuments(connectAsAdmin());
public void teardown() throws Exception {
setAuthentication(securityContextType, restServerName);
setDefaultUser("nobody", restServerName);
}

// Should throw exceptions when none specified.
@Test
public void testAuthenticationNone() throws KeyManagementException, NoSuchAlgorithmException, IOException
public void testAuthenticationNone() throws IOException
{
System.out.println("Running testAuthenticationNone");
if (!IsSecurityEnabled()) {
Expand All @@ -63,13 +61,11 @@ public void testAuthenticationNone() throws KeyManagementException, NoSuchAlgori
}
assertEquals("Write Text difference", "makeSecurityContext should only be called with BASIC or DIGEST Authentication",
str.toString().trim());
setAuthentication("digest", restServerName);
setDefaultUser("nobody", restServerName);
}
}

@Test
public void testAuthenticationBasic() throws KeyManagementException, NoSuchAlgorithmException, IOException
public void testAuthenticationBasic() throws IOException
{
if (!IsSecurityEnabled()) {
setAuthentication("basic", restServerName);
Expand Down Expand Up @@ -100,15 +96,6 @@ public void testAuthenticationBasic() throws KeyManagementException, NoSuchAlgor

// release client
client.release();

setAuthentication("digest", restServerName);
setDefaultUser("nobody", restServerName);
}
}

@AfterClass
public static void tearDown() throws Exception {
setAuthentication("digest", restServerName);
setDefaultUser("nobody", restServerName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void testXmlCRUD_BytesHandle() throws KeyManagementException, NoSuchAlgor
XMLUnit.setNormalizeWhitespace(true);

// connect the client
DatabaseClientFactory.SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("eval-user", "x");
DatabaseClientFactory.SecurityContext secContext = newSecurityContext("eval-user", "x");
DatabaseClient client = DatabaseClientFactory.newClient(appServerHostname, uberPort, dbName, secContext, getConnType());

// write docs
Expand Down Expand Up @@ -140,7 +140,7 @@ public void testTextCRUD_BytesHandle() throws KeyManagementException, NoSuchAlgo
System.out.println("Runing test TextCRUD_BytesHandle");

// connect the client
DatabaseClientFactory.SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("eval-user", "x");
DatabaseClientFactory.SecurityContext secContext = newSecurityContext("eval-user", "x");
DatabaseClient client = DatabaseClientFactory.newClient(appServerHostname, uberPort, dbName, secContext, getConnType());

// write docs
Expand Down Expand Up @@ -201,7 +201,7 @@ public void testJsonCRUD_BytesHandle() throws KeyManagementException, NoSuchAlgo
ObjectMapper mapper = new ObjectMapper();

// connect the client
DatabaseClientFactory.SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("eval-user", "x");
DatabaseClientFactory.SecurityContext secContext = newSecurityContext("eval-user", "x");
DatabaseClient client = DatabaseClientFactory.newClient(appServerHostname, uberPort, dbName, secContext, getConnType());

// write docs
Expand Down Expand Up @@ -262,7 +262,7 @@ public void testBinaryCRUD_BytesHandle() throws KeyManagementException, NoSuchAl
System.out.println("Running testBinaryCRUD_BytesHandle");

// connect the client
DatabaseClientFactory.SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("eval-user", "x");
DatabaseClientFactory.SecurityContext secContext = newSecurityContext("eval-user", "x");
DatabaseClient client = DatabaseClientFactory.newClient(appServerHostname, uberPort, dbName, secContext, getConnType());

// write docs
Expand Down
Loading