Compare commits
No commits in common. "ad7658692c2a93bc3ac12f22e87d4cf02d7229d6" and "2bacea7ad90c4b53474f0c0a511e9f555d429d32" have entirely different histories.
ad7658692c
...
2bacea7ad9
5
.aliases
5
.aliases
@ -90,8 +90,3 @@ alias gw-importOfficeData-in-docker-compose='
|
||||
docker-compose -f etc/docker-compose.yml down &&
|
||||
docker-compose -f etc/docker-compose.yml up -d && sleep 10 &&
|
||||
time gw-importHostingAssets'
|
||||
|
||||
if [ ! -f .environment ]; then
|
||||
cp .tc-environment .environment
|
||||
fi
|
||||
source .environment
|
||||
|
@ -2,7 +2,6 @@ unset HSADMINNG_POSTGRES_JDBC_URL # dynamically set, different for normal tests
|
||||
export HSADMINNG_POSTGRES_ADMIN_USERNAME=admin
|
||||
export HSADMINNG_POSTGRES_ADMIN_PASSWORD=
|
||||
export HSADMINNG_POSTGRES_RESTRICTED_USERNAME=restricted
|
||||
export HSADMINNG_SUPERUSER=superuser-alex@hostsharing.net
|
||||
export HSADMINNG_MIGRATION_DATA_PATH=migration
|
||||
export LIQUIBASE_CONTEXT=
|
||||
export LANG=de_DE.UTF-8
|
||||
export LANG=en_US.UTF-8
|
||||
|
@ -34,7 +34,6 @@ import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.PostLoad;
|
||||
import jakarta.persistence.Transient;
|
||||
import jakarta.persistence.Version;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -116,13 +115,6 @@ public abstract class HsHostingAsset implements Stringifyable, BaseEntity<HsHost
|
||||
this.isLoaded = true;
|
||||
}
|
||||
|
||||
public List<HsHostingAssetRealEntity> getSubHostingAssets() {
|
||||
if (subHostingAssets == null) {
|
||||
subHostingAssets = new ArrayList<>();
|
||||
}
|
||||
return subHostingAssets;
|
||||
}
|
||||
|
||||
public PatchableMapWrapper<Object> getConfig() {
|
||||
return PatchableMapWrapper.of(configWrapper, (newWrapper) -> {configWrapper = newWrapper;}, config);
|
||||
}
|
||||
|
@ -66,8 +66,6 @@ public class HostingAssetEntitySaveProcessor {
|
||||
public HostingAssetEntitySaveProcessor saveUsing(final Function<HsHostingAsset, HsHostingAsset> saveFunction) {
|
||||
step("saveUsing", "validateContext");
|
||||
entity = saveFunction.apply(entity);
|
||||
em.flush(); // makes RbacEntity available as RealEntity if needed
|
||||
validator.postPersist(em, entity);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,10 @@
|
||||
package net.hostsharing.hsadminng.hs.hosting.asset.validators;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAsset;
|
||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetRealEntity;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.UNIX_USER;
|
||||
|
||||
class HsManagedWebspaceHostingAssetValidator extends HostingAssetEntityValidator {
|
||||
public HsManagedWebspaceHostingAssetValidator() {
|
||||
@ -25,32 +22,4 @@ class HsManagedWebspaceHostingAssetValidator extends HostingAssetEntityValidator
|
||||
: "[a-z][a-z0-9][a-z0-9]";
|
||||
return Pattern.compile("^" + prefixPattern + "[0-9][0-9]$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postPersist(final EntityManager em, final HsHostingAsset webspaceAsset) {
|
||||
if (!webspaceAsset.isLoaded()) {
|
||||
final var unixUserAsset = HsHostingAssetRealEntity.builder()
|
||||
.type(UNIX_USER)
|
||||
.parentAsset(em.find(HsHostingAssetRealEntity.class, webspaceAsset.getUuid()))
|
||||
.identifier(webspaceAsset.getIdentifier())
|
||||
.caption(webspaceAsset.getIdentifier() + " webspace user")
|
||||
.build();
|
||||
webspaceAsset.getSubHostingAssets().add(unixUserAsset);
|
||||
final var emw = new EntityManagerWrapper(em);
|
||||
new HostingAssetEntitySaveProcessor(em, unixUserAsset)
|
||||
.preprocessEntity()
|
||||
.validateEntity()
|
||||
.prepareForSave()
|
||||
.saveUsing(emw::persist)
|
||||
.validateContext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
record EntityManagerWrapper(EntityManager em) {
|
||||
|
||||
HsHostingAsset persist(HsHostingAsset hsHostingAsset) {
|
||||
em.persist(hsHostingAsset);
|
||||
return hsHostingAsset;
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,4 @@ public abstract class HsEntityValidator<E extends PropertiesProvider> {
|
||||
public ValidatableProperty<?, ?> getProperty(final String propertyName) {
|
||||
return stream(propertyValidators).filter(pv -> pv.propertyName().equals(propertyName)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public void postPersist(final EntityManager em, final E entity) {
|
||||
}
|
||||
}
|
||||
|
@ -182,23 +182,11 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
.header("Location", matchesRegex("http://localhost:[1-9][0-9]*/api/hs/hosting/assets/[^/]*"))
|
||||
.extract().header("Location"); // @formatter:on
|
||||
|
||||
// the new asset can be accessed under the generated UUID
|
||||
final var newWebspaceUuid = UUID.fromString(
|
||||
// finally, the new asset can be accessed under the generated UUID
|
||||
final var newWebspace = UUID.fromString(
|
||||
location.substring(location.lastIndexOf('/') + 1));
|
||||
assertThat(newWebspaceUuid).isNotNull();
|
||||
toCleanup(HsHostingAssetRbacEntity.class, newWebspaceUuid);
|
||||
|
||||
// and a default user got created
|
||||
final var webspaceUnixUser = em.createQuery("SELECT ha FROM HsHostingAssetRealEntity ha WHERE ha.parentAsset.uuid=:webspaceUUID")
|
||||
.setParameter("webspaceUUID", newWebspaceUuid)
|
||||
.getSingleResult();
|
||||
assertThat(webspaceUnixUser).isNotNull().extracting(Object::toString)
|
||||
.isEqualTo("""
|
||||
HsHostingAsset(UNIX_USER, fir10, fir10 webspace user, MANAGED_WEBSPACE:fir10, {
|
||||
"password" : null,
|
||||
"userid" : 1000000
|
||||
})
|
||||
""".trim());
|
||||
assertThat(newWebspace).isNotNull();
|
||||
toCleanup(HsHostingAssetRbacEntity.class, newWebspace);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -337,7 +325,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
|
||||
jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
for (int n = 0; n < UNIX_USER_PER_MULTI_OPTION-preExistingUnixUserCount; ++n) {
|
||||
for (int n = 0; n < UNIX_USER_PER_MULTI_OPTION -preExistingUnixUserCount+1; ++n) {
|
||||
toCleanup(realAssetRepo.save(
|
||||
HsHostingAssetRealEntity.builder()
|
||||
.type(UNIX_USER)
|
||||
|
Loading…
Reference in New Issue
Block a user