Search in sources :

Example 91 with ClientException

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

the class AclDefaultsTest method test_113_ACLCheckForAllFieldsMissing.

/**
   *
   */
@Test
public void test_113_ACLCheckForAllFieldsMissing() {
    try {
        JSONArray expected = new JSONArray();
        JSONAssert.assertEquals(expected, clientCommands.aclGet(AclAccessType.READ_WHITELIST, masterGuid, GNSProtocol.ENTIRE_RECORD.toString(), masterGuid.getGuid()), true);
    } catch (ClientException | IOException | JSONException e) {
        Utils.failWithStackTrace("Exception while checking ALL_FIELDS in ACLCheckForAllFieldsMissing: ", e);
    }
}
Also used : JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 92 with ClientException

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

the class AclDefaultsTest method test_139_ACLNotReadOtherGuidFieldTest.

/**
   *
   */
@Test
public void test_139_ACLNotReadOtherGuidFieldTest() {
    try {
        try {
            String result = clientCommands.fieldRead(westyEntry.getGuid(), "environment", samEntry);
            Utils.failWithStackTrace("Result of read of westy's environment by sam is " + result + " which is wrong because it should have been rejected.");
        } catch (ClientException e) {
        }
    } catch (Exception e) {
        Utils.failWithStackTrace("Exception while reading fields in ACLNotReadOtherGuidFieldTest: ", 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 93 with ClientException

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

the class AclDefaultsTest method test_148_ACLTestReadsThree.

/**
   *
   */
@Test
public void test_148_ACLTestReadsThree() {
    try {
        try {
            String result = clientCommands.fieldRead(barneyEntry.getGuid(), "address", samEntry);
            Utils.failWithStackTrace("Result of read of barney's address by sam is " + result + " which is wrong because it should have been rejected.");
        } catch (ClientException e) {
            if (e.getCode() == ResponseCode.ACCESS_ERROR) {
                System.out.print("This was expected for null querier trying to ReadUnsigned " + barneyEntry.getGuid() + "'s address: " + e);
            }
        } catch (IOException e) {
            Utils.failWithStackTrace("Exception while Sam reading Barney' address: ", e);
        }
    } catch (Exception e) {
        Utils.failWithStackTrace("Exception when we were not expecting it in ACLTestReadsThree: ", e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) 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 94 with ClientException

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

the class AclDefaultsTest method test_149_ACLALLFields.

/**
   *
   */
@Test
public void test_149_ACLALLFields() {
    String superUserName = "superuser" + RandomString.randomString(12);
    try {
        try {
            clientCommands.lookupGuid(superUserName);
            Utils.failWithStackTrace(superUserName + " entity should not exist");
        } catch (ClientException e) {
        }
        GuidEntry superuserEntry = clientCommands.guidCreate(masterGuid, superUserName);
        // let superuser read any of barney's fields
        clientCommands.aclAdd(AclAccessType.READ_WHITELIST, barneyEntry, GNSProtocol.ENTIRE_RECORD.toString(), superuserEntry.getGuid());
        Assert.assertEquals("413-555-1234", clientCommands.fieldRead(barneyEntry.getGuid(), "cell", superuserEntry));
        Assert.assertEquals("100 Main Street", clientCommands.fieldRead(barneyEntry.getGuid(), "address", superuserEntry));
        try {
            clientCommands.guidRemove(masterGuid, superuserEntry.getGuid());
        } catch (IOException | ClientException e) {
            Utils.failWithStackTrace("Exception while deleting superuserEntry in ACLALLFields: ", e);
        }
    } catch (IOException | ClientException e) {
        Utils.failWithStackTrace("Exception when we were not expecting it in ACLALLFields: ", e);
    }
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) IOException(java.io.IOException) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) Test(org.junit.Test) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest)

Example 95 with ClientException

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

the class AclDefaultsTest method test_138_ACLNotReadOtherGuidAllFieldsTest.

/**
   *
   */
@Test
public void test_138_ACLNotReadOtherGuidAllFieldsTest() {
    try {
        try {
            String result = clientCommands.fieldRead(westyEntry.getGuid(), GNSProtocol.ENTIRE_RECORD.toString(), samEntry);
            Utils.failWithStackTrace("Result of read of all of westy's fields by sam is " + result + " which is wrong because it should have been rejected.");
        } catch (ClientException e) {
        }
    } catch (Exception e) {
        Utils.failWithStackTrace("Exception while reading fields in ACLNotReadOtherGuidAllFieldsTest: ", 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)

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