Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Make the domain a source of defaults #2057

Merged
merged 1 commit into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ object Authorization {
* @property host the host part of base Corellium API url "https://[host]/api/v1".
*/
data class Credentials(
val host: String,
val username: String,
val password: String,
val host: String = "",
val username: String = "",
val password: String = "",
)

val Empty = Credentials()

/**
* The authorization API call.
* The successful return is making the rest of API functions available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,18 @@ class RunTestCorelliumAndroidCommand :
}

private fun defaultConfig() = Config().apply {
project = "Default Project"
auth = "corellium_auth.yml"
apks = emptyList()
maxTestShards = 1
localResultsDir = null
obfuscate = false
gpuAcceleration = true
scanPreviousDurations = 10
project = Args.DEFAULT_PROJECT
auth = Args.AUTH_FILE
this += Args.Default
}

private operator fun Config.plusAssign(args: Args) {
apks = args.apks
maxTestShards = args.maxShardsCount
localResultsDir = args.outputDir
obfuscate = args.obfuscateDumpShards
gpuAcceleration = args.gpuAcceleration
scanPreviousDurations = args.scanPreviousDurations
}

private fun RunTestCorelliumAndroidCommand.yamlConfig(): Config =
Expand All @@ -182,7 +186,7 @@ private fun RunTestCorelliumAndroidCommand.createArgs() = Args(
credentials = loadYaml(config.auth!!),
apks = config.apks!!,
maxShardsCount = config.maxTestShards!!,
outputDir = config.localResultsDir ?: Args.DefaultOutputDir.new,
outputDir = config.localResultsDir!!,
obfuscateDumpShards = config.obfuscate!!,
gpuAcceleration = config.gpuAcceleration!!,
scanPreviousDurations = config.scanPreviousDurations!!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,21 @@ object RunTestCorelliumAndroid {
* @param scanPreviousDurations Scan the specified amount of JUnitReport.xml files to obtain test cases durations necessary for optimized sharding. The [outputDir] is used for searching JUnit reports.
*/
data class Args(
val credentials: Authorization.Credentials,
val apks: List<Apk.App>,
val maxShardsCount: Int,
val credentials: Authorization.Credentials = Authorization.Empty,
val apks: List<Apk.App> = emptyList(),
val maxShardsCount: Int = 1,
val obfuscateDumpShards: Boolean = false,
val outputDir: String = DefaultOutputDir.new,
val gpuAcceleration: Boolean = true,
val scanPreviousDurations: Int = 10,
) {

companion object {
val Default = Args()
const val DEFAULT_PROJECT = "Default Project"
const val AUTH_FILE = "corellium_auth.yml"
}

/**
* Default output directory scheme.
*
Expand Down