Loading app/src/test/java/foundation/e/apps/exodus/PrivacyScoreRepositoryImplTest.kt +23 −3 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import org.mockito.Mock import org.mockito.Mockito import org.mockito.MockitoAnnotations import org.mockito.kotlin.any import org.mockito.kotlin.eq class PrivacyScoreRepositoryImplTest { Loading @@ -50,7 +51,7 @@ class PrivacyScoreRepositoryImplTest { _id = "113", status = Status.UNAVAILABLE, name = "Demo Three", package_name = "a.b.c", package_name = "com.test.fakePackage", latest_version_code = 123, is_pwa = true, permsFromExodus = listOf(), Loading @@ -67,7 +68,7 @@ class PrivacyScoreRepositoryImplTest { _id = "113", status = Status.UNAVAILABLE, name = "Demo Three", package_name = "a.b.c", package_name = "com.test.fakePackage", latest_version_code = 123, is_pwa = true, perms = listOf(), Loading @@ -83,7 +84,7 @@ class PrivacyScoreRepositoryImplTest { _id = "113", status = Status.UNAVAILABLE, name = "Demo Three", package_name = "a.b.c", package_name = "com.test.fakePackage", latest_version_code = 123, is_pwa = true, permsFromExodus = listOf(), Loading @@ -93,4 +94,23 @@ class PrivacyScoreRepositoryImplTest { val privacyScore = privacyScoreRepository.calculatePrivacyScore(application) Assert.assertEquals("failed to retrieve valid privacy score", 9, privacyScore) } @Test fun `test calculate privacyScore for the app are available in privacyScoreZero applist`() { val application = Application( _id = "113", status = Status.UNAVAILABLE, name = "Demo Three", package_name = "com.test.fakePackage.privacyZero", latest_version_code = 123, is_pwa = true, permsFromExodus = listOf(), perms = listOf(), trackers = CommonUtilsModule.LIST_OF_NULL ) Mockito.`when`(blockedAppRepository.isPrivacyScoreZero(eq("com.test.fakePackage.privacyZero"))).thenReturn(true) val privacyScore = privacyScoreRepository.calculatePrivacyScore(application) Assert.assertEquals("privacy score zero", 0, privacyScore) } } app/src/test/java/foundation/e/apps/gplay/GplyHttpClientTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ class GplyHttpClientTest { @Test fun testPostAuthFailedWhenStatus401() = runTest { initMocksForStatus401() val response = gPlayHttpClient.postAuth("http://abc.abc", "".toByteArray()) val response = gPlayHttpClient.postAuth(FakeCall.FAKE_URL, "".toByteArray()) assertResponse(response) } Loading @@ -123,7 +123,7 @@ class GplyHttpClientTest { fun testPostAuthFailedWhenStatus429() = runTest { initMocksForStatus429() try { gPlayHttpClient.postAuth("http://abc.abc", "".toByteArray()) gPlayHttpClient.postAuth(FakeCall.FAKE_URL, "".toByteArray()) } catch (e: Exception) { assert429(e) } Loading app/src/test/java/foundation/e/apps/util/FakeCall.kt +3 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class FakeCall : Call { var willThrow429 = false companion object { const val FAKE_URL = "https://abc.abc" const val FAKE_URL = "https://murena.test" } private val fakeRequest = Request.Builder().url(FAKE_URL).build() Loading @@ -55,11 +55,13 @@ class FakeCall : Call { .message("") .code(401) .body("".toResponseBody()) if (willThrow401) { builder.code(401) } else if (willThrow429) { builder.code(429) } return builder.build() } Loading Loading
app/src/test/java/foundation/e/apps/exodus/PrivacyScoreRepositoryImplTest.kt +23 −3 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import org.mockito.Mock import org.mockito.Mockito import org.mockito.MockitoAnnotations import org.mockito.kotlin.any import org.mockito.kotlin.eq class PrivacyScoreRepositoryImplTest { Loading @@ -50,7 +51,7 @@ class PrivacyScoreRepositoryImplTest { _id = "113", status = Status.UNAVAILABLE, name = "Demo Three", package_name = "a.b.c", package_name = "com.test.fakePackage", latest_version_code = 123, is_pwa = true, permsFromExodus = listOf(), Loading @@ -67,7 +68,7 @@ class PrivacyScoreRepositoryImplTest { _id = "113", status = Status.UNAVAILABLE, name = "Demo Three", package_name = "a.b.c", package_name = "com.test.fakePackage", latest_version_code = 123, is_pwa = true, perms = listOf(), Loading @@ -83,7 +84,7 @@ class PrivacyScoreRepositoryImplTest { _id = "113", status = Status.UNAVAILABLE, name = "Demo Three", package_name = "a.b.c", package_name = "com.test.fakePackage", latest_version_code = 123, is_pwa = true, permsFromExodus = listOf(), Loading @@ -93,4 +94,23 @@ class PrivacyScoreRepositoryImplTest { val privacyScore = privacyScoreRepository.calculatePrivacyScore(application) Assert.assertEquals("failed to retrieve valid privacy score", 9, privacyScore) } @Test fun `test calculate privacyScore for the app are available in privacyScoreZero applist`() { val application = Application( _id = "113", status = Status.UNAVAILABLE, name = "Demo Three", package_name = "com.test.fakePackage.privacyZero", latest_version_code = 123, is_pwa = true, permsFromExodus = listOf(), perms = listOf(), trackers = CommonUtilsModule.LIST_OF_NULL ) Mockito.`when`(blockedAppRepository.isPrivacyScoreZero(eq("com.test.fakePackage.privacyZero"))).thenReturn(true) val privacyScore = privacyScoreRepository.calculatePrivacyScore(application) Assert.assertEquals("privacy score zero", 0, privacyScore) } }
app/src/test/java/foundation/e/apps/gplay/GplyHttpClientTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ class GplyHttpClientTest { @Test fun testPostAuthFailedWhenStatus401() = runTest { initMocksForStatus401() val response = gPlayHttpClient.postAuth("http://abc.abc", "".toByteArray()) val response = gPlayHttpClient.postAuth(FakeCall.FAKE_URL, "".toByteArray()) assertResponse(response) } Loading @@ -123,7 +123,7 @@ class GplyHttpClientTest { fun testPostAuthFailedWhenStatus429() = runTest { initMocksForStatus429() try { gPlayHttpClient.postAuth("http://abc.abc", "".toByteArray()) gPlayHttpClient.postAuth(FakeCall.FAKE_URL, "".toByteArray()) } catch (e: Exception) { assert429(e) } Loading
app/src/test/java/foundation/e/apps/util/FakeCall.kt +3 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class FakeCall : Call { var willThrow429 = false companion object { const val FAKE_URL = "https://abc.abc" const val FAKE_URL = "https://murena.test" } private val fakeRequest = Request.Builder().url(FAKE_URL).build() Loading @@ -55,11 +55,13 @@ class FakeCall : Call { .message("") .code(401) .body("".toResponseBody()) if (willThrow401) { builder.code(401) } else if (willThrow429) { builder.code(429) } return builder.build() } Loading