-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...a/org/bonitasoft/console/common/server/preferences/properties/SecurityPropertiesTest.java
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,47 @@ | ||
/** | ||
* Copyright (C) 2024 Bonitasoft S.A. | ||
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble | ||
* This library is free software; you can redistribute it and/or modify it under the terms | ||
* of the GNU Lesser General Public License as published by the Free Software Foundation | ||
* version 2.1 of the License. | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License along with this | ||
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth | ||
* Floor, Boston, MA 02110-1301, USA. | ||
**/ | ||
package org.bonitasoft.console.common.server.preferences.properties; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.bonitasoft.console.common.server.preferences.properties.SecurityProperties.SANITIZER_PROTECTION; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.spy; | ||
|
||
import org.junit.Test; | ||
|
||
public class SecurityPropertiesTest { | ||
|
||
private final SecurityProperties securityProperties = spy(new SecurityProperties()); | ||
|
||
@Test | ||
public void invalid_or_absent_sanitizer_conf_should_be_disabled() { | ||
doReturn(null).when(securityProperties).getPlatformProperty(SANITIZER_PROTECTION); | ||
assertThat(securityProperties.isSanitizerProtectionEnabled()).isFalse(); | ||
|
||
doReturn("").when(securityProperties).getPlatformProperty(SANITIZER_PROTECTION); | ||
assertThat(securityProperties.isSanitizerProtectionEnabled()).isFalse(); | ||
|
||
doReturn("false").when(securityProperties).getPlatformProperty(SANITIZER_PROTECTION); | ||
assertThat(securityProperties.isSanitizerProtectionEnabled()).isFalse(); | ||
} | ||
|
||
@Test | ||
public void sanitizer_should_be_enabled_for_true_value_whatever_the_case() { | ||
doReturn("true").when(securityProperties).getPlatformProperty(SANITIZER_PROTECTION); | ||
assertThat(securityProperties.isSanitizerProtectionEnabled()).isTrue(); | ||
|
||
doReturn("trUE").when(securityProperties).getPlatformProperty(SANITIZER_PROTECTION); | ||
assertThat(securityProperties.isSanitizerProtectionEnabled()).isTrue(); | ||
} | ||
} |