From bec3d13eb0a0aa055b2fb3cefe0ce95f6428959c Mon Sep 17 00:00:00 2001 From: Manuel Soulier Date: Thu, 30 Nov 2023 02:13:43 +0100 Subject: [PATCH] fix: GuiInputSecurity test --- .../fr/insee/arc/utils/security/GuiInputSecurityTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arc-utils/src/test/java/fr/insee/arc/utils/security/GuiInputSecurityTest.java b/arc-utils/src/test/java/fr/insee/arc/utils/security/GuiInputSecurityTest.java index 84435da87..b6b00de5b 100644 --- a/arc-utils/src/test/java/fr/insee/arc/utils/security/GuiInputSecurityTest.java +++ b/arc-utils/src/test/java/fr/insee/arc/utils/security/GuiInputSecurityTest.java @@ -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; @@ -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 @@ -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 guiInputsNull=null; + assertNull(GuiInputSecurity.formatAsDatabaseIdentifier(guiInputsNull)); List guiInputs = Arrays.asList("__var_table_metier$$", "drop database toto;"); List guiInputsReformat = GuiInputSecurity.formatAsDatabaseIdentifier(guiInputs);