package de.superx.sec; import org.junit.Assert; import org.junit.Test; public class StringCheckTest { // this input check explicitly allows input, that caused an injection in some special cases(!) // so it has to be assured, that it is only configured contexts, where this is not the case private static String[] SAMPLES_FOR_VALID_FORMAT = {"", "135€", "Marçel", "Søren", "Rathausstraße", "info@mailinator.com", "line 1\r\nline 2", "test^csv^upload^functionality", "1,2,3,4,5", "sp_get_keylist_str($$bla1$$,$$bla2$$)::INT"}; private static String[] SAMPLES_FOR_INVALID_FORMAT = {";"}; @SuppressWarnings("static-method") @Test public void testConfirmFormat() { StringCheck testee = new StringCheck(); for (String sample : SAMPLES_FOR_VALID_FORMAT) { Assert.assertTrue("expected '" + sample + "' to be valid pattern", testee.check(sample)); } for (String sample : SAMPLES_FOR_INVALID_FORMAT) { Assert.assertFalse("expected '" + sample + "' to be invalid pattern", testee.check(sample)); } } }