summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuan Nguyen <tnguy238@ford.com>2017-07-26 15:01:43 -0700
committerTuan Nguyen <tnguy238@ford.com>2017-07-26 15:01:43 -0700
commit060a3ac7ab820f7631e515f6f3a21479648f4b4d (patch)
treed71591e0d4bb4432a01ddaf1cf1892f59df4efcd
parente758471965513a8afdddb9e690e1a2e3dd727252 (diff)
downloadsdl_android-bugfix/issue_569.tar.gz
#569 Add test case.bugfix/issue_569
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java37
1 files changed, 36 insertions, 1 deletions
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java
index a6dfe613a..e40049afd 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java
@@ -1,5 +1,8 @@
package com.smartdevicelink.transport;
+import android.app.ActivityManager;
+import android.content.ComponentName;
+import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.test.AndroidTestCase;
@@ -392,6 +395,38 @@ public class RSVTestCase extends AndroidTestCase {
releaseTListLock();
}
-
+
+ /**
+ * Test app's router validation. Validation should fail when the given context and ComponentName object are from different packages and security setting is not OFF
+ * and app is not on trusted list. Validation should pass when the given context and ComponentName object are from the same package.
+ */
+ public void testAppSelfValidation() {
+
+ class RouterServiceValidatorTest extends RouterServiceValidator{
+ public RouterServiceValidatorTest(Context context){
+ super(context);
+ }
+
+ public RouterServiceValidatorTest(Context context, ComponentName service){
+ super(context, service);
+ }
+
+ // Override this method and simply returning true for the purpose of this test
+ protected boolean isServiceRunning(Context context, ComponentName service){
+ return true;
+ }
+ }
+
+ // Fail, different package name for context and service and app security setting is not OFF and app is not on trusted list
+ RouterServiceValidatorTest rsvpFail = new RouterServiceValidatorTest(this.mContext, new ComponentName("anything", mContext.getClass().getSimpleName()));
+ rsvpFail.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH);
+ assertFalse(rsvpFail.validate());
+
+ // Success, same package name for context and service
+ RouterServiceValidatorTest rsvpPass = new RouterServiceValidatorTest(this.mContext, new ComponentName(mContext.getPackageName(), mContext.getClass().getSimpleName()));
+ rsvpPass.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH);
+ assertTrue(rsvpPass.validate());
+ }
+
}