This repository was archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Application signing validation (#19)
* Improve Application signing validation * fix: configuration cache wasn't happy * if a config doesn't have a signingConfig threat it as default
- Loading branch information
1 parent
0a5bcd5
commit 4b682be
Showing
5 changed files
with
176 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 17 additions & 11 deletions
28
src/main/kotlin/io/github/flank/gradle/utils/keystoreUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import java.io.File | ||
import org.junit.Test | ||
import strikt.api.expectThat | ||
import strikt.assertions.contains | ||
|
||
class SigningValidationTest : GradleTest() { | ||
@Test | ||
fun warnIfDefaultSigning() { | ||
projectFromResources("app") | ||
|
||
val build = gradleRunner("flankRunDebug").forwardOutput().build() | ||
|
||
expectThat(build.output) { contains("Warning: The debug keystore should be set") } | ||
} | ||
|
||
@Test | ||
fun failIfDefaultSigningAndHermeticTests() { | ||
projectFromResources("app") | ||
File(testProjectDir.root, "build.gradle.kts") | ||
.appendText( | ||
""" | ||
simpleFlank { | ||
hermeticTests.set(true) | ||
} | ||
""".trimIndent()) | ||
|
||
gradleRunner("flankRunDebug").forwardOutput().buildAndFail() | ||
} | ||
|
||
@Test | ||
fun failIfNoSigningAndHermeticTests() { | ||
projectFromResources("app") | ||
File(testProjectDir.root, "build.gradle.kts") | ||
.appendText( | ||
""" | ||
android { | ||
testBuildType = "beta" | ||
buildTypes { | ||
create("beta") | ||
} | ||
} | ||
simpleFlank { | ||
hermeticTests.set(true) | ||
} | ||
""".trimIndent()) | ||
|
||
gradleRunner("flankRunDebug").forwardOutput().buildAndFail() | ||
} | ||
|
||
@Test | ||
fun workFineIfCustomSigning() { | ||
projectFromResources("app") | ||
File(testProjectDir.root, "build.gradle.kts") | ||
.appendText( | ||
""" | ||
android { | ||
signingConfigs { | ||
named("debug") { | ||
storeFile = File(projectDir, "someKeystore") | ||
keyAlias = "debugKey" | ||
keyPassword = "debugKeystore" | ||
storePassword = "debugKeystore" | ||
} | ||
} | ||
buildTypes { | ||
getByName("debug") { | ||
signingConfig = signingConfigs.getByName("debug") | ||
} | ||
} | ||
} | ||
simpleFlank { | ||
hermeticTests.set(true) | ||
} | ||
""".trimIndent()) | ||
|
||
val build = gradleRunner("flankRunDebug").forwardOutput().build() | ||
|
||
expectThat(build.output) { not { contains("The debug keystore should be set") } } | ||
} | ||
|
||
@Test | ||
fun workFineNotOnlyWithDebugSigningConfig() { | ||
projectFromResources("app") | ||
File(testProjectDir.root, "build.gradle.kts") | ||
.appendText( | ||
""" | ||
android { | ||
signingConfigs { | ||
create("mySigning") { | ||
storeFile = File(projectDir, "someKeystore") | ||
keyAlias = "debugKey" | ||
keyPassword = "debugKeystore" | ||
storePassword = "debugKeystore" | ||
} | ||
} | ||
buildTypes { | ||
getByName("debug") { | ||
signingConfig = signingConfigs.getByName("mySigning") | ||
} | ||
} | ||
} | ||
simpleFlank { | ||
hermeticTests.set(true) | ||
} | ||
""".trimIndent()) | ||
|
||
gradleRunner("flankRunDebug").forwardOutput().build() | ||
} | ||
} |
Binary file not shown.