Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #152 from corona-warn-app/dev
Browse files Browse the repository at this point in the history
0.8.2
  • Loading branch information
jakobmoellerdev authored Jun 4, 2020
2 parents d842f1a + b195623 commit 00513d1
Show file tree
Hide file tree
Showing 138 changed files with 5,036 additions and 3,124 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
steps:
- checkout
- install-ndk:
ndk-sha: "50250fcba479de477b45801e2699cca47f7e1267"
ndk-version: "android-ndk-r21b"
ndk-sha: "c81a5bcb4672a18d3647bf6898cd4dbcb978d0e8"
ndk-version: "android-ndk-r21c"
- restore-build-cache
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "Corona-Warn-App/build.gradle" }}-{{ checksum "Server-Protocol-Buffer/build.gradle" }}
Expand All @@ -36,4 +36,4 @@ workflows:
version: 2
workflow:
jobs:
- quickBuildReleaseWithTestsAndChecks
- quickBuildReleaseWithTestsAndChecks
49 changes: 32 additions & 17 deletions Corona-Warn-App/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'jacoco'

android {
ndkVersion "21.1.6352462"
ndkVersion "21.2.6472646"
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
applicationId 'de.rki.coronawarnapp'
minSdkVersion 23
targetSdkVersion 29
versionCode 8
versionName "0.8.1"
versionCode 9
versionName "0.8.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

buildConfigField "String", "DOWNLOAD_CDN_URL", "\"$DOWNLOAD_CDN_URL\""
Expand Down Expand Up @@ -142,12 +142,11 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDeviceReleaseUnitTest
}

