@Test(dataProvider = "provideData") public void testPreRewrite(String allowedString, String disallowedString, String user, boolean success) throws Exception { if (allowedString != null) { conf.set(UserBasedQueryHook.ALLOWED_USERS, allowedString); } else { conf.unset(UserBasedQueryHook.ALLOWED_USERS); } if (disallowedString != null) { conf.set(UserBasedQueryHook.DISALLOWED_USERS, disallowedString); } else { conf.unset(UserBasedQueryHook.DISALLOWED_USERS); } when(ctx.getSubmittedUser()).thenReturn(user); try { hook.setDriver(driver); hook.preRewrite(ctx); assertTrue(success); } catch (Exception e) { assertFalse(success); } }
@Override public void preRewrite(AbstractQueryContext ctx) throws LensException { if ((allowedUsers != null && !allowedUsers.contains(ctx.getSubmittedUser())) || (disallowedUsers != null && disallowedUsers.contains(ctx.getSubmittedUser()))) { throw new LensException(getErrorMessage(ctx)); } }
UserBasedQueryHook extends NoOpDriverQueryHook { @Override public void preRewrite(AbstractQueryContext ctx) throws LensException { if ((allowedUsers != null && !allowedUsers.contains(ctx.getSubmittedUser())) || (disallowedUsers != null && disallowedUsers.contains(ctx.getSubmittedUser()))) { throw new LensException(getErrorMessage(ctx)); } } }
UserBasedQueryHook extends NoOpDriverQueryHook { @Override public void preRewrite(AbstractQueryContext ctx) throws LensException { if ((allowedUsers != null && !allowedUsers.contains(ctx.getSubmittedUser())) || (disallowedUsers != null && disallowedUsers.contains(ctx.getSubmittedUser()))) { throw new LensException(getErrorMessage(ctx)); } }  }
UserBasedQueryHook extends NoOpDriverQueryHook { @Override public void preRewrite(AbstractQueryContext ctx) throws LensException { if ((allowedUsers != null && !allowedUsers.contains(ctx.getSubmittedUser())) || (disallowedUsers != null && disallowedUsers.contains(ctx.getSubmittedUser()))) { throw new LensException(getErrorMessage(ctx)); } }  @Override void setDriver(LensDriver driver); @Override void preRewrite(AbstractQueryContext ctx); }
UserBasedQueryHook extends NoOpDriverQueryHook { @Override public void preRewrite(AbstractQueryContext ctx) throws LensException { if ((allowedUsers != null && !allowedUsers.contains(ctx.getSubmittedUser())) || (disallowedUsers != null && disallowedUsers.contains(ctx.getSubmittedUser()))) { throw new LensException(getErrorMessage(ctx)); } }  @Override void setDriver(LensDriver driver); @Override void preRewrite(AbstractQueryContext ctx); static final String ALLOWED_USERS; static final String DISALLOWED_USERS; }