🚧 Add strict filtering to preferences loader
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 18 Apr 2020 21:49:46 +0000 (23:49 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 18 Apr 2020 21:49:46 +0000 (23:49 +0200)
src/main/kotlin/net/pterodactylus/sone/core/PreferencesLoader.kt
src/test/kotlin/net/pterodactylus/sone/core/PreferencesLoaderTest.kt

index 32c35cb..62b60ae 100644 (file)
@@ -17,6 +17,7 @@ class PreferencesLoader(private val preferences: Preferences) {
                loadRequireFullAccess(configuration)
                loadFcpInterfaceActive(configuration)
                loadFcpFullAccessRequired(configuration)
+               loadStrictFiltering(configuration)
        }
 
        private fun loadInsertionDelay(configuration: Configuration) {
@@ -55,4 +56,8 @@ class PreferencesLoader(private val preferences: Preferences) {
                preferences.newFcpFullAccessRequired = fullAccessRequiredInteger?.let { FullAccessRequired.values()[it] }
        }
 
+       private fun loadStrictFiltering(configuration: Configuration) {
+               preferences.newStrictFiltering = configuration.getBooleanValue("Option/StrictFiltering").getValue(null)
+       }
+
 }
index 0cd7e6d..cb8df38 100644 (file)
@@ -28,6 +28,7 @@ class PreferencesLoaderTest {
                setupBooleanValue("RequireFullAccess", true)
                setupBooleanValue("ActivateFcpInterface", true)
                setupIntValue("FcpFullAccessRequired", 1)
+               setupBooleanValue("StrictFiltering", true)
        }
 
        private fun setupIntValue(optionName: String, value: Int) {
@@ -49,6 +50,7 @@ class PreferencesLoaderTest {
                assertThat(preferences.requireFullAccess, equalTo(true))
                assertThat(preferences.fcpInterfaceActive, equalTo(true))
                assertThat(preferences.fcpFullAccessRequired, equalTo(FullAccessRequired.WRITING))
+               assertThat(preferences.strictFiltering, equalTo(true))
        }
 
        @Test