Skip to content

Commit

Permalink
fix: GuiInputSecurity test
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolife999 committed Nov 30, 2023
1 parent 85c55cf commit bec3d13
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.insee.arc.utils.security;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
Expand All @@ -20,6 +21,9 @@ public void testServiceHashFileNameIsUtilityClass() throws NoSuchMethodException
@Test
public void testFormatAsDatabaseIdentifier() {

String input = null;
assertNull(GuiInputSecurity.formatAsDatabaseIdentifier(input));

assertEquals("var_table_metier",GuiInputSecurity.formatAsDatabaseIdentifier("var_table_metier"));

// remove space and ; and other chars
Expand All @@ -33,6 +37,8 @@ public void testFormatAsDatabaseIdentifier() {
assertEquals("var_table_metier",GuiInputSecurity.formatAsDatabaseIdentifier("$var_table_metier_$"));
assertEquals("var_table_metier",GuiInputSecurity.formatAsDatabaseIdentifier("$_$var_table_metier$__;"));

List<String> guiInputsNull=null;
assertNull(GuiInputSecurity.formatAsDatabaseIdentifier(guiInputsNull));

List<String> guiInputs = Arrays.asList("__var_table_metier$$", "drop database toto;");
List<String> guiInputsReformat = GuiInputSecurity.formatAsDatabaseIdentifier(guiInputs);
Expand Down

0 comments on commit bec3d13

Please sign in to comment.