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"
|
||||
|
||||
// Embed git commit SHA for the About card in Settings
|
||||
val gitSha = providers.exec {
|
||||
val gitSha =
|
||||
providers.exec {
|
||||
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||
}.standardOutput.asText.get().trim()
|
||||
buildConfigField("String", "GIT_SHA", "\"$gitSha\"")
|
||||
@@ -29,7 +30,8 @@ android {
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
val isReleaseBuild = gradle.startParameter.taskNames.any { name ->
|
||||
val isReleaseBuild =
|
||||
gradle.startParameter.taskNames.any { name ->
|
||||
name.contains("Release", ignoreCase = true) || name == "build"
|
||||
}
|
||||
|
||||
@@ -119,13 +121,14 @@ dependencies {
|
||||
implementation(libs.androidx.compose.material.icons.extended)
|
||||
// Tooling
|
||||
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||
debugImplementation(libs.leakcanary.android)
|
||||
// Instrumented tests
|
||||
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
||||
|
||||
// Networking
|
||||
implementation(libs.okhttp)
|
||||
implementation(libs.okhttp.logging)
|
||||
debugImplementation(libs.okhttp.logging)
|
||||
implementation(libs.retrofit)
|
||||
implementation(libs.retrofit.converter.gson)
|
||||
implementation(libs.gson)
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.m57.hermescontrol.data.local
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
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.ThemePreference
|
||||
import com.m57.hermescontrol.theme.ThemePreset
|
||||
@@ -68,16 +68,13 @@ object AuthManager {
|
||||
synchronized(this) {
|
||||
if (prefs != null) return
|
||||
val masterKey =
|
||||
MasterKey
|
||||
.Builder(context.applicationContext)
|
||||
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
|
||||
.build()
|
||||
MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
|
||||
|
||||
prefs =
|
||||
EncryptedSharedPreferences.create(
|
||||
context.applicationContext,
|
||||
PREFS_FILE,
|
||||
masterKey,
|
||||
context.applicationContext,
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM,
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.m57.hermescontrol.data.local
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.security.crypto.EncryptedSharedPreferences
|
||||
import androidx.security.crypto.MasterKey
|
||||
import androidx.security.crypto.MasterKeys
|
||||
import io.mockk.*
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -31,18 +31,16 @@ class AuthManagerTest {
|
||||
mockkStatic(EncryptedSharedPreferences::class)
|
||||
every {
|
||||
EncryptedSharedPreferences.create(
|
||||
any<Context>(),
|
||||
any<String>(),
|
||||
any<MasterKey>(),
|
||||
any<String>(),
|
||||
any<Context>(),
|
||||
any<EncryptedSharedPreferences.PrefKeyEncryptionScheme>(),
|
||||
any<EncryptedSharedPreferences.PrefValueEncryptionScheme>(),
|
||||
)
|
||||
} returns mockPrefs
|
||||
|
||||
// Mock MasterKey.Builder constructor and its build method
|
||||
mockkConstructor(MasterKey.Builder::class)
|
||||
val mockMasterKey = mockk<MasterKey>(relaxed = true)
|
||||
every { anyConstructed<MasterKey.Builder>().build() } returns mockMasterKey
|
||||
mockkStatic(MasterKeys::class)
|
||||
every { MasterKeys.getOrCreate(any()) } returns "mockMasterKey"
|
||||
|
||||
// Reset prefs singleton instance using reflection
|
||||
val field = AuthManager::class.java.getDeclaredField("prefs")
|
||||
|
||||
@@ -18,10 +18,11 @@ kotlin = "2.3.20"
|
||||
ksp = "2.3.9"
|
||||
nav3Core = "1.0.1"
|
||||
lifecycleViewmodelNav3 = "2.10.0"
|
||||
leakcanary = "2.14"
|
||||
okhttp = "4.12.0"
|
||||
retrofit = "2.11.0"
|
||||
gson = "2.11.0"
|
||||
securityCrypto = "1.1.0-alpha06"
|
||||
securityCrypto = "1.0.0"
|
||||
mockk = "1.13.12"
|
||||
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-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" }
|
||||
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanary" }
|
||||
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
|
||||
mockk-android = { module = "io.mockk:mockk-android", version.ref = "mockk" }
|
||||
androidx-navigation3-runtime = { module = "androidx.navigation3:navigation3-runtime", version.ref = "nav3Core" }
|
||||
|
||||
Reference in New Issue
Block a user