Search in sources :

Example 66 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusDBHelperLoginTest method testModifyCredentialsAndKey.

/*
	 * Modify credentials and public key then fetch modified credentials and validate it
	 */
@MediumTest
public void testModifyCredentialsAndKey() {
    Log.i(LOG_TAG, "***** EXECUTING testAddDeleteContactsDetails *****");
    Log.i(LOG_TAG, "Test contact functionality (add delete contacts details)");
    Log.i(LOG_TAG, "Test 1a: Initialise test environment and load database");
    assertTrue(initialise());
    Log.i(LOG_TAG, "Test 1b: Remove user data");
    mDatabaseHelper.removeUserData();
    ServiceStatus status = mTestUtility.waitForEvent(WAIT_EVENT_TIMEOUT_MS, DbTestUtility.CONTACTS_INT_EVENT_MASK);
    assertEquals(ServiceStatus.SUCCESS, status);
    RegistrationDetails registrationDetails = new RegistrationDetails();
    registrationDetails.mUsername = TestModule.generateRandomString();
    registrationDetails.mPassword = TestModule.generateRandomString();
    registrationDetails.mMsisdn = TestModule.generateRandomString();
    LoginDetails loginDetails = new LoginDetails();
    loginDetails.mUsername = registrationDetails.mUsername;
    loginDetails.mPassword = registrationDetails.mPassword;
    loginDetails.mAutoConnect = TestModule.generateRandomBoolean();
    loginDetails.mRememberMe = TestModule.generateRandomBoolean();
    loginDetails.mMobileNo = registrationDetails.mMsisdn;
    loginDetails.mSubscriberId = TestModule.generateRandomString();
    PublicKeyDetails pubKeyDetails = new PublicKeyDetails();
    RSAEncryptionUtils.copyDefaultPublicKey(pubKeyDetails);
    pubKeyDetails.mKeyBase64 = TestModule.generateRandomString();
    LoginDetails fetchedLogin = new LoginDetails();
    PublicKeyDetails fetchedPubKey = new PublicKeyDetails();
    status = mDatabaseHelper.fetchLogonCredentialsAndPublicKey(fetchedLogin, fetchedPubKey);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertNull(fetchedLogin.mUsername);
    assertNull(fetchedLogin.mPassword);
    assertNull(fetchedPubKey.mKeyBase64);
    assertNull(fetchedPubKey.mExponential);
    assertNull(fetchedPubKey.mModulus);
    status = mDatabaseHelper.modifyCredentialsAndPublicKey(loginDetails, pubKeyDetails);
    assertEquals(ServiceStatus.SUCCESS, status);
    status = mDatabaseHelper.fetchLogonCredentialsAndPublicKey(fetchedLogin, fetchedPubKey);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, fetchedLogin.mUsername);
    if (loginDetails.mRememberMe) {
        assertEquals(loginDetails.mPassword, fetchedLogin.mPassword);
    }
    assertEquals(loginDetails.mAutoConnect, fetchedLogin.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, fetchedLogin.mRememberMe);
    assertEquals(loginDetails.mMobileNo, fetchedLogin.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, fetchedLogin.mSubscriberId);
    assertEquals(pubKeyDetails.mExponential.length, fetchedPubKey.mExponential.length);
    for (int i = 0; i < pubKeyDetails.mExponential.length; i++) {
        assertEquals(pubKeyDetails.mExponential[i], fetchedPubKey.mExponential[i]);
    }
    assertEquals(pubKeyDetails.mModulus.length, fetchedPubKey.mModulus.length);
    for (int i = 0; i < fetchedPubKey.mModulus.length; i++) {
        assertEquals(pubKeyDetails.mModulus[i], fetchedPubKey.mModulus[i]);
    }
    assertEquals(pubKeyDetails.mKeyBase64, fetchedPubKey.mKeyBase64);
    shutdown();
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "testModifyFetchCredentials has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : PublicKeyDetails(com.vodafone360.people.datatypes.PublicKeyDetails) ServiceStatus(com.vodafone360.people.service.ServiceStatus) RegistrationDetails(com.vodafone360.people.datatypes.RegistrationDetails) LoginDetails(com.vodafone360.people.datatypes.LoginDetails) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 67 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusStateTableTest method testMeProfileId.

/*
     * modify and fetch MeProfileId
     */
