Skip to content

Commit

Permalink
Merge c86d66b into ec76313
Browse files Browse the repository at this point in the history
  • Loading branch information
ktiniatros authored Sep 28, 2021
2 parents ec76313 + c86d66b commit a065ebd
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import nl.rijksoverheid.ctr.appconfig.persistence.*
import nl.rijksoverheid.ctr.appconfig.repositories.ConfigRepository
import nl.rijksoverheid.ctr.appconfig.repositories.ConfigRepositoryImpl
import nl.rijksoverheid.ctr.appconfig.usecases.*
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.viewmodel.dsl.viewModel
Expand All @@ -26,7 +28,7 @@ import retrofit2.Retrofit
* @param path Path for the config api, for example "holder" to fetch the config from <baseurl>/holder/config
* @param versionCode version code
*/
fun appConfigModule(path: String, versionCode: Int) = module {
fun appConfigModule(cdnUrl: String, path: String, versionCode: Int) = module {
factory<ConfigRepository> { ConfigRepositoryImpl(get()) }
factory<AppConfigUseCase> { AppConfigUseCaseImpl(get(), get(), get(), get()) }
factory<AppStatusUseCase> {
Expand Down Expand Up @@ -62,7 +64,7 @@ fun appConfigModule(path: String, versionCode: Int) = module {
single {
val okHttpClient = get<OkHttpClient>(OkHttpClient::class).newBuilder().build()
val retrofit = get<Retrofit>(Retrofit::class)
val baseUrl = retrofit.baseUrl().newBuilder().addPathSegments("$path/").build()
val baseUrl = cdnUrl.toHttpUrl().newBuilder().addPathSegments("$path/").build()
retrofit.newBuilder().baseUrl(baseUrl).client(okHttpClient).build()
.create(AppConfigApi::class.java)
}
Expand All @@ -82,4 +84,4 @@ fun appConfigModule(path: String, versionCode: Int) = module {
}

fun isVerifierApp(applicationContext: Context): Boolean =
applicationContext.packageName.contains("verifier")
applicationContext.packageName.contains("verifier")
2 changes: 2 additions & 0 deletions holder/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ android {
"{" +
"\"sha256/lR7gRvqDMW5nhsCMRPE7TKLq0tJkTWMxQ5HAzHCIfQ0=\"" +
"}"
buildConfigField "String", "CDN_API_URL", "\"https://holder-api-cdn.coronacheck.nl/v5/\""
manifestPlaceholders = [appLabel: "@string/app_name", deepLinkHost: "coronacheck.nl", digidSchema: "coronacheck"]

javaCompileOptions {
Expand Down Expand Up @@ -96,6 +97,7 @@ android {
"{" +
"\"sha256/lR7gRvqDMW5nhsCMRPE7TKLq0tJkTWMxQ5HAzHCIfQ0=\"" +
"}"
buildConfigField "String", "CDN_API_URL", "\"https://holder-api-cdn.acc.coronacheck.nl/v5/\""
dimension "environment"
versionNameSuffix "-acc"
applicationIdSuffix ".acc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ open class HolderApplication : SharedApplication(), Configuration.Provider {
BuildConfig.CERTIFICATE_PINS,
),
sharedModule,
appConfigModule("holder", BuildConfig.VERSION_CODE),
appConfigModule(BuildConfig.CDN_API_URL,"holder", BuildConfig.VERSION_CODE),
introductionModule,
*getAdditionalModules().toTypedArray(),
designModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ package nl.rijksoverheid.ctr.holder
import com.squareup.moshi.Moshi
import kotlinx.coroutines.runBlocking
import nl.rijksoverheid.ctr.api.json.JsonObjectJsonAdapter
import nl.rijksoverheid.ctr.appconfig.AppConfigViewModel
import nl.rijksoverheid.ctr.appconfig.AppConfigViewModelImpl
import nl.rijksoverheid.ctr.appconfig.api.AppConfigApi
import nl.rijksoverheid.ctr.appconfig.appConfigModule
import nl.rijksoverheid.ctr.appconfig.isVerifierApp
import nl.rijksoverheid.ctr.appconfig.persistence.*
import nl.rijksoverheid.ctr.appconfig.repositories.ConfigRepository
import nl.rijksoverheid.ctr.appconfig.repositories.ConfigRepositoryImpl
import nl.rijksoverheid.ctr.appconfig.usecases.*
import okhttp3.CertificatePinner
import okhttp3.CertificatePinner.Companion.sha256Hash
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
Expand All @@ -15,7 +24,10 @@ import okhttp3.tls.HeldCertificate
import org.junit.Assert.assertThrows
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.context.loadKoinModules
import org.koin.core.context.unloadKoinModules
import org.koin.dsl.module
import org.koin.test.AutoCloseKoinTest
import org.koin.test.get
Expand Down Expand Up @@ -57,7 +69,8 @@ class CertificatePinTest: AutoCloseKoinTest() {
setBody("{}")
})

loadKoinModules(apiModule(server.url("/")))
unloadKoinModules(appConfigModule(BuildConfig.CDN_API_URL, "holder", BuildConfig.VERSION_CODE))
loadKoinModules(listOf(apiModule(server.url("/")), appConfigModule(server.url("/").toString(), "holder", BuildConfig.VERSION_CODE)))

val configApi: AppConfigApi = get()

Expand Down Expand Up @@ -128,4 +141,4 @@ class CertificatePinTest: AutoCloseKoinTest() {
.add(JsonObjectJsonAdapter())
}
}
}
}
5 changes: 3 additions & 2 deletions verifier/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

def appVersionCode = System.getenv("GITHUB_RUN_NUMBER") != null ? System.getenv("GITHUB_RUN_NUMBER").toInteger() : 1000000
version = "2.3.1"
version = "2.3.2"
archivesBaseName = "verifier-v${version}-${appVersionCode}"

android {
Expand Down Expand Up @@ -37,6 +37,7 @@ android {
"{" +
"\"sha256/lR7gRvqDMW5nhsCMRPE7TKLq0tJkTWMxQ5HAzHCIfQ0=\"" +
"}"
buildConfigField "String", "CDN_API_URL", "\"https://verifier-api-cdn.coronacheck.nl/v5/\""
}

signingConfigs {
Expand Down Expand Up @@ -83,6 +84,7 @@ android {
"{" +
"\"sha256/lR7gRvqDMW5nhsCMRPE7TKLq0tJkTWMxQ5HAzHCIfQ0=\"" +
"}"
buildConfigField "String", "CDN_API_URL", "\"https://verifier-api-cdn.acc.coronacheck.nl/v5/\""
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
}
Expand Down Expand Up @@ -138,4 +140,3 @@ dependencies {

debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
}

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ open class VerifierApplication : SharedApplication() {
verifierModule("verifier"),
verifierIntroductionModule,
sharedModule,
appConfigModule("verifier", BuildConfig.VERSION_CODE),
appConfigModule(BuildConfig.CDN_API_URL, "verifier", BuildConfig.VERSION_CODE),
introductionModule,
*getAdditionalModules().toTypedArray(),
designModule,
Expand Down

0 comments on commit a065ebd

Please sign in to comment.