Skip to content

Commit

Permalink
Update reference configuration regarding scanner options
Browse files Browse the repository at this point in the history
Extend the 'options' section to demonstrate the structure of
configuration options that are now supported.

Enhance the test for OrtConfiguration to check that the new structure
is processed correctly and that properties can be overridden via
command line options.

Signed-off-by: Oliver Heger <[email protected]>
  • Loading branch information
oheger-bosch committed Jan 26, 2021
1 parent e7950d2 commit 1b7f147
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
13 changes: 12 additions & 1 deletion model/src/test/assets/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,18 @@ ort {
}

options {
// A map of maps from scanner class names to scanner-specific key-value pairs.
// A map from scanner class names to scanner-specific ScannerOption objects.
"ScanCode": {
compatibility {
minVersion = "3.1.0"
maxVersion = "3.3"
}

properties: {
commandLine = "--copyright --license --info --timeout 300"
debugCommandLine = "--license-diag"
}
}
}

storages {
Expand Down
37 changes: 15 additions & 22 deletions model/src/test/kotlin/config/OrtConfigurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,42 +111,35 @@ class OrtConfigurationTest : WordSpec({
}

"correctly prioritize the sources" {
val configFile = createTestConfig(
"""
ort {
scanner {
storages {
postgresStorage {
url = "postgresql://your-postgresql-server:5444/your-database"
schema = schema
username = username
password = password
}
}
}
}
""".trimIndent()
)

val env = mapOf("ort.scanner.storages.postgresStorage.password" to "envPassword")
val configFile = File("src/test/assets/reference.conf")
val env = mapOf("ort.scanner.storages.postgres.password" to "envPassword")

withEnvironment(env) {
val config = OrtConfiguration.load(
args = mapOf(
"ort.scanner.storages.postgresStorage.schema" to "argsSchema",
"ort.scanner.storages.postgresStorage.password" to "argsPassword",
"other.property" to "someValue"
"ort.scanner.storages.postgres.schema" to "argsSchema",
"ort.scanner.storages.postgres.password" to "argsPassword",
"other.property" to "someValue",
"ort.scanner.options.ScanCode.compatibility.maxVersion" to "4.0",
"ort.scanner.options.ScanCode.properties.debugCommandLine" to "--consolidate"
),
configFile = configFile
)

config.scanner?.storages shouldNotBeNull {
val postgresStorage = this["postgresStorage"]
val postgresStorage = this["postgres"]
postgresStorage.shouldBeInstanceOf<PostgresStorageConfiguration>()
postgresStorage.username shouldBe "username"
postgresStorage.schema shouldBe "argsSchema"
postgresStorage.password shouldBe "envPassword"
}

val scanCodeOptions = config.scanner?.options?.get("ScanCode")
scanCodeOptions.shouldNotBeNull()
scanCodeOptions.compatibility?.minVersion shouldBe "3.1.0"
scanCodeOptions.compatibility?.maxVersion shouldBe "4.0"
scanCodeOptions.properties?.get("commandLine") shouldBe "--copyright --license --info --timeout 300"
scanCodeOptions.properties?.get("debugCommandLine") shouldBe "--consolidate"
}
}

Expand Down

0 comments on commit 1b7f147

Please sign in to comment.