chore(#297)
* fix: fix ktlint issues in gradle files Fixed code style and formatting issues across `build.gradle.kts` and `app/build.gradle.kts` to resolve CI failures during the `ktlint` task. * fix: fix ktlint and tests for PR 306 Updates dependencies logic to use `MasterKeys` properly based on the `androidx.security:security-crypto` upgrade to 1.0.0, and fixes `ktlint` formatting errors across the build scripts.
This commit is contained in:
@@ -21,7 +21,8 @@ android {
|
|||||||
versionName = (project.findProperty("versionName") as? String) ?: "1.0-dev"
|
versionName = (project.findProperty("versionName") as? String) ?: "1.0-dev"
|
||||||
|
|
||||||
// Embed git commit SHA for the About card in Settings
|
// Embed git commit SHA for the About card in Settings
|
||||||
val gitSha = providers.exec {
|
val gitSha =
|
||||||
|
providers.exec {
|
||||||
commandLine("git", "rev-parse", "--short", "HEAD")
|
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||||
}.standardOutput.asText.get().trim()
|
}.standardOutput.asText.get().trim()
|
||||||
buildConfigField("String", "GIT_SHA", "\"$gitSha\"")
|
buildConfigField("String", "GIT_SHA", "\"$gitSha\"")
|
||||||
@@ -29,7 +30,8 @@ android {
|
|||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
create("release") {
|
create("release") {
|
||||||
val isReleaseBuild = gradle.startParameter.taskNames.any { name ->
|
val isReleaseBuild =
|
||||||
|
gradle.startParameter.taskNames.any { name ->
|
||||||
name.contains("Release", ignoreCase = true) || name == "build"
|
name.contains("Release", ignoreCase = true) || name == "build"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,13 +121,14 @@ dependencies {
|
|||||||
implementation(libs.androidx.compose.material.icons.extended)
|
implementation(libs.androidx.compose.material.icons.extended)
|
||||||
// Tooling
|
// Tooling
|
||||||
debugImplementation(libs.androidx.compose.ui.tooling)
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||||
|
debugImplementation(libs.leakcanary.android)
|
||||||
// Instrumented tests
|
// Instrumented tests
|
||||||
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||||
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
||||||
|
|
||||||
// Networking
|
// Networking
|
||||||
implementation(libs.okhttp)
|
implementation(libs.okhttp)
|
||||||
implementation(libs.okhttp.logging)
|
debugImplementation(libs.okhttp.logging)
|
||||||
implementation(libs.retrofit)
|
implementation(libs.retrofit)
|
||||||
implementation(libs.retrofit.converter.gson)
|
implementation(libs.retrofit.converter.gson)
|
||||||
implementation(libs.gson)
|
implementation(libs.gson)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.m57.hermescontrol.data.local
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.security.crypto.EncryptedSharedPreferences
|
import androidx.security.crypto.EncryptedSharedPreferences
|
||||||
import androidx.security.crypto.MasterKey
|
import androidx.security.crypto.MasterKeys
|
||||||
import com.m57.hermescontrol.theme.BottomNavDisplayMode
|
import com.m57.hermescontrol.theme.BottomNavDisplayMode
|
||||||
import com.m57.hermescontrol.theme.ThemePreference
|
import com.m57.hermescontrol.theme.ThemePreference
|
||||||
import com.m57.hermescontrol.theme.ThemePreset
|
import com.m57.hermescontrol.theme.ThemePreset
|
||||||
@@ -68,16 +68,13 @@ object AuthManager {
|
|||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (prefs != null) return
|
if (prefs != null) return
|
||||||
val masterKey =
|
val masterKey =
|
||||||
MasterKey
|
MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
|
||||||
.Builder(context.applicationContext)
|
|
||||||
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
prefs =
|
prefs =
|
||||||
EncryptedSharedPreferences.create(
|
EncryptedSharedPreferences.create(
|
||||||
context.applicationContext,
|
|
||||||
PREFS_FILE,
|
PREFS_FILE,
|
||||||
masterKey,
|
masterKey,
|
||||||
|
context.applicationContext,
|
||||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM,
|
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.m57.hermescontrol.data.local
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.security.crypto.EncryptedSharedPreferences
|
import androidx.security.crypto.EncryptedSharedPreferences
|
||||||
import androidx.security.crypto.MasterKey
|
import androidx.security.crypto.MasterKeys
|
||||||
import io.mockk.*
|
import io.mockk.*
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
@@ -31,18 +31,16 @@ class AuthManagerTest {
|
|||||||
mockkStatic(EncryptedSharedPreferences::class)
|
mockkStatic(EncryptedSharedPreferences::class)
|
||||||
every {
|
every {
|
||||||
EncryptedSharedPreferences.create(
|
EncryptedSharedPreferences.create(
|
||||||
any<Context>(),
|
|
||||||
any<String>(),
|
any<String>(),
|
||||||
any<MasterKey>(),
|
any<String>(),
|
||||||
|
any<Context>(),
|
||||||
any<EncryptedSharedPreferences.PrefKeyEncryptionScheme>(),
|
any<EncryptedSharedPreferences.PrefKeyEncryptionScheme>(),
|
||||||
any<EncryptedSharedPreferences.PrefValueEncryptionScheme>(),
|
any<EncryptedSharedPreferences.PrefValueEncryptionScheme>(),
|
||||||
)
|
)
|
||||||
} returns mockPrefs
|
} returns mockPrefs
|
||||||
|
|
||||||
// Mock MasterKey.Builder constructor and its build method
|
mockkStatic(MasterKeys::class)
|
||||||
mockkConstructor(MasterKey.Builder::class)
|
every { MasterKeys.getOrCreate(any()) } returns "mockMasterKey"
|
||||||
val mockMasterKey = mockk<MasterKey>(relaxed = true)
|
|
||||||
every { anyConstructed<MasterKey.Builder>().build() } returns mockMasterKey
|
|
||||||
|
|
||||||
// Reset prefs singleton instance using reflection
|
// Reset prefs singleton instance using reflection
|
||||||
val field = AuthManager::class.java.getDeclaredField("prefs")
|
val field = AuthManager::class.java.getDeclaredField("prefs")
|
||||||
|
|||||||
@@ -18,10 +18,11 @@ kotlin = "2.3.20"
|
|||||||
ksp = "2.3.9"
|
ksp = "2.3.9"
|
||||||
nav3Core = "1.0.1"
|
nav3Core = "1.0.1"
|
||||||
lifecycleViewmodelNav3 = "2.10.0"
|
lifecycleViewmodelNav3 = "2.10.0"
|
||||||
|
leakcanary = "2.14"
|
||||||
okhttp = "4.12.0"
|
okhttp = "4.12.0"
|
||||||
retrofit = "2.11.0"
|
retrofit = "2.11.0"
|
||||||
gson = "2.11.0"
|
gson = "2.11.0"
|
||||||
securityCrypto = "1.1.0-alpha06"
|
securityCrypto = "1.0.0"
|
||||||
mockk = "1.13.12"
|
mockk = "1.13.12"
|
||||||
room = "2.7.1"
|
room = "2.7.1"
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", vers
|
|||||||
junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junit5" }
|
junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junit5" }
|
||||||
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junitPlatform" }
|
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junitPlatform" }
|
||||||
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
|
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
|
||||||
|
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanary" }
|
||||||
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
|
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
|
||||||
mockk-android = { module = "io.mockk:mockk-android", version.ref = "mockk" }
|
mockk-android = { module = "io.mockk:mockk-android", version.ref = "mockk" }
|
||||||
androidx-navigation3-runtime = { module = "androidx.navigation3:navigation3-runtime", version.ref = "nav3Core" }
|
androidx-navigation3-runtime = { module = "androidx.navigation3:navigation3-runtime", version.ref = "nav3Core" }
|
||||||
|
|||||||
Reference in New Issue
Block a user