Skip to content

Commit

Permalink
HPCC4J-614 Code review 1
Browse files Browse the repository at this point in the history
- Adds ability to test encod-able username

Signed-off-by: Rodrigo Pastrana <rodrigo.pastrana@lexisnexisrisk.com>
  • Loading branch information
rpastrana committed Jul 10, 2024
1 parent 60cff93 commit 474a241
Showing 1 changed file with 46 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ HPCC SYSTEMS software Copyright (C) 2019 HPCC Systems®.

import static org.junit.Assert.assertNotNull;

import java.net.MalformedURLException;
import java.nio.charset.Charset;
import java.util.Properties;
import java.util.Random;
Expand All @@ -29,8 +30,10 @@ HPCC SYSTEMS software Copyright (C) 2019 HPCC Systems®.
import org.apache.axis2.AxisFault;
import org.hpccsystems.commons.utils.CryptoHelper;
import org.hpccsystems.commons.utils.DigestAlgorithmType;
import org.hpccsystems.ws.client.utils.Connection;
import org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
Expand All @@ -42,8 +45,11 @@ public class WSStoreClientTest extends BaseRemoteTest
public final static String defaultStoreName = "WsClientTestStore";
public final static String defaultNS = "Junittests";

public final static String defaultEncodedUserName = "Juni@tUser";
public final static String defaultEncodedStoreName = "WsCli@ntT_estStore";
public final static String defaultEncodedNS = "Junit_t@ests";
private static Connection encodedUserConn = null;
private static HPCCWsStoreClient encodedUserClient;

private final static String storename = System.getProperty("storename", defaultStoreName);
private final static String namespace = System.getProperty("storenamespace", defaultNS);
Expand All @@ -58,6 +64,29 @@ public class WSStoreClientTest extends BaseRemoteTest

client = HPCCWsStoreClient.get(connection);
Assert.assertNotNull(client);

try
{
encodedUserConn = new Connection(connString);
}
catch (MalformedURLException e)
{
System.out.println("Could not acquire connection object based on: '" + connString + "' - " + e.getLocalizedMessage());
}

if (encodedUserConn != null)
{
encodedUserConn.setCredentials(defaultEncodedUserName, hpccPass);

if (connTO != null)
encodedUserConn.setConnectTimeoutMilli(connTO);

if (sockTO != null)
encodedUserConn.setSocketTimeoutMilli(Integer.valueOf(sockTO));

encodedUserClient = HPCCWsStoreClient.get(encodedUserConn);
}
Assert.assertNotNull(encodedUserClient);
}

