@Before public void setServiceAndStore() throws Exception { service = getSecurityManager().loadUserGroupService("test"); store = createStore(service); }
@Test public void testRemove() throws Exception { // all is empty checkEmpty(service); checkEmpty(store); insertValues(store); store.store(); checkValuesInserted(store); checkValuesInserted(service); removeValues(store); if (!isJDBCTest()) checkValuesInserted(service); checkValuesRemoved(store); store.load(); checkValuesInserted(store); checkValuesInserted(service); removeValues(store); store.store(); checkValuesRemoved(store); checkValuesRemoved(service); }
@Test public void testModify() throws Exception { // all is empty checkEmpty(service); checkEmpty(store); insertValues(store); store.store(); checkValuesInserted(store); checkValuesInserted(service); modifyValues(store); if (!isJDBCTest()) checkValuesInserted(service); checkValuesModified(store); store.load(); checkValuesInserted(store); checkValuesInserted(service); modifyValues(store); store.store(); checkValuesModified(store); checkValuesModified(service); }
@Test public void testInsert() throws Exception { // all is empty checkEmpty(service); checkEmpty(store); // transaction has values ? insertValues(store); if (!isJDBCTest()) checkEmpty(service); checkValuesInserted(store); // rollback store.load(); checkEmpty(store); checkEmpty(service); // commit insertValues(store); store.store(); checkValuesInserted(store); checkValuesInserted(service); }
getSecurityManager().loadUserGroupServiceConfig(service.getName()); config.setPasswordEncoderName(getPlainTextPasswordEncoder().getName()); getSecurityManager().saveUserGroupService(config); service.initializeFromConfig(config); store = service.createStore(); service.loadUserByUsername("u1") .getPassword() .startsWith(getPlainTextPasswordEncoder().getPrefix())); assertTrue( service.loadUserByUsername("u2") .getPassword() .startsWith(getPlainTextPasswordEncoder().getPrefix())); config.setPasswordEncoderName(getPBEPasswordEncoder().getName()); getSecurityManager().saveUserGroupService(config); service.initializeFromConfig(config); service.loadUserByUsername("u1") .getPassword() .startsWith(getPBEPasswordEncoder().getPrefix())); assertTrue( service.loadUserByUsername("u2") .getPassword() .startsWith(getPBEPasswordEncoder().getPrefix())); config.setPasswordEncoderName(getDigestPasswordEncoder().getName()); getSecurityManager().saveUserGroupService(config); service.initializeFromConfig(config);
@Override public GeoServerUserGroupStore createStore(GeoServerUserGroupService service) throws IOException { JDBCUserGroupStore store = (JDBCUserGroupStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store,store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); service = createUserGroupService("test"); // store = createStore(service); }
@Override protected SystemTestData createTestData() throws Exception { if ("h2".equalsIgnoreCase(getFixtureId())) return super.createTestData(); return new LiveDbmsDataSecurity(getFixtureId()); }
@Override protected TestData buildTestData() throws Exception { if ("h2".equalsIgnoreCase(getFixtureId())) return super.buildTestData(); return new LiveDbmsDataSecurity(getFixtureId()); }
@Test public void testEmptyPassword() throws Exception { // all is empty checkEmpty(service); checkEmpty(store); GeoServerUser user = store.createUserObject("userNoPasswd", null, true); store.addUser(user); store.store(); assertEquals(1, service.getUserCount()); user = service.getUserByUsername("userNoPasswd"); assertNull(user.getPassword()); user = (GeoServerUser) service.loadUserByUsername("userNoPasswd"); assertNull(user.getPassword()); }
@Override public GeoServerUserGroupStore createStore(GeoServerUserGroupService service) throws IOException { JDBCUserGroupStore store = (JDBCUserGroupStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store, store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }