Loading app/build.gradle +0 −2 Original line number Diff line number Diff line Loading @@ -153,8 +153,6 @@ allOpen { dependencies { implementation project(path: ':modules') // TODO: Add splitinstall-lib to a repo https://gitlab.e.foundation/e/os/backlog/-/issues/628 api files('libs/splitinstall-lib.jar') Loading modules/build.gradle +19 −0 Original line number Diff line number Diff line /* * Copyright MURENA SAS 2023 * Apps Quickly and easily install Android apps onto your device! * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' Loading modules/src/androidTest/java/app/lounge/NetworkFetchingAPITest.kt→modules/src/androidTest/java/app/lounge/AnonymousUserAPITest.kt +16 −57 Original line number Diff line number Diff line package app.lounge import app.lounge.model.AnonymousAuthDataRequestBody import app.lounge.model.AnonymousAuthDataValidationRequestBody import app.lounge.model.AuthDataResponse import app.lounge.model.AuthDataValidationResponse import app.lounge.networking.NetworkFetching import app.lounge.networking.NetworkFetchingRetrofitAPI import app.lounge.networking.NetworkFetchingRetrofitImpl import app.lounge.login.anonymous.AnonymousUser import app.lounge.login.anonymous.AnonymousUserRetrofitAPI import app.lounge.login.anonymous.AnonymousUserRetrofitImpl import app.lounge.networking.NetworkResult import com.aurora.gplayapi.data.models.AuthData import kotlinx.coroutines.runBlocking import okhttp3.OkHttpClient import org.junit.Test import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import java.io.InterruptedIOException import java.util.Properties import java.util.concurrent.TimeUnit class NetworkFetchingAPITest { class AnonymousUserAPITest { companion object { var authData: AuthDataResponse? = null var authData: AuthData? = null } @Test fun test1OnSuccessReturnsAuthData() = runBlocking { authData = networkFetchingToken.requestAuthData( fun testOnSuccessReturnsAuthData() = runBlocking { val response = anonymousUser.requestAuthData( anonymousAuthDataRequestBody = requestBodyData, ) assert(authData is AuthDataResponse) { "Assert!! Success must return data" } when(response){ is NetworkResult.Success -> authData = response.data else -> {} } @Test fun test2OnSuccessReturnsLoginData() = runBlocking { var result: AuthDataValidationResponse? = null authData?.let { authData -> authData.dfeCookie = "null" result = networkFetchingToken.requestAuthDataValidation( anonymousAuthDataValidationRequestBody = AnonymousAuthDataValidationRequestBody( authDataResponse = authData ) ) assert(authData is AuthData) { "Assert!! Success must return data" } } assert(authData is AuthDataResponse) { "Assert!! AuthData must be present" } assert(result is AuthDataValidationResponse) { "Assert!! `response` must have data" } } @Test fun test3OnTimeoutFailureReturnsError(): Unit = runBlocking { var failure: Exception = Exception("No Error") authData?.let { authData -> authData.dfeCookie = "null" try { networkFetchingTimeoutGoogle.requestAuthDataValidation( anonymousAuthDataValidationRequestBody = AnonymousAuthDataValidationRequestBody( authDataResponse = authData ) ) } catch (e: InterruptedIOException) { failure = e } } assert(authData is AuthDataResponse) { "Assert!! AuthData must be present" } assert(failure is InterruptedIOException) { "Assert!! Timeout Failure callback must call" } } private fun retrofitTestConfig( baseUrl: String, Loading @@ -78,20 +47,9 @@ class NetworkFetchingAPITest { ) .build() private val eCloudTest = retrofitTestConfig(NetworkFetchingRetrofitAPI.tokenBaseURL) private val googleTest = retrofitTestConfig(NetworkFetchingRetrofitAPI.googlePlayBaseURL) private val googleTestTimeout = retrofitTestConfig( NetworkFetchingRetrofitAPI.googlePlayBaseURL, 50L) private val eCloudTest = retrofitTestConfig(AnonymousUserRetrofitAPI.tokenBaseURL) private val networkFetchingToken: NetworkFetching = NetworkFetchingRetrofitImpl( eCloud = eCloudTest, google = googleTest ) private val networkFetchingTimeoutGoogle: NetworkFetching = NetworkFetchingRetrofitImpl( eCloud = eCloudTest, google = googleTestTimeout ) private val anonymousUser: AnonymousUser = AnonymousUserRetrofitImpl(eCloud = eCloudTest) private val requestBodyData = AnonymousAuthDataRequestBody( properties = testSystemProperties, Loading Loading @@ -139,3 +97,4 @@ val testSystemProperties = Properties().apply { setProperty("CellOperator", "310") setProperty("SimOperator", "38") } modules/src/main/java/app/lounge/di/NetworkModule.kt +28 −23 Original line number Diff line number Diff line /* * Copyright MURENA SAS 2023 * Apps Quickly and easily install Android apps onto your device! * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package app.lounge.di import app.lounge.networking.NetworkFetching import app.lounge.networking.NetworkFetchingRetrofitAPI import app.lounge.networking.NetworkFetchingRetrofitImpl import app.lounge.login.anonymous.AnonymousUser import app.lounge.login.anonymous.AnonymousUserRetrofitAPI import app.lounge.login.anonymous.AnonymousUserRetrofitImpl import dagger.Module import dagger.Provides import dagger.hilt.InstallIn Loading Loading @@ -40,19 +59,7 @@ internal object NetworkModule { ): Retrofit { return retrofit( okHttpClient = okHttpClient, baseUrl = NetworkFetchingRetrofitAPI.tokenBaseURL ) } @Provides @Singleton @Named("GoogleRetrofit") internal fun provideGoogleRetrofit( okHttpClient: OkHttpClient ): Retrofit { return retrofit( okHttpClient = okHttpClient, baseUrl = NetworkFetchingRetrofitAPI.googlePlayBaseURL baseUrl = AnonymousUserRetrofitAPI.tokenBaseURL ) } Loading Loading @@ -81,13 +88,11 @@ internal object NetworkModule { @Provides @Singleton fun provideNetworkFetching( @Named("ECloudRetrofit") ecloud: Retrofit, @Named("GoogleRetrofit") google: Retrofit, ) : NetworkFetching { return NetworkFetchingRetrofitImpl( eCloud = ecloud, google = google fun provideAnonymousUser( @Named("ECloudRetrofit") ecloud: Retrofit ) : AnonymousUser { return AnonymousUserRetrofitImpl( eCloud = ecloud ) } Loading modules/src/main/java/app/lounge/extension/Extension.kt +19 −0 Original line number Diff line number Diff line /* * Copyright MURENA SAS 2023 * Apps Quickly and easily install Android apps onto your device! * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package app.lounge.extension import com.google.gson.Gson Loading Loading
app/build.gradle +0 −2 Original line number Diff line number Diff line Loading @@ -153,8 +153,6 @@ allOpen { dependencies { implementation project(path: ':modules') // TODO: Add splitinstall-lib to a repo https://gitlab.e.foundation/e/os/backlog/-/issues/628 api files('libs/splitinstall-lib.jar') Loading
modules/build.gradle +19 −0 Original line number Diff line number Diff line /* * Copyright MURENA SAS 2023 * Apps Quickly and easily install Android apps onto your device! * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' Loading
modules/src/androidTest/java/app/lounge/NetworkFetchingAPITest.kt→modules/src/androidTest/java/app/lounge/AnonymousUserAPITest.kt +16 −57 Original line number Diff line number Diff line package app.lounge import app.lounge.model.AnonymousAuthDataRequestBody import app.lounge.model.AnonymousAuthDataValidationRequestBody import app.lounge.model.AuthDataResponse import app.lounge.model.AuthDataValidationResponse import app.lounge.networking.NetworkFetching import app.lounge.networking.NetworkFetchingRetrofitAPI import app.lounge.networking.NetworkFetchingRetrofitImpl import app.lounge.login.anonymous.AnonymousUser import app.lounge.login.anonymous.AnonymousUserRetrofitAPI import app.lounge.login.anonymous.AnonymousUserRetrofitImpl import app.lounge.networking.NetworkResult import com.aurora.gplayapi.data.models.AuthData import kotlinx.coroutines.runBlocking import okhttp3.OkHttpClient import org.junit.Test import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import java.io.InterruptedIOException import java.util.Properties import java.util.concurrent.TimeUnit class NetworkFetchingAPITest { class AnonymousUserAPITest { companion object { var authData: AuthDataResponse? = null var authData: AuthData? = null } @Test fun test1OnSuccessReturnsAuthData() = runBlocking { authData = networkFetchingToken.requestAuthData( fun testOnSuccessReturnsAuthData() = runBlocking { val response = anonymousUser.requestAuthData( anonymousAuthDataRequestBody = requestBodyData, ) assert(authData is AuthDataResponse) { "Assert!! Success must return data" } when(response){ is NetworkResult.Success -> authData = response.data else -> {} } @Test fun test2OnSuccessReturnsLoginData() = runBlocking { var result: AuthDataValidationResponse? = null authData?.let { authData -> authData.dfeCookie = "null" result = networkFetchingToken.requestAuthDataValidation( anonymousAuthDataValidationRequestBody = AnonymousAuthDataValidationRequestBody( authDataResponse = authData ) ) assert(authData is AuthData) { "Assert!! Success must return data" } } assert(authData is AuthDataResponse) { "Assert!! AuthData must be present" } assert(result is AuthDataValidationResponse) { "Assert!! `response` must have data" } } @Test fun test3OnTimeoutFailureReturnsError(): Unit = runBlocking { var failure: Exception = Exception("No Error") authData?.let { authData -> authData.dfeCookie = "null" try { networkFetchingTimeoutGoogle.requestAuthDataValidation( anonymousAuthDataValidationRequestBody = AnonymousAuthDataValidationRequestBody( authDataResponse = authData ) ) } catch (e: InterruptedIOException) { failure = e } } assert(authData is AuthDataResponse) { "Assert!! AuthData must be present" } assert(failure is InterruptedIOException) { "Assert!! Timeout Failure callback must call" } } private fun retrofitTestConfig( baseUrl: String, Loading @@ -78,20 +47,9 @@ class NetworkFetchingAPITest { ) .build() private val eCloudTest = retrofitTestConfig(NetworkFetchingRetrofitAPI.tokenBaseURL) private val googleTest = retrofitTestConfig(NetworkFetchingRetrofitAPI.googlePlayBaseURL) private val googleTestTimeout = retrofitTestConfig( NetworkFetchingRetrofitAPI.googlePlayBaseURL, 50L) private val eCloudTest = retrofitTestConfig(AnonymousUserRetrofitAPI.tokenBaseURL) private val networkFetchingToken: NetworkFetching = NetworkFetchingRetrofitImpl( eCloud = eCloudTest, google = googleTest ) private val networkFetchingTimeoutGoogle: NetworkFetching = NetworkFetchingRetrofitImpl( eCloud = eCloudTest, google = googleTestTimeout ) private val anonymousUser: AnonymousUser = AnonymousUserRetrofitImpl(eCloud = eCloudTest) private val requestBodyData = AnonymousAuthDataRequestBody( properties = testSystemProperties, Loading Loading @@ -139,3 +97,4 @@ val testSystemProperties = Properties().apply { setProperty("CellOperator", "310") setProperty("SimOperator", "38") }
modules/src/main/java/app/lounge/di/NetworkModule.kt +28 −23 Original line number Diff line number Diff line /* * Copyright MURENA SAS 2023 * Apps Quickly and easily install Android apps onto your device! * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package app.lounge.di import app.lounge.networking.NetworkFetching import app.lounge.networking.NetworkFetchingRetrofitAPI import app.lounge.networking.NetworkFetchingRetrofitImpl import app.lounge.login.anonymous.AnonymousUser import app.lounge.login.anonymous.AnonymousUserRetrofitAPI import app.lounge.login.anonymous.AnonymousUserRetrofitImpl import dagger.Module import dagger.Provides import dagger.hilt.InstallIn Loading Loading @@ -40,19 +59,7 @@ internal object NetworkModule { ): Retrofit { return retrofit( okHttpClient = okHttpClient, baseUrl = NetworkFetchingRetrofitAPI.tokenBaseURL ) } @Provides @Singleton @Named("GoogleRetrofit") internal fun provideGoogleRetrofit( okHttpClient: OkHttpClient ): Retrofit { return retrofit( okHttpClient = okHttpClient, baseUrl = NetworkFetchingRetrofitAPI.googlePlayBaseURL baseUrl = AnonymousUserRetrofitAPI.tokenBaseURL ) } Loading Loading @@ -81,13 +88,11 @@ internal object NetworkModule { @Provides @Singleton fun provideNetworkFetching( @Named("ECloudRetrofit") ecloud: Retrofit, @Named("GoogleRetrofit") google: Retrofit, ) : NetworkFetching { return NetworkFetchingRetrofitImpl( eCloud = ecloud, google = google fun provideAnonymousUser( @Named("ECloudRetrofit") ecloud: Retrofit ) : AnonymousUser { return AnonymousUserRetrofitImpl( eCloud = ecloud ) } Loading
modules/src/main/java/app/lounge/extension/Extension.kt +19 −0 Original line number Diff line number Diff line /* * Copyright MURENA SAS 2023 * Apps Quickly and easily install Android apps onto your device! * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package app.lounge.extension import com.google.gson.Gson Loading