only open for tests/debug

This commit is contained in:
AdrianLxM 2021-03-14 19:42:02 +01:00
parent 3d93e4d84d
commit bf3fe19a4e
4 changed files with 14 additions and 4 deletions

View file

@ -55,6 +55,7 @@ buildscript {
// in the individual module build.gradle files
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
classpath 'com.hiya:jacoco-android:0.2'
}
}

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android'
apply plugin: "io.gitlab.arturbosch.detekt" // TODO move to `subprojects` section in global build.gradle
apply plugin: "org.jlleitschuh.gradle.ktlint" // TODO move to `subprojects` section in global build.gradle
@ -16,6 +17,10 @@ android {
}
}
allOpen {
annotation 'info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenClass'
}
detekt { // TODO move to `subprojects` section in global build.gradle
toolVersion = "1.15.0-RC2"
config = files("./detekt-config.yml") // TODO move to global space and use "../detekt-config.yml"

View file

@ -1,9 +1,11 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
import info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenForTesting
import java.security.SecureRandom
open class RandomByteGenerator {
@OpenForTesting
class RandomByteGenerator {
private val secureRandom = SecureRandom()
open fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes)
fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes)
}

View file

@ -1,10 +1,12 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
import com.google.crypto.tink.subtle.X25519
import info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenForTesting
open class X25519KeyGenerator {
@OpenForTesting
class X25519KeyGenerator {
open fun generatePrivateKey(): ByteArray = X25519.generatePrivateKey()
fun generatePrivateKey(): ByteArray = X25519.generatePrivateKey()
fun publicFromPrivate(privateKey: ByteArray): ByteArray = X25519.publicFromPrivate(privateKey)
fun computeSharedSecret(privateKey: ByteArray, publicKey: ByteArray): ByteArray =
X25519.computeSharedSecret(privateKey, publicKey)