public void testMeProfileId() {
    final String fnName = "testMeProfileId";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "modify and fetching MeProfileId");
    SQLiteDatabase writableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    Long myContactID = TestModule.generateRandomLong();
    ServiceStatus status = StateTable.modifyMeProfileID(myContactID, writableDb);
    assertEquals(ServiceStatus.ERROR_DATABASE_CORRUPT, status);
    Long fetchedMeProfileId = StateTable.fetchMeProfileId(readableDb);
    assertNull(fetchedMeProfileId);
    createTable();
    fetchedMeProfileId = StateTable.fetchMeProfileId(readableDb);
    assertNull(fetchedMeProfileId);
    status = StateTable.modifyMeProfileID(myContactID, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    fetchedMeProfileId = StateTable.fetchMeProfileId(readableDb);
    assertEquals(myContactID, fetchedMeProfileId);
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "modify and fetching MeProfileId has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 68 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusStateTableTest method testModifyCredentialsAndKey.

/*
     * Modify credentials and public key then fetch modified credentials and
     * validate it
     */
@MediumTest
public void testModifyCredentialsAndKey() {
    final String fnName = "testModifyCredentialsAndKey";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "modfiy and fetchmodified credentials");
    SQLiteDatabase writableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    LoginDetails loginDetails = new LoginDetails();
    RegistrationDetails registrationDetails = new RegistrationDetails();
    registrationDetails.mUsername = TestModule.generateRandomString();
    registrationDetails.mPassword = TestModule.generateRandomString();
    registrationDetails.mMsisdn = TestModule.generateRandomString();
    loginDetails.mUsername = registrationDetails.mUsername;
    loginDetails.mPassword = registrationDetails.mPassword;
    loginDetails.mAutoConnect = true;
    loginDetails.mRememberMe = true;
    loginDetails.mMobileNo = registrationDetails.mMsisdn;
    loginDetails.mSubscriberId = TestModule.generateRandomString();
    PublicKeyDetails pubKeyDetails = new PublicKeyDetails();
    RSAEncryptionUtils.copyDefaultPublicKey(pubKeyDetails);
    // try to modify credentials before creating a table causes uncaught
    // exception
    ServiceStatus status = StateTable.modifyCredentialsAndPublicKey(loginDetails, pubKeyDetails, writableDb);
    assertEquals(ServiceStatus.ERROR_DATABASE_CORRUPT, status);
    createTable();
    // positive test modify credentials after table was created
    status = StateTable.modifyCredentialsAndPublicKey(loginDetails, pubKeyDetails, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    PublicKeyDetails fetchedPubKey = new PublicKeyDetails();
    LoginDetails fetchedLoginDetails = new LoginDetails();
    status = StateTable.fetchLogonCredentialsAndPublicKey(fetchedLoginDetails, fetchedPubKey, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, fetchedLoginDetails.mUsername);
    assertEquals(loginDetails.mPassword, fetchedLoginDetails.mPassword);
    assertEquals(loginDetails.mAutoConnect, fetchedLoginDetails.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, fetchedLoginDetails.mRememberMe);
    assertEquals(loginDetails.mMobileNo, fetchedLoginDetails.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, fetchedLoginDetails.mSubscriberId);
    assertEquals(pubKeyDetails.mExponential.length, fetchedPubKey.mExponential.length);
    for (int i = 0; i < pubKeyDetails.mExponential.length; i++) {
        assertEquals(pubKeyDetails.mExponential[i], fetchedPubKey.mExponential[i]);
    }
    assertEquals(pubKeyDetails.mModulus.length, fetchedPubKey.mModulus.length);
    for (int i = 0; i < fetchedPubKey.mModulus.length; i++) {
        assertEquals(pubKeyDetails.mModulus[i], fetchedPubKey.mModulus[i]);
    }
    loginDetails.mRememberMe = false;
    pubKeyDetails.mKeyBase64 = TestModule.generateRandomString();
    status = StateTable.modifyCredentialsAndPublicKey(loginDetails, pubKeyDetails, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    LoginDetails modifedLoginDetails = new LoginDetails();
    PublicKeyDetails modifiedPubKey = new PublicKeyDetails();
    status = StateTable.fetchLogonCredentialsAndPublicKey(modifedLoginDetails, modifiedPubKey, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, modifedLoginDetails.mUsername);
    // mRemberme was set to false
    assertNull(modifedLoginDetails.mPassword);
    // so password should be null
    assertEquals(loginDetails.mAutoConnect, modifedLoginDetails.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, modifedLoginDetails.mRememberMe);
    assertEquals(loginDetails.mMobileNo, modifedLoginDetails.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, modifedLoginDetails.mSubscriberId);
    assertEquals(pubKeyDetails.mExponential.length, modifiedPubKey.mExponential.length);
    for (int i = 0; i < pubKeyDetails.mExponential.length; i++) {
        assertEquals(pubKeyDetails.mExponential[i], fetchedPubKey.mExponential[i]);
    }
    assertEquals(pubKeyDetails.mModulus.length, modifiedPubKey.mModulus.length);
    for (int i = 0; i < fetchedPubKey.mModulus.length; i++) {
        assertEquals(pubKeyDetails.mModulus[i], fetchedPubKey.mModulus[i]);
    }
    assertEquals(pubKeyDetails.mKeyBase64, modifiedPubKey.mKeyBase64);
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "testModifyCredentialsAndKey has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : PublicKeyDetails(com.vodafone360.people.datatypes.PublicKeyDetails) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus) RegistrationDetails(com.vodafone360.people.datatypes.RegistrationDetails) LoginDetails(com.vodafone360.people.datatypes.LoginDetails) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 69 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusStateTableTest method testModifyCredentials.

/*
     * Modify credentials then fetch modified credentials and validate it
     */
@MediumTest
public void testModifyCredentials() {
    final String fnName = "testModifyCredentials";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "modfiy and fetchmodified credentials");
    SQLiteDatabase writableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    LoginDetails loginDetails = new LoginDetails();
    RegistrationDetails registrationDetails = new RegistrationDetails();
    registrationDetails.mUsername = TestModule.generateRandomString();
    registrationDetails.mPassword = TestModule.generateRandomString();
    registrationDetails.mMsisdn = TestModule.generateRandomString();
    loginDetails.mUsername = registrationDetails.mUsername;
    loginDetails.mPassword = registrationDetails.mPassword;
    loginDetails.mAutoConnect = true;
    loginDetails.mRememberMe = true;
    loginDetails.mMobileNo = registrationDetails.mMsisdn;
    loginDetails.mSubscriberId = TestModule.generateRandomString();
    // try to modify credentials before creating a table causes uncaught
    // exception
    ServiceStatus status = StateTable.modifyCredentials(loginDetails, writableDb);
    assertEquals(ServiceStatus.ERROR_DATABASE_CORRUPT, status);
    createTable();
    // positive test modify credentials after table was created
    status = StateTable.modifyCredentials(loginDetails, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    LoginDetails fetchedLoginDetails = new LoginDetails();
    status = StateTable.fetchLogonCredentials(fetchedLoginDetails, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, fetchedLoginDetails.mUsername);
    assertEquals(loginDetails.mPassword, fetchedLoginDetails.mPassword);
    assertEquals(loginDetails.mAutoConnect, fetchedLoginDetails.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, fetchedLoginDetails.mRememberMe);
    assertEquals(loginDetails.mMobileNo, fetchedLoginDetails.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, fetchedLoginDetails.mSubscriberId);
    loginDetails.mRememberMe = false;
    status = StateTable.modifyCredentials(loginDetails, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    LoginDetails modifedLoginDetails = new LoginDetails();
    status = StateTable.fetchLogonCredentials(modifedLoginDetails, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, modifedLoginDetails.mUsername);
    // mRemberme was set to false
    assertNull(modifedLoginDetails.mPassword);
    // so password should be null
    assertEquals(loginDetails.mAutoConnect, modifedLoginDetails.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, modifedLoginDetails.mRememberMe);
    assertEquals(loginDetails.mMobileNo, modifedLoginDetails.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, modifedLoginDetails.mSubscriberId);
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "testModifyCredentials has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus) RegistrationDetails(com.vodafone360.people.datatypes.RegistrationDetails) LoginDetails(com.vodafone360.people.datatypes.LoginDetails) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 70 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusStateTableTest method testSetFetchSession.

/*
     * set and fetch session
     */
public void testSetFetchSession() {
    final String fnName = "testSetFetchSession";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "test setting and fetching session");
    SQLiteDatabase writableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    AuthSessionHolder session = new AuthSessionHolder();
    session.sessionID = TestModule.generateRandomString();
    session.sessionSecret = TestModule.generateRandomString();
    session.userID = TestModule.generateRandomInt();
    session.userName = TestModule.generateRandomString();
    ServiceStatus status = StateTable.setSession(session, writableDb);
    assertNull(status);
    AuthSessionHolder fetchedSession = StateTable.fetchSession(readableDb);
    assertNull(fetchedSession);
    createTable();
    status = StateTable.setSession(session, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    fetchedSession = StateTable.fetchSession(readableDb);
    assertEquals(session.toString(), fetchedSession.toString());
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "testSetFetchSession has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : AuthSessionHolder(com.vodafone360.people.datatypes.AuthSessionHolder) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Aggregations

ServiceStatus (com.vodafone360.people.service.ServiceStatus)190 Contact (com.vodafone360.people.datatypes.Contact)71 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)63 MediumTest (android.test.suitebuilder.annotation.MediumTest)62 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)43 ArrayList (java.util.ArrayList)43 Suppress (android.test.suitebuilder.annotation.Suppress)40 Cursor (android.database.Cursor)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)17 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)16 Bundle (android.os.Bundle)12 ContentValues (android.content.ContentValues)11 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)11 SQLException (android.database.SQLException)9 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)9 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)9 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)9 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)8 LoginDetails (com.vodafone360.people.datatypes.LoginDetails)8 PersistSettings (com.vodafone360.people.service.PersistSettings)8