@Deprecated private InvocationContext invokeWebRequest(String uri, String... parameters) { // This is not testing servlet, so any HTTP method suffices WebRequest request = new PostMethodWebRequest(SIMULATION_BASE_URL + uri); // TODO remove this portion once front-end migration is finished // Reason: CSRF protection is not part of action tests if (Const.SystemParams.PAGES_REQUIRING_ORIGIN_VALIDATION.contains(uri)) { request.setHeaderField("referer", SIMULATION_BASE_URL); String sessionId = sc.getSession(true).getId(); String token = StringHelper.encrypt(sessionId); request.setParameter(Const.ParamsNames.SESSION_TOKEN, token); } Map<String, List<String>> paramMultiMap = new HashMap<>(); for (int i = 0; i < parameters.length; i = i + 2) { paramMultiMap.computeIfAbsent(parameters[i], k -> new ArrayList<>()).add(parameters[i + 1]); } paramMultiMap.forEach((key, values) -> request.setParameter(key, values.toArray(new String[0]))); try { return sc.newInvocation(request); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Returns the session to be used by the next request. * @param create if true, will create a new session if no valid session is defined. * @since 1.6 */ public HttpSession getSession( boolean create ) { return getClient().getSession( create ); }
/** * Returns the session to be used by the next request. * @param create if true, will create a new session if no valid session is defined. * @since 1.6 */ public HttpSession getSession( boolean create ) { return getClient().getSession( create ); }
/** * Returns the session to be used by the next request. * @param create if true, will create a new session if no valid session is defined. * @since 1.6 */ public HttpSession getSession( boolean create ) { return getClient().getSession( create ); }