You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
3.3 KiB
74 lines
3.3 KiB
package de.superx.common; |
|
|
|
import java.io.File; |
|
import java.io.FileNotFoundException; |
|
import java.io.FileReader; |
|
import java.io.IOException; |
|
import java.io.Reader; |
|
import java.sql.Connection; |
|
import java.sql.PreparedStatement; |
|
import java.sql.ResultSet; |
|
import java.sql.SQLException; |
|
import java.sql.Statement; |
|
import java.time.Year; |
|
import java.util.Locale; |
|
|
|
import org.apache.commons.csv.CSVFormat; |
|
import org.apache.commons.csv.CSVRecord; |
|
import org.h2.jdbc.JdbcConnection; |
|
import org.junit.Assert; |
|
import org.junit.Before; |
|
import org.junit.Test; |
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
import org.springframework.mock.web.MockHttpServletRequest; |
|
import org.springframework.test.context.ContextConfiguration; |
|
|
|
import de.superx.BaseDbTest; |
|
import de.superx.TestApplicationConfigPg; |
|
import de.superx.TestUtils; |
|
import de.superx.servlet.UserInitializer; |
|
|
|
//@ContextConfiguration(classes = { TestApplicationConfigPg.class }) |
|
public class JSessionIdLeakTest extends BaseDbTest { |
|
|
|
// in der Oberfläche verbirgt sich hinter der Auswahl "Köpfe" eine SQL-Filterklausel |
|
private static final String KOEPFE = "KoF_1"; |
|
// Da die Musterdaten jährlich verjüngt werden, sollte das Auswertungssemester dynamisch ermittelt werden |
|
private static final String LETZTES_WINTERSEMESTER = (Year.now().getValue() - 1) + "2"; |
|
private static final String LETZTES_SOMMERSEMESTER = (Year.now().getValue() - 1) + "1"; |
|
private static final String AKTUELLES_WINTERSEMESTER = Year.now().getValue() + "2"; |
|
private static final String AKTUELLES_SOMMERSEMESTER = Year.now().getValue() + "2"; |
|
private static final String AKTUELLE_ZAHLEN_STUDIERENDE = "6"; |
|
private static final String AKTUELLE_ZAHLEN_PRUEFUNGEN = "4"; |
|
private static final String BESTANDEN = "BE"; |
|
private static final String HAUPTPRUEFUNG = "2"; |
|
private static final String MANDANTEN_ID = "test"; |
|
private static final String USER_NAME = "admin"; |
|
private static final String SOS_MASKEN_PATH = String.join(File.separator, |
|
"superx", "WEB-INF", "conf", "edustore", "db", "module", "sos", "masken"); |
|
private SxUser sxUser = null; |
|
|
|
@Before |
|
public void setupTest() throws Exception { |
|
try (Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement();) { |
|
sxUser = TestUtils.initUser(conn, stmt); |
|
} |
|
} |
|
|
|
@Test |
|
public void testJSessionIdNotInXml() throws Exception { |
|
JdbcTemplate jt = new JdbcTemplate(dataSource); |
|
Integer maskenTid = Integer.valueOf(160440); |
|
Maske maske = new Maske(MANDANTEN_ID, sxUser, maskenTid, Locale.GERMANY); |
|
MockHttpServletRequest request = new MockHttpServletRequest(); |
|
request.addParameter("Köpfe oder Fälle ?", KOEPFE); // sollte der Wert für "Köpfe" sein |
|
request.addParameter("Stichtag", AKTUELLE_ZAHLEN_STUDIERENDE); // das ist die id für den Bestand "aktuelle Zahlen" |
|
request.addParameter("Seit Semester", LETZTES_SOMMERSEMESTER); |
|
request.addParameter("Bis Semester", AKTUELLES_WINTERSEMESTER); |
|
maske.setFieldDefaults(sxUser, request, true); |
|
maske.runQuery(sxUser, request, null); |
|
String xmlResult = maske.getMaskXml(sxUser, true); |
|
Assert.assertFalse("XML sollte nicht das Attribut 'jsessionid' enthalten", xmlResult.toLowerCase().contains("jsessionid")); |
|
} |
|
|
|
} |