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, "**************************************");
}
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, "**************************************");
}
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, "**************************************");
}
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, "**************************************");
}
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, "**************************************");
}
Aggregations