Search in sources :

Example 56 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class UnsignedReadTest method test_262_UnsignedReadFailAgain.

/**
   * Insures that we still can't read the non-world-readable field without a guid.
   */
@Test
public void test_262_UnsignedReadFailAgain() {
    try {
        try {
            String result = clientCommands.fieldRead(unsignedReadTestGuid.getGuid(), unreadAbleReadFieldName, null);
            Utils.failWithStackTrace("Result of read of westy's " + unreadAbleReadFieldName + " in " + unsignedReadTestGuid.entityName + " as world readable was " + result + " which is wrong because it should have been rejected in UnsignedRead.");
        } catch (ClientException e) {
        }
    } catch (Exception e) {
        Utils.failWithStackTrace("Exception while testing for denied unsigned access in UnsignedRead: ", e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) JSONException(org.json.JSONException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 57 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class UnsignedWriteTest method test_03_UnsignedWrite.

/**
   *
   */
@Test
public void test_03_UnsignedWrite() {
    String unsignedWriteFieldName = "allwriteaccess";
    String standardWriteFieldName = "standardwriteaccess";
    try {
        clientCommands.fieldCreateOneElementList(westyEntry.getGuid(), unsignedWriteFieldName, "default", westyEntry);
        // make it writeable by everyone
        clientCommands.aclAdd(AclAccessType.WRITE_WHITELIST, westyEntry, unsignedWriteFieldName, GNSProtocol.ALL_GUIDS.toString());
        clientCommands.fieldReplaceFirstElement(westyEntry.getGuid(), unsignedWriteFieldName, "funkadelicwrite", westyEntry);
        Assert.assertEquals("funkadelicwrite", clientCommands.fieldReadArrayFirstElement(westyEntry.getGuid(), unsignedWriteFieldName, westyEntry));
        clientCommands.fieldCreateOneElementList(westyEntry.getGuid(), standardWriteFieldName, "bummer", westyEntry);
        try {
            clientCommands.fieldReplaceFirstElement(westyEntry.getGuid(), standardWriteFieldName, "funkadelicwrite", null);
            Utils.failWithStackTrace("Write of westy's field " + standardWriteFieldName + " as world readable should have been rejected.");
        } catch (ClientException e) {
        // normal result
        }
    } catch (IOException | ClientException e) {
        Utils.failWithStackTrace("Exception when we were not expecting it: " + e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 58 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class DottedReadTest method test_20_Update.

/**
   *
   */
@Test
public void test_20_Update() {
    try {
        JSONObject json = new JSONObject();
        JSONObject subJson = new JSONObject();
        subJson.put("sally", "red");
        subJson.put("sammy", "green");
        JSONObject subsubJson = new JSONObject();
        subsubJson.put("right", "seven");
        subsubJson.put("left", "eight");
        subJson.put("sally", subsubJson);
        json.put("flapjack", subJson);
        clientCommands.update(westyEntry, json);
    } catch (JSONException | IOException | ClientException e) {
        Utils.failWithStackTrace("Exception while adding field \"flapjack\": " + e);
    }
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) IOException(java.io.IOException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 59 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class GroupAddTest method test_210_GroupCreate.

/**
   *
   */
@Test
public void test_210_GroupCreate() {
    String mygroupName = "mygroup" + RandomString.randomString(12);
    try {
        try {
            clientCommands.lookupGuid(mygroupName);
            Utils.failWithStackTrace(mygroupName + " entity should not exist");
        } catch (ClientException e) {
        }
        mygroupEntry = clientCommands.guidCreate(masterGuid, mygroupName);
    } catch (Exception e) {
        Utils.failWithStackTrace("Exception while creating guids: ", e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) JSONException(org.json.JSONException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 60 with ClientException

use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.

the class GroupAddTest method test_211_GroupAdd.

/**
   *
   */
@Test
public void test_211_GroupAdd() {
    try {
        JSONArray guids = new JSONArray(Arrays.asList(westyEntry.getGuid(), samEntry.getGuid(), guidToDeleteEntry.getGuid()));
        clientCommands.groupAddGuids(mygroupEntry.getGuid(), guids, mygroupEntry);
    } catch (IOException | ClientException e) {
        Utils.failWithStackTrace("Exception while adding to groups: ", e);
    }
}
Also used : JSONArray(org.json.JSONArray) IOException(java.io.IOException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Aggregations

ClientException (edu.umass.cs.gnscommon.exceptions.client.ClientException)239 IOException (java.io.IOException)215 Test (org.junit.Test)134 JSONException (org.json.JSONException)126 DefaultGNSTest (edu.umass.cs.gnsserver.utils.DefaultGNSTest)125 RandomString (edu.umass.cs.gnscommon.utils.RandomString)113 JSONArray (org.json.JSONArray)74 GuidEntry (edu.umass.cs.gnsclient.client.util.GuidEntry)71 JSONObject (org.json.JSONObject)59 GNSClientCommands (edu.umass.cs.gnsclient.client.GNSClientCommands)40 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)37 StringTokenizer (java.util.StringTokenizer)30 EncryptionException (edu.umass.cs.gnscommon.exceptions.client.EncryptionException)23 BasicGuidEntry (edu.umass.cs.gnsclient.client.util.BasicGuidEntry)20 FieldNotFoundException (edu.umass.cs.gnscommon.exceptions.client.FieldNotFoundException)19 FileNotFoundException (java.io.FileNotFoundException)18 InternalRequestException (edu.umass.cs.gnscommon.exceptions.server.InternalRequestException)15 ResponseCode (edu.umass.cs.gnscommon.ResponseCode)13 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)13 InvalidKeyException (java.security.InvalidKeyException)12