HttpRequestUtils { public static void filterAdminOnlyFlowParams(final UserManager userManager, final ExecutionOptions options, final User user) throws ExecutorManagerException { if (options == null || options.getFlowParameters() == null) { return; } final Map<String, String> params = options.getFlowParameters(); if (!hasPermission(userManager, user, Type.ADMIN)) { params.remove(ExecutionOptions.FLOW_PRIORITY); params.remove(ExecutionOptions.USE_EXECUTOR); } else { validateIntegerParam(params, ExecutionOptions.FLOW_PRIORITY); validateIntegerParam(params, ExecutionOptions.USE_EXECUTOR); } }  static ExecutionOptions parseFlowOptions(final HttpServletRequest req,
      final String flowName); static void filterAdminOnlyFlowParams(final UserManager userManager,
      final ExecutionOptions options, final User user); static boolean validateIntegerParam(final Map<String, String> params,
      final String paramName); static boolean hasPermission(final UserManager userManager, final User user,
      final Permission.Type type); static boolean hasParam(final HttpServletRequest request, final String param); static String getParam(final HttpServletRequest request, final String name); static String getParam(final HttpServletRequest request, final String name,
      final String defaultVal); static int getIntParam(final HttpServletRequest request, final String name); static int getIntParam(final HttpServletRequest request, final String name,
      final int defaultVal); static boolean getBooleanParam(final HttpServletRequest request, final String name); static boolean getBooleanParam(final HttpServletRequest request,
      final String name, final boolean defaultVal); static long getLongParam(final HttpServletRequest request, final String name); static long getLongParam(final HttpServletRequest request, final String name,
      final long defaultVal); static Map<String, String> getParamGroup(final HttpServletRequest request,
      final String groupName); static Object getJsonBody(final HttpServletRequest request); static String getBody(final HttpServletRequest request); static final String PARAM_SLA_EMAILS; static final String PARAM_SLA_SETTINGS; }
@Test public void TestFilterNonAdminOnlyFlowParams() throws IOException, ExecutorManagerException, UserManagerException { final ExecutableFlow flow = createExecutableFlow(); final UserManager manager = TestUtils.createTestXmlUserManager(); final User user = manager.getUser("testUser", "testUser"); HttpRequestUtils.filterAdminOnlyFlowParams(manager, flow.getExecutionOptions(), user); Assert.assertFalse(flow.getExecutionOptions().getFlowParameters() .containsKey(ExecutionOptions.FLOW_PRIORITY)); Assert.assertFalse(flow.getExecutionOptions().getFlowParameters() .containsKey(ExecutionOptions.USE_EXECUTOR)); }
@Test public void TestFilterAdminOnlyFlowParams() throws IOException, ExecutorManagerException, UserManagerException { final ExecutableFlow flow = createExecutableFlow(); final UserManager manager = TestUtils.createTestXmlUserManager(); final User user = manager.getUser("testAdmin", "testAdmin"); HttpRequestUtils.filterAdminOnlyFlowParams(manager, flow.getExecutionOptions(), user); Assert.assertTrue(flow.getExecutionOptions().getFlowParameters() .containsKey(ExecutionOptions.FLOW_PRIORITY)); Assert.assertTrue(flow.getExecutionOptions().getFlowParameters() .containsKey(ExecutionOptions.USE_EXECUTOR)); }