dependencies {
api fileTree(dir: 'libs', include: ['play-services-nearby-18.0.2-eap.aar'])
implementation project(":Server-Protocol-Buffer")


// KOTLIN
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

// ANDROID STANDARD
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'com.google.android.material:material:1.1.0'
Expand All @@ -158,15 +157,13 @@ dependencies {
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.work:work-runtime-ktx:2.3.4'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.squareup.okhttp3:okhttp:4.7.2'
implementation 'com.google.android.play:core:1.7.3'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.guava:guava:29.0-android'

// QR
implementation('com.journeyapps:zxing-android-embedded:4.1.0') { transitive = false }
// noinspection GradleDependency - needed for SDK 23 compatibility, in combination with com.journeyapps:zxing-android-embedded:4.1.0
implementation 'com.google.zxing:core:3.3.0'
// implementation 'com.google.android.gms:play-services-nearby:18.0.2-eap'

// TESTING
testImplementation 'junit:junit:4.13'
testImplementation "org.mockito:mockito-core:3.3.3"
testImplementation('org.robolectric:robolectric:4.3.1') {
Expand All @@ -181,23 +178,41 @@ dependencies {
androidTestImplementation 'androidx.test.ext:truth:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'

implementation 'joda-time:joda-time:2.10.6'

// Play Services
implementation 'com.google.android.play:core:1.7.3'
implementation 'com.google.android.gms:play-services-base:17.2.1'
implementation 'com.google.android.gms:play-services-basement:17.2.1'
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.google.android.gms:play-services-tasks:17.0.2'
api fileTree(dir: 'libs', include: ['play-services-nearby-18.0.2-eap.aar'])

def room_version = "2.2.5"
// HTTP
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation ('com.squareup.retrofit2:converter-protobuf:2.9.0') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
implementation("com.squareup.okhttp3:logging-interceptor:4.7.2")
implementation 'com.squareup.okhttp3:okhttp:4.7.2'

// PERSISTENCE
def room_version = "2.2.5"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-guava:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.sqlite:sqlite:2.0.1"

implementation "androidx.security:security-crypto:1.0.0-rc02"
// UTILS
implementation project(":Server-Protocol-Buffer")
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.guava:guava:29.0-android'
implementation 'joda-time:joda-time:2.10.6'

// SECURITY
implementation "androidx.security:security-crypto:1.0.0-rc02"
implementation 'net.zetetic:android-database-sqlcipher:4.4.0'
implementation "androidx.sqlite:sqlite:2.0.1"
implementation 'org.conscrypt:conscrypt-android:2.4.0'

}
2 changes: 1 addition & 1 deletion Corona-Warn-App/config/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ performance:
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt']
SpreadOperator:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt']
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt', '**/CertificatePinnerFactory.kt']
UnnecessaryTemporaryInstantiation:
active: true

Expand Down
30 changes: 30 additions & 0 deletions Corona-Warn-App/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,33 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod

# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package de.rki.coronawarnapp.storage

import android.content.Context
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

/**
* ExposureSummaryDao test.
*/
@RunWith(AndroidJUnit4::class)
class ExposureSummaryDaoTest {
private lateinit var dao: ExposureSummaryDao
private lateinit var db: AppDatabase

@Before
fun setUp() {
val context = ApplicationProvider.getApplicationContext<Context>()
db = Room.inMemoryDatabaseBuilder(
context, AppDatabase::class.java).build()
dao = db.exposureSummaryDao()
}

/**
* Test Create / Read DB operations.
*/
@Test
fun testCROperations() {
runBlocking {
val testEntity1 = ExposureSummaryEntity().apply {
this.daysSinceLastExposure = 1
this.matchedKeyCount = 1
this.maximumRiskScore = 1
this.summationRiskScore = 1
}

val testEntity2 = ExposureSummaryEntity().apply {
this.daysSinceLastExposure = 2
this.matchedKeyCount = 2
this.maximumRiskScore = 2
this.summationRiskScore = 2
}

assertThat(dao.getExposureSummaryEntities().isEmpty()).isTrue()

val id1 = dao.insertExposureSummaryEntity(testEntity1)
var selectAll = dao.getExposureSummaryEntities()
var selectLast = dao.getLatestExposureSummary()
assertThat(dao.getExposureSummaryEntities().isEmpty()).isFalse()
assertThat(selectAll.size).isEqualTo(1)
assertThat(selectAll[0].id).isEqualTo(id1)
assertThat(selectLast).isNotNull()
assertThat(selectLast?.id).isEqualTo(id1)

val id2 = dao.insertExposureSummaryEntity(testEntity2)
selectAll = dao.getExposureSummaryEntities()
selectLast = dao.getLatestExposureSummary()
assertThat(selectAll.isEmpty()).isFalse()
assertThat(selectAll.size).isEqualTo(2)
assertThat(selectLast).isNotNull()
assertThat(selectLast?.id).isEqualTo(id2)
}
}

@After
fun closeDb() {
db.close()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package de.rki.coronawarnapp.storage.keycache

import android.content.Context
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import de.rki.coronawarnapp.storage.AppDatabase
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

/**
* KeyCacheDao test.
*/
@RunWith(AndroidJUnit4::class)
class KeyCacheDaoTest {
private lateinit var keyCacheDao: KeyCacheDao
private lateinit var db: AppDatabase

@Before
fun setUp() {
val context = ApplicationProvider.getApplicationContext<Context>()
db = Room.inMemoryDatabaseBuilder(
context, AppDatabase::class.java).build()
keyCacheDao = db.dateDao()
}

/**
* Test Create / Read / Delete DB operations.
*/
@Test
fun testCRDOperations() {
runBlocking {
val dates = KeyCacheEntity().apply {
this.id = "0"
this.path = "0"
this.type = 0
}
val hours = KeyCacheEntity().apply {
this.id = "1"
this.path = "1"
this.type = 1
}

assertThat(keyCacheDao.getAllEntries().isEmpty()).isTrue()

keyCacheDao.insertEntry(dates)
keyCacheDao.insertEntry(hours)

var all = keyCacheDao.getAllEntries()

assertThat(all.size).isEqualTo(2)

val selectedDates = keyCacheDao.getDates()
assertThat(selectedDates.size).isEqualTo(1)
assertThat(selectedDates[0].type).isEqualTo(0)
assertThat(selectedDates[0].id).isEqualTo(dates.id)

val selectedHours = keyCacheDao.getHours()
assertThat(selectedHours.size).isEqualTo(1)
assertThat(selectedHours[0].type).isEqualTo(1)
assertThat(selectedHours[0].id).isEqualTo(hours.id)

keyCacheDao.clearHours()

all = keyCacheDao.getAllEntries()
assertThat(all.size).isEqualTo(1)
assertThat(all[0].type).isEqualTo(0)

keyCacheDao.insertEntry(hours)

assertThat(keyCacheDao.getAllEntries().size).isEqualTo(2)

keyCacheDao.clear()

assertThat(keyCacheDao.getAllEntries().isEmpty()).isTrue()
}
}

@After
fun closeDb() {
db.close()
}
}
Loading

0 comments on commit 00513d1

Please sign in to comment.