Search in sources :

Example 6 with Credentials

use of com.trovebox.android.common.model.Credentials in project mobile-android by photo.

the class CredentialsTest method testCredentialsParcelable.

public void testCredentialsParcelable() {
    Credentials c;
    try {
        JSONObject json = JSONUtils.getJson(getInstrumentation().getContext(), R.raw.json_credentials);
        c = new Credentials(json);
    } catch (JSONException e) {
        throw new AssertionError("This exception should not be thrown!");
    }
    checkCredentials(c, "hello@trovebox.com");
    Parcel parcel = Parcel.obtain();
    c.writeToParcel(parcel, 0);
    // done writing, now reset parcel for reading
    parcel.setDataPosition(0);
    // finish round trip
    Credentials createFromParcel = Credentials.CREATOR.createFromParcel(parcel);
    checkCredentials(createFromParcel, "hello@trovebox.com");
}
Also used : JSONObject(org.json.JSONObject) Parcel(android.os.Parcel) JSONException(org.json.JSONException) Credentials(com.trovebox.android.common.model.Credentials)

Example 7 with Credentials

use of com.trovebox.android.common.model.Credentials in project mobile-android by photo.

the class AccountTroveboxResponseTest method testMultiResponse.

public void testMultiResponse() throws JSONException {
    JSONObject json = JSONUtils.getJson(getInstrumentation().getContext(), R.raw.json_login_multiple);
    AccountTroveboxResponse response = new AccountTroveboxResponse(RequestType.UNKNOWN, json);
    assertNotNull(response);
    assertEquals(200, response.getCode());
    Credentials[] credentials = response.getCredentials();
    assertNotNull(credentials);
    assertTrue(credentials.length == 2);
    CredentialsTest.checkCredentials(credentials[0], "hello@trovebox.com");
    CredentialsTest.checkCredentials(credentials[1], "hello2@trovebox.com");
}
Also used : AccountTroveboxResponse(com.trovebox.android.app.net.account.AccountTroveboxResponse) JSONObject(org.json.JSONObject) Credentials(com.trovebox.android.common.model.Credentials)

Example 8 with Credentials

use of com.trovebox.android.common.model.Credentials in project mobile-android by photo.

the class AccountTroveboxResponseTest method testMultiResponseV2.

public void testMultiResponseV2() throws JSONException {
    JSONObject json = JSONUtils.getJson(getInstrumentation().getContext(), R.raw.json_login_multiple_v2);
    AccountTroveboxResponse response = new AccountTroveboxResponse(RequestType.UNKNOWN, json);
    assertNotNull(response);
    assertEquals(200, response.getCode());
    Credentials[] credentials = response.getCredentials();
    assertNotNull(credentials);
    assertTrue(credentials.length == 3);
    CredentialsTest.checkCredentialsV2(credentials[0], "hello@trovebox.com", "http://test.trovebox.com", Credentials.OWNER_TYPE);
    CredentialsTest.checkCredentialsV2(credentials[1], "hellox@trovebox.com", "http://test2.trovebox.com", Credentials.ADMIN_TYPE);
    CredentialsTest.checkCredentialsV2(credentials[2], "hellox2@trovebox.com", "http://test3.trovebox.com", Credentials.GROUP_TYPE);
}
Also used : AccountTroveboxResponse(com.trovebox.android.app.net.account.AccountTroveboxResponse) JSONObject(org.json.JSONObject) Credentials(com.trovebox.android.common.model.Credentials)

Aggregations

Credentials (com.trovebox.android.common.model.Credentials)8 JSONObject (org.json.JSONObject)6 AccountTroveboxResponse (com.trovebox.android.app.net.account.AccountTroveboxResponse)4 Parcel (android.os.Parcel)2 JSONException (org.json.JSONException)2 Intent (android.content.Intent)1 GoogleIdToken (com.google.api.client.googleapis.auth.oauth2.GoogleIdToken)1 GoogleIdTokenVerifier (com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier)1 NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)1 JsonFactory (com.google.api.client.json.JsonFactory)1 GsonFactory (com.google.api.client.json.gson.GsonFactory)1