public void printMetaData(int tabs, Properties props)
Expand Down Expand Up @@ -361,10 +390,11 @@ public void z91deleteNSTest() throws Exception, ArrayOfEspExceptionWrapper
@Test
public void b1createEncodedStoreTest() throws Exception, ArrayOfEspExceptionWrapper
{
Assume.assumeNotNull(encodedUserClient);
try
{
System.out.println("Creating Store: '" + defaultEncodedStoreName + "' ...");
boolean success = client.createStore(defaultEncodedStoreName, "Store strictly for WsClient tests", "TEST");
boolean success = encodedUserClient.createStore(defaultEncodedStoreName, "Store strictly for WsClient tests", "TEST");
if (!success)
System.out.println("No exceptions, but failure reported. Does this store already exist? Store: '" + defaultEncodedStoreName + "'");
}
Expand All @@ -377,10 +407,11 @@ public void b1createEncodedStoreTest() throws Exception, ArrayOfEspExceptionWrap
@Test
public void zz91deleteEncodedNSTest() throws Exception, ArrayOfEspExceptionWrapper
{
Assume.assumeNotNull(encodedUserClient);
try
{
System.out.println("Deleting ns: '" + defaultEncodedNS + "' ...");
Assert.assertTrue(client.deleteNamespace(defaultEncodedStoreName, defaultEncodedNS, true, ""));
Assert.assertTrue(encodedUserClient.deleteNamespace(defaultEncodedStoreName, defaultEncodedNS, true, ""));
}
catch (Exception e)
{
Expand All @@ -391,10 +422,11 @@ public void zz91deleteEncodedNSTest() throws Exception, ArrayOfEspExceptionWrapp
@Test
public void b4fetchAllEncodedNSKeysTest()
{
Assume.assumeNotNull(encodedUserClient);
try
{
System.out.println("Fetching all " + defaultEncodedStoreName + "." + defaultEncodedNS + "keys...");
Properties fetchAllNSKeys = client.fetchAllNSKeys(defaultEncodedStoreName, defaultEncodedNS, true);
Properties fetchAllNSKeys = encodedUserClient.fetchAllNSKeys(defaultEncodedStoreName, defaultEncodedNS, true);
Assert.assertNotNull(fetchAllNSKeys);
System.out.println("All Keys: " + fetchAllNSKeys.toString());
}
Expand All @@ -411,10 +443,11 @@ public void b4fetchAllEncodedNSKeysTest()
@Test
public void b4fetchEncodedNSKeysAttributesTest()
{
Assume.assumeNotNull(encodedUserClient);
try
{
System.out.println("Fetching key attribute: " + defaultEncodedStoreName + "." + defaultEncodedNS + "global.test");
Properties fetchKeyMetadata = client.fetchKeyMetaData(defaultEncodedStoreName, defaultEncodedNS, "global.test", true);
Properties fetchKeyMetadata = encodedUserClient.fetchKeyMetaData(defaultEncodedStoreName, defaultEncodedNS, "global.test", true);
Assert.assertNotNull(fetchKeyMetadata);
System.out.println("Key Metadata: " + fetchKeyMetadata.toString());
}
Expand All @@ -429,21 +462,22 @@ public void b4fetchEncodedNSKeysAttributesTest()
}

@Test
public void b3setTest() throws Exception, ArrayOfEspExceptionWrapper
public void b3setEncodedTest() throws Exception, ArrayOfEspExceptionWrapper
{
Assume.assumeNotNull(encodedUserClient);
try
{
System.out.println("Setting " + defaultEncodedStoreName + "." + defaultEncodedNS + "." + "WsClient.global.test=\"success\"...");
Assert.assertTrue(client.setValue(defaultEncodedStoreName, defaultEncodedNS, "global.test", "success", true));
Assert.assertTrue(client.setValue(defaultEncodedStoreName, defaultEncodedNS, "a", "ddfa", true));
Assert.assertTrue(encodedUserClient.setValue(defaultEncodedStoreName, defaultEncodedNS, "global.test", "success", true));
Assert.assertTrue(encodedUserClient.setValue(defaultEncodedStoreName, defaultEncodedNS, "a", "ddfa", true));

Assert.assertTrue(client.setValue(defaultEncodedStoreName, defaultEncodedNS, "global.test", "success", true));
Assert.assertTrue(encodedUserClient.setValue(defaultEncodedStoreName, defaultEncodedNS, "global.test", "success", true));
System.out.println("Setting " + defaultEncodedStoreName + "." + defaultEncodedNS + "." + "WsClient.user.test=\"success\"...");
Assert.assertTrue(client.setValue(defaultEncodedStoreName, defaultEncodedNS, "user.test", "success", false));
Assert.assertTrue(encodedUserClient.setValue(defaultEncodedStoreName, defaultEncodedNS, "user.test", "success", false));

Assert.assertTrue(client.setValue(defaultEncodedStoreName, defaultEncodedNS, "files.rowperpage.default", "50", true));
Assert.assertTrue(client.setValue(defaultEncodedStoreName, defaultEncodedNS, "dp-thor_160-jim::tutorialperson-wuid", "W20190710-114239", false));
Assert.assertTrue(client.setValue(defaultEncodedStoreName, defaultEncodedNS, "ecl.playground.sample.default", "Java Simple", true));
Assert.assertTrue(encodedUserClient.setValue(defaultEncodedStoreName, defaultEncodedNS, "files.rowperpage.default", "50", true));
Assert.assertTrue(encodedUserClient.setValue(defaultEncodedStoreName, defaultEncodedNS, "dp-thor_160-jim::tutorialperson-wuid", "W20190710-114239", false));
Assert.assertTrue(encodedUserClient.setValue(defaultEncodedStoreName, defaultEncodedNS, "ecl.playground.sample.default", "Java Simple", true));
}
catch (Exception e)
{
Expand Down

0 comments on commit 474a241

Please sign in to comment.