Search in sources :

Example 86 with GuidEntry

use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.

the class ServerIntegrationTest method test_020_RemoveCreated.

/**
   * Removes a guid.
   *
   * @throws IOException
   * @throws ClientException
   * @throws NoSuchAlgorithmException
   */
@Test
public void test_020_RemoveCreated() throws NoSuchAlgorithmException, ClientException, IOException {
    // CHECKED FOR VALIDITY
    String testGuidName = "testGUID" + RandomString.randomString(12);
    GuidEntry testGuid;
    testGuid = clientCommands.guidCreate(masterGuid, testGuidName);
    clientCommands.guidRemove(masterGuid, testGuid.getGuid());
    try {
        clientCommands.lookupGuidRecord(testGuid.getGuid());
        failWithStackTrace("Lookup testGuid should have throw an exception.");
    } catch (ClientException e) {
    // expected
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Test(org.junit.Test)

Example 87 with GuidEntry

use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.

the class ServerIntegrationTest method test_124_ACLTests_OtherUser.

/**
   * Runs a set of ACL tests checking if others can read or not ACLS set by another.
   *
   * @throws Exception
   * @throws JSONException
   */
@Test
public void test_124_ACLTests_OtherUser() throws JSONException, Exception {
    GuidEntry westyEntry = GuidUtils.lookupOrCreateGuid(clientCommands, masterGuid, "westy124" + RandomString.randomString(6));
    GuidEntry samEntry = GuidUtils.lookupOrCreateGuid(clientCommands, masterGuid, "sam124" + RandomString.randomString(6));
    test_131_ACLRemoveAllFields(westyEntry, samEntry);
    test_132_ACLCreateFields(westyEntry);
    test_135_ACLMaybeAddAllFieldsForMaster(westyEntry);
    test_136_ACLMasterReadAllFields(westyEntry);
    test_137_ACLReadMyFields(westyEntry);
    test_138_ACLNotReadOtherGuidAllFieldsTest(westyEntry, samEntry);
    test_139_ACLNotReadOtherGuidFieldTest(westyEntry, samEntry);
    test_140_AddACLTest(westyEntry, samEntry);
    test_141_CheckACLTest(westyEntry, samEntry);
    test_150_ACLCreateDeeperField(westyEntry);
    test_151_ACLAddDeeperFieldACL(westyEntry);
    test_152_ACLCheckDeeperFieldACLExists(westyEntry);
    test_153_ACLReadDeeperFieldSelf(westyEntry);
    test_154_ACLReadDeeperFieldOtherFail(westyEntry, samEntry);
    test_156_ACLReadShallowFieldOtherFail(westyEntry, samEntry);
    test_157_AddAllRecordACL(westyEntry);
    test_158_ACLReadDeeperFieldOtherFail(westyEntry, samEntry);
}
Also used : BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Test(org.junit.Test)

Example 88 with GuidEntry

use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.

the class ServerIntegrationTest method test_041_FieldTests.

/**
   * Runs the Field tests as one independent unit.
   *
   * @throws Exception
   */
@Test
public void test_041_FieldTests() throws Exception {
    GuidEntry subGuidEntry = test_050_CreateSubGuid();
    test_060_FieldNotFoundException(subGuidEntry);
    test_070_FieldExistsFalse(subGuidEntry);
    test_080_CreateFieldForFieldExists(subGuidEntry);
    test_090_FieldExistsTrue(subGuidEntry);
}
Also used : BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Test(org.junit.Test)

Example 89 with GuidEntry

use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.

the class ServerIntegrationTest method test_410_JSONUpdate.

/**
   * Tests update using JSON.
   *
   * @return GuidEntry created
   * @throws Exception
   */
public GuidEntry test_410_JSONUpdate() throws Exception {
    //CHECKED FOR VALIDITY
    GuidEntry westyEntry = clientCommands.guidCreate(masterGuid, "westy410" + RandomString.randomString(12));
    //System.out.print("Created: " + westyEntry);
    try {
        JSONObject json = new JSONObject();
        json.put("name", "frank");
        json.put("occupation", "busboy");
        json.put("location", "work");
        json.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
        JSONObject subJson = new JSONObject();
        subJson.put("einy", "floop");
        subJson.put("meiny", "bloop");
        json.put("gibberish", subJson);
        clientCommands.update(westyEntry, json);
    } catch (JSONException | IOException | ClientException e) {
        failWithStackTrace("Exception while updating JSON: ", e);
    }
    try {
        JSONObject expected = new JSONObject();
        expected.put("name", "frank");
        expected.put("occupation", "busboy");
        expected.put("location", "work");
        expected.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
        JSONObject subJson = new JSONObject();
        subJson.put("einy", "floop");
        subJson.put("meiny", "bloop");
        expected.put("gibberish", subJson);
        JSONObject actual = clientCommands.read(westyEntry);
        JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
    //System.out.println(actual);
    } catch (Exception e) {
        failWithStackTrace("Exception while reading JSON: ", e);
    }
    try {
        JSONObject json = new JSONObject();
        json.put("occupation", "rocket scientist");
        clientCommands.update(westyEntry, json);
    } catch (JSONException | IOException | ClientException e) {
        failWithStackTrace("Exception while changing \"occupation\" to \"rocket scientist\": ", e);
    }
    try {
        JSONObject expected = new JSONObject();
        expected.put("name", "frank");
        expected.put("occupation", "rocket scientist");
        expected.put("location", "work");
        expected.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
        JSONObject subJson = new JSONObject();
        subJson.put("einy", "floop");
        subJson.put("meiny", "bloop");
        expected.put("gibberish", subJson);
        JSONObject actual = clientCommands.read(westyEntry);
        JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
    //System.out.println(actual);
    } catch (Exception e) {
        failWithStackTrace("Exception while reading change of \"occupation\" to \"rocket scientist\": ", e);
    }
    try {
        JSONObject json = new JSONObject();
        json.put("ip address", "127.0.0.1");
        clientCommands.update(westyEntry, json);
    } catch (JSONException | IOException | ClientException e) {
        failWithStackTrace("Exception while adding field \"ip address\" with value \"127.0.0.1\": ", e);
    }
    try {
        JSONObject expected = new JSONObject();
        expected.put("name", "frank");
        expected.put("occupation", "rocket scientist");
        expected.put("location", "work");
        expected.put("ip address", "127.0.0.1");
        expected.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
        JSONObject subJson = new JSONObject();
        subJson.put("einy", "floop");
        subJson.put("meiny", "bloop");
        expected.put("gibberish", subJson);
        JSONObject actual = clientCommands.read(westyEntry);
        JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
    //System.out.println(actual);
    } catch (Exception e) {
        failWithStackTrace("Exception while reading JSON: ", e);
    }
    try {
        clientCommands.fieldRemove(westyEntry.getGuid(), "gibberish", westyEntry);
    } catch (IOException | ClientException e) {
        failWithStackTrace("Exception during remove field \"gibberish\": ", e);
    }
    try {
        JSONObject expected = new JSONObject();
        expected.put("name", "frank");
        expected.put("occupation", "rocket scientist");
        expected.put("location", "work");
        expected.put("ip address", "127.0.0.1");
        expected.put("friends", new ArrayList<>(Arrays.asList("Joe", "Sam", "Billy")));
        JSONObject actual = clientCommands.read(westyEntry);
        JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
    //System.out.println(actual);
    } catch (Exception e) {
        failWithStackTrace("Exception while reading JSON: ", e);
    }
    return westyEntry;
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) IOException(java.io.IOException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) EncryptionException(edu.umass.cs.gnscommon.exceptions.client.EncryptionException) FieldNotFoundException(edu.umass.cs.gnscommon.exceptions.client.FieldNotFoundException) JSONException(org.json.JSONException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) FileNotFoundException(java.io.FileNotFoundException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException)

Example 90 with GuidEntry

use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.

the class BatchCreateTest method test_500_Batch_Tests.

/**
   * The test set for testing batch creates. The test will create batches
   * of size 2, 4, 8,..., 128.
   *
   * @throws Exception
   */
@Test
// Fixme: put this back at 7 once removal is faster.
@Repeat(times = 5)
public void test_500_Batch_Tests() throws Exception {
    GuidEntry accountGuidForBatch = test_510_CreateBatchAccountGuid();
    test_511_CreateBatch(accountGuidForBatch);
    test_512_CheckBatch(accountGuidForBatch);
    numberToCreate *= 2;
    client.execute(GNSCommand.accountGuidRemove(accountGuidForBatch));
}
Also used : GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Repeat(edu.umass.cs.utils.Repeat)

Aggregations

GuidEntry (edu.umass.cs.gnsclient.client.util.GuidEntry)134 ClientException (edu.umass.cs.gnscommon.exceptions.client.ClientException)87 IOException (java.io.IOException)85 Test (org.junit.Test)69 DefaultGNSTest (edu.umass.cs.gnsserver.utils.DefaultGNSTest)61 RandomString (edu.umass.cs.gnscommon.utils.RandomString)54 BasicGuidEntry (edu.umass.cs.gnsclient.client.util.BasicGuidEntry)46 JSONException (org.json.JSONException)45 JSONArray (org.json.JSONArray)36 GNSClientCommands (edu.umass.cs.gnsclient.client.GNSClientCommands)28 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)18 EncryptionException (edu.umass.cs.gnscommon.exceptions.client.EncryptionException)15 DuplicateNameException (edu.umass.cs.gnscommon.exceptions.client.DuplicateNameException)14 StringTokenizer (java.util.StringTokenizer)13 JSONObject (org.json.JSONObject)12 FieldNotFoundException (edu.umass.cs.gnscommon.exceptions.client.FieldNotFoundException)11 FileNotFoundException (java.io.FileNotFoundException)11 HashSet (java.util.HashSet)10 FileInputStream (java.io.FileInputStream)8 Repeat (edu.umass.cs.utils.Repeat)7