rename hs-admin to hs-office regarding the module name
This commit is contained in:
@@ -53,16 +53,16 @@ public class ArchTest {
|
||||
@com.tngtech.archunit.junit.ArchTest
|
||||
@SuppressWarnings("unused")
|
||||
public static final ArchRule hsAdminPackagesRule = classes()
|
||||
.that().resideInAPackage("..hs.admin.(*)..")
|
||||
.that().resideInAPackage("..hs.office.(*)..")
|
||||
.should().onlyBeAccessed().byClassesThat()
|
||||
.resideInAnyPackage("..hs.admin.(*)..");
|
||||
.resideInAnyPackage("..hs.office.(*)..");
|
||||
|
||||
@com.tngtech.archunit.junit.ArchTest
|
||||
@SuppressWarnings("unused")
|
||||
public static final ArchRule hsAdminPartnerPackageRule = classes()
|
||||
.that().resideInAPackage("..hs.admin.partner..")
|
||||
public static final ArchRule HsOfficePartnerPackageRule = classes()
|
||||
.that().resideInAPackage("..hs.office.partner..")
|
||||
.should().onlyBeAccessed().byClassesThat()
|
||||
.resideInAnyPackage("..hs.admin.partner..");
|
||||
.resideInAnyPackage("..hs.office.partner..");
|
||||
|
||||
@com.tngtech.archunit.junit.ArchTest
|
||||
@SuppressWarnings("unused")
|
||||
|
@@ -1,17 +0,0 @@
|
||||
package net.hostsharing.hsadminng.hs.admin.contact;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TestHsAdminContact {
|
||||
|
||||
public static final HsAdminContactEntity someContact = hsAdminContact("some contact", "some-contact@example.com");
|
||||
|
||||
static public HsAdminContactEntity hsAdminContact(final String label, final String emailAddr) {
|
||||
return HsAdminContactEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.label(label)
|
||||
.postalAddress("address of " + label)
|
||||
.emailAddresses(emailAddr)
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package net.hostsharing.hsadminng.hs.admin.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.admin.contact.HsAdminContactEntity;
|
||||
import net.hostsharing.hsadminng.hs.admin.person.HsAdminPersonEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.admin.person.HsAdminPersonType.LEGAL;
|
||||
|
||||
public class TestHsAdminPartner {
|
||||
|
||||
public static final HsAdminPartnerEntity testLtd = hsAdminPartnerWithLegalPerson("Test Ltd.");
|
||||
|
||||
static public HsAdminPartnerEntity hsAdminPartnerWithLegalPerson(final String tradeName) {
|
||||
return HsAdminPartnerEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.person(HsAdminPersonEntity.builder()
|
||||
.personType(LEGAL)
|
||||
.tradeName(tradeName)
|
||||
.build())
|
||||
.contact(HsAdminContactEntity.builder()
|
||||
.label(tradeName)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
package net.hostsharing.hsadminng.hs.admin.person;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TestHsAdminPerson {
|
||||
|
||||
public static final HsAdminPersonEntity somePerson = hsAdminPerson("some person");
|
||||
|
||||
static public HsAdminPersonEntity hsAdminPerson(final String tradeName) {
|
||||
return HsAdminPersonEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.personType(HsAdminPersonType.NATURAL)
|
||||
.tradeName(tradeName)
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package net.hostsharing.hsadminng.hs.admin.contact;
|
||||
package net.hostsharing.hsadminng.hs.office.contact;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.context.ContextBasedTest;
|
||||
@@ -22,7 +22,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.admin.contact.TestHsAdminContact.hsAdminContact;
|
||||
import static net.hostsharing.hsadminng.hs.office.contact.TestHsOfficeContact.hsOfficeContact;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantDisplayExtractor.grantDisplaysOf;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleNameExtractor.roleNamesOf;
|
||||
import static net.hostsharing.test.JpaAttempt.attempt;
|
||||
@@ -30,12 +30,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assumptions.assumeThat;
|
||||
|
||||
@DataJpaTest
|
||||
@ComponentScan(basePackageClasses = { HsAdminContactRepository.class, Context.class, JpaAttempt.class })
|
||||
@ComponentScan(basePackageClasses = { HsOfficeContactRepository.class, Context.class, JpaAttempt.class })
|
||||
@DirtiesContext
|
||||
class HsAdminContactRepositoryIntegrationTest extends ContextBasedTest {
|
||||
class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
@Autowired
|
||||
HsAdminContactRepository contactRepo;
|
||||
HsOfficeContactRepository contactRepo;
|
||||
|
||||
@Autowired
|
||||
RbacRoleRepository roleRepo;
|
||||
@@ -67,11 +67,11 @@ class HsAdminContactRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// when
|
||||
|
||||
final var result = attempt(em, () -> contactRepo.save(
|
||||
hsAdminContact("a new contact", "contact-admin@www.example.com")));
|
||||
hsOfficeContact("a new contact", "contact-admin@www.example.com")));
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsAdminContactEntity::getUuid).isNotNull();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeContactEntity::getUuid).isNotNull();
|
||||
assertThatContactIsPersisted(result.returnedValue());
|
||||
assertThat(contactRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
@@ -84,11 +84,11 @@ class HsAdminContactRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> contactRepo.save(
|
||||
hsAdminContact("another new contact", "another-new-contact@example.com")));
|
||||
hsOfficeContact("another new contact", "another-new-contact@example.com")));
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsAdminContactEntity::getUuid).isNotNull();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeContactEntity::getUuid).isNotNull();
|
||||
assertThatContactIsPersisted(result.returnedValue());
|
||||
assertThat(contactRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class HsAdminContactRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
// when
|
||||
attempt(em, () -> contactRepo.save(
|
||||
hsAdminContact("another new contact", "another-new-contact@example.com"))
|
||||
hsOfficeContact("another new contact", "another-new-contact@example.com"))
|
||||
).assumeSuccessful();
|
||||
|
||||
// then
|
||||
@@ -111,17 +111,17 @@ class HsAdminContactRepositoryIntegrationTest extends ContextBasedTest {
|
||||
assertThat(roleNamesOf(roles)).containsExactlyInAnyOrder(
|
||||
Array.from(
|
||||
initialRoleNames,
|
||||
"hs_admin_contact#anothernewcontact.owner",
|
||||
"hs_admin_contact#anothernewcontact.admin",
|
||||
"hs_admin_contact#anothernewcontact.tenant"));
|
||||
"hs_office_contact#anothernewcontact.owner",
|
||||
"hs_office_contact#anothernewcontact.admin",
|
||||
"hs_office_contact#anothernewcontact.tenant"));
|
||||
final var grants = grantRepo.findAll();
|
||||
assertThat(grantDisplaysOf(grants)).containsAll(List.of(
|
||||
"{ grant assumed role hs_admin_contact#anothernewcontact.owner to user drew@hostsharing.org by role global#global.admin }"));
|
||||
"{ grant assumed role hs_office_contact#anothernewcontact.owner to user drew@hostsharing.org by role global#global.admin }"));
|
||||
assertThat(grants.size()).as("invalid number of grants created")
|
||||
.isEqualTo(initialGrantCount + 1);
|
||||
}
|
||||
|
||||
private void assertThatContactIsPersisted(final HsAdminContactEntity saved) {
|
||||
private void assertThatContactIsPersisted(final HsOfficeContactEntity saved) {
|
||||
final var found = contactRepo.findByUuid(saved.getUuid());
|
||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
||||
}
|
||||
@@ -253,9 +253,9 @@ class HsAdminContactRepositoryIntegrationTest extends ContextBasedTest {
|
||||
}
|
||||
}
|
||||
|
||||
private HsAdminContactEntity givenSomeTemporaryContact(
|
||||
private HsOfficeContactEntity givenSomeTemporaryContact(
|
||||
final String createdByUser,
|
||||
Supplier<HsAdminContactEntity> entitySupplier) {
|
||||
Supplier<HsOfficeContactEntity> entitySupplier) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context(createdByUser);
|
||||
return contactRepo.save(entitySupplier.get());
|
||||
@@ -272,23 +272,23 @@ class HsAdminContactRepositoryIntegrationTest extends ContextBasedTest {
|
||||
});
|
||||
}
|
||||
|
||||
private HsAdminContactEntity givenSomeTemporaryContact(final String createdByUser) {
|
||||
private HsOfficeContactEntity givenSomeTemporaryContact(final String createdByUser) {
|
||||
final var random = RandomString.make(12);
|
||||
return givenSomeTemporaryContact(createdByUser, () ->
|
||||
hsAdminContact(
|
||||
hsOfficeContact(
|
||||
"some temporary contact #" + random,
|
||||
"some-temporary-contact" + random + "@example.com"));
|
||||
}
|
||||
|
||||
void exactlyTheseContactsAreReturned(final List<HsAdminContactEntity> actualResult, final String... contactLabels) {
|
||||
void exactlyTheseContactsAreReturned(final List<HsOfficeContactEntity> actualResult, final String... contactLabels) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsAdminContactEntity::getLabel)
|
||||
.extracting(HsOfficeContactEntity::getLabel)
|
||||
.containsExactlyInAnyOrder(contactLabels);
|
||||
}
|
||||
|
||||
void allTheseContactsAreReturned(final List<HsAdminContactEntity> actualResult, final String... contactLabels) {
|
||||
void allTheseContactsAreReturned(final List<HsOfficeContactEntity> actualResult, final String... contactLabels) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsAdminContactEntity::getLabel)
|
||||
.extracting(HsOfficeContactEntity::getLabel)
|
||||
.contains(contactLabels);
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package net.hostsharing.hsadminng.hs.office.contact;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TestHsOfficeContact {
|
||||
|
||||
public static final HsOfficeContactEntity someContact = hsOfficeContact("some contact", "some-contact@example.com");
|
||||
|
||||
static public HsOfficeContactEntity hsOfficeContact(final String label, final String emailAddr) {
|
||||
return HsOfficeContactEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.label(label)
|
||||
.postalAddress("address of " + label)
|
||||
.emailAddresses(emailAddr)
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package net.hostsharing.hsadminng.hs.admin.partner;
|
||||
package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
@@ -24,7 +24,7 @@ import static org.hamcrest.Matchers.*;
|
||||
classes = HsadminNgApplication.class
|
||||
)
|
||||
@Transactional
|
||||
class HsAdminPartnerControllerAcceptanceTest {
|
||||
class HsOfficePartnerControllerAcceptanceTest {
|
||||
|
||||
@LocalServerPort
|
||||
private Integer port;
|
||||
@@ -35,7 +35,7 @@ class HsAdminPartnerControllerAcceptanceTest {
|
||||
@Autowired
|
||||
Context contextMock;
|
||||
@Autowired
|
||||
HsAdminPartnerRepository partnerRepository;
|
||||
HsOfficePartnerRepository partnerRepository;
|
||||
|
||||
@Nested
|
||||
@Accepts({ "Partner:F(Find)" })
|
||||
@@ -48,7 +48,7 @@ class HsAdminPartnerControllerAcceptanceTest {
|
||||
.header("current-user", "mike@hostsharing.net")
|
||||
.port(port)
|
||||
.when()
|
||||
.get("http://localhost/api/hs/admin/partners")
|
||||
.get("http://localhost/api/hs/office/partners")
|
||||
.then().assertThat()
|
||||
.statusCode(200)
|
||||
.contentType("application/json")
|
||||
@@ -103,7 +103,7 @@ class HsAdminPartnerControllerAcceptanceTest {
|
||||
.with("uuid", givenUUID.toString()).toString())
|
||||
.port(port)
|
||||
.when()
|
||||
.post("http://localhost/api/hs/admin/partners")
|
||||
.post("http://localhost/api/hs/office/partners")
|
||||
.then().assertThat()
|
||||
.statusCode(201)
|
||||
.contentType(ContentType.JSON)
|
||||
@@ -132,7 +132,7 @@ class HsAdminPartnerControllerAcceptanceTest {
|
||||
.body(NEW_PARTNER_JSON_WITHOUT_UUID)
|
||||
.port(port)
|
||||
.when()
|
||||
.post("http://localhost/api/hs/admin/partners")
|
||||
.post("http://localhost/api/hs/office/partners")
|
||||
.then().assertThat()
|
||||
.statusCode(201)
|
||||
.contentType(ContentType.JSON)
|
||||
@@ -166,7 +166,7 @@ class HsAdminPartnerControllerAcceptanceTest {
|
||||
.header("current-user", "mike@hostsharing.net")
|
||||
.port(port)
|
||||
.when()
|
||||
.get("http://localhost/api/hs/admin/partners/" + givenPartnerUuid)
|
||||
.get("http://localhost/api/hs/office/partners/" + givenPartnerUuid)
|
||||
.then().log().body().assertThat()
|
||||
.statusCode(200)
|
||||
.contentType("application/json")
|
||||
@@ -186,7 +186,7 @@ class HsAdminPartnerControllerAcceptanceTest {
|
||||
.header("current-user", "somebody@example.org")
|
||||
.port(port)
|
||||
.when()
|
||||
.get("http://localhost/api/hs/admin/partners/" + givenPartnerUuid)
|
||||
.get("http://localhost/api/hs/office/partners/" + givenPartnerUuid)
|
||||
.then().log().body().assertThat()
|
||||
.statusCode(404);
|
||||
// @formatter:on
|
@@ -1,10 +1,10 @@
|
||||
package net.hostsharing.hsadminng.hs.admin.partner;
|
||||
package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.context.ContextBasedTest;
|
||||
import net.hostsharing.hsadminng.hs.admin.contact.HsAdminContactRepository;
|
||||
import net.hostsharing.hsadminng.hs.admin.person.HsAdminPersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.admin.person.HsAdminPersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
|
||||
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
|
||||
import net.hostsharing.test.Array;
|
||||
@@ -33,18 +33,18 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assumptions.assumeThat;
|
||||
|
||||
@DataJpaTest
|
||||
@ComponentScan(basePackageClasses = { HsAdminPartnerRepository.class, Context.class, JpaAttempt.class })
|
||||
@ComponentScan(basePackageClasses = { HsOfficePartnerRepository.class, Context.class, JpaAttempt.class })
|
||||
@DirtiesContext
|
||||
class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
@Autowired
|
||||
HsAdminPartnerRepository partnerRepo;
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsAdminPersonRepository personRepo;
|
||||
HsOfficePersonRepository personRepo;
|
||||
|
||||
@Autowired
|
||||
HsAdminContactRepository contactRepo;
|
||||
HsOfficeContactRepository contactRepo;
|
||||
|
||||
@Autowired
|
||||
RawRbacRoleRepository rawRoleRepo;
|
||||
@@ -61,7 +61,7 @@ class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
@MockBean
|
||||
HttpServletRequest request;
|
||||
|
||||
Set<HsAdminPartnerEntity> tempPartners = new HashSet<>();
|
||||
Set<HsOfficePartnerEntity> tempPartners = new HashSet<>();
|
||||
|
||||
@Nested
|
||||
class CreatePartner {
|
||||
@@ -76,7 +76,7 @@ class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
final var newPartner = HsAdminPartnerEntity.builder()
|
||||
final var newPartner = HsOfficePartnerEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.person(givenPerson)
|
||||
.contact(givenContact)
|
||||
@@ -86,7 +86,7 @@ class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsAdminPartnerEntity::getUuid).isNotNull();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePartnerEntity::getUuid).isNotNull();
|
||||
assertThatPartnerIsPersisted(result.returnedValue());
|
||||
assertThat(partnerRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
attempt(em, () -> {
|
||||
final var givenPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0);
|
||||
final var newPartner = HsAdminPartnerEntity.builder()
|
||||
final var newPartner = HsOfficePartnerEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.person(givenPerson)
|
||||
.contact(givenContact)
|
||||
@@ -114,24 +114,24 @@ class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// then
|
||||
assertThat(roleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
|
||||
initialRoleNames,
|
||||
"hs_admin_partner#ErbenBesslerMelBessler-forthcontact.admin",
|
||||
"hs_admin_partner#ErbenBesslerMelBessler-forthcontact.owner",
|
||||
"hs_admin_partner#ErbenBesslerMelBessler-forthcontact.tenant"));
|
||||
"hs_office_partner#ErbenBesslerMelBessler-forthcontact.admin",
|
||||
"hs_office_partner#ErbenBesslerMelBessler-forthcontact.owner",
|
||||
"hs_office_partner#ErbenBesslerMelBessler-forthcontact.tenant"));
|
||||
assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsAll(List.of(
|
||||
"{ grant role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.owner to role global#global.admin by system and assume }",
|
||||
"{ grant role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.tenant to role hs_admin_contact#forthcontact.admin by system and assume }",
|
||||
"{ grant perm edit on hs_admin_partner#ErbenBesslerMelBessler-forthcontact to role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.admin by system and assume }",
|
||||
"{ grant role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.tenant to role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.admin by system and assume }",
|
||||
"{ grant perm * on hs_admin_partner#ErbenBesslerMelBessler-forthcontact to role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.owner by system and assume }",
|
||||
"{ grant role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.admin to role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.owner by system and assume }",
|
||||
"{ grant perm view on hs_admin_partner#ErbenBesslerMelBessler-forthcontact to role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.tenant by system and assume }",
|
||||
"{ grant role hs_admin_contact#forthcontact.tenant to role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.tenant by system and assume }",
|
||||
"{ grant role hs_admin_person#ErbenBesslerMelBessler.tenant to role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.tenant by system and assume }",
|
||||
"{ grant role hs_admin_partner#ErbenBesslerMelBessler-forthcontact.tenant to role hs_admin_person#ErbenBesslerMelBessler.admin by system and assume }"))
|
||||
"{ grant role hs_office_partner#ErbenBesslerMelBessler-forthcontact.owner to role global#global.admin by system and assume }",
|
||||
"{ grant role hs_office_partner#ErbenBesslerMelBessler-forthcontact.tenant to role hs_office_contact#forthcontact.admin by system and assume }",
|
||||
"{ grant perm edit on hs_office_partner#ErbenBesslerMelBessler-forthcontact to role hs_office_partner#ErbenBesslerMelBessler-forthcontact.admin by system and assume }",
|
||||
"{ grant role hs_office_partner#ErbenBesslerMelBessler-forthcontact.tenant to role hs_office_partner#ErbenBesslerMelBessler-forthcontact.admin by system and assume }",
|
||||
"{ grant perm * on hs_office_partner#ErbenBesslerMelBessler-forthcontact to role hs_office_partner#ErbenBesslerMelBessler-forthcontact.owner by system and assume }",
|
||||
"{ grant role hs_office_partner#ErbenBesslerMelBessler-forthcontact.admin to role hs_office_partner#ErbenBesslerMelBessler-forthcontact.owner by system and assume }",
|
||||
"{ grant perm view on hs_office_partner#ErbenBesslerMelBessler-forthcontact to role hs_office_partner#ErbenBesslerMelBessler-forthcontact.tenant by system and assume }",
|
||||
"{ grant role hs_office_contact#forthcontact.tenant to role hs_office_partner#ErbenBesslerMelBessler-forthcontact.tenant by system and assume }",
|
||||
"{ grant role hs_office_person#ErbenBesslerMelBessler.tenant to role hs_office_partner#ErbenBesslerMelBessler-forthcontact.tenant by system and assume }",
|
||||
"{ grant role hs_office_partner#ErbenBesslerMelBessler-forthcontact.tenant to role hs_office_person#ErbenBesslerMelBessler.admin by system and assume }"))
|
||||
.as("invalid number of grants created").hasSize(initialGrantCount + 10);
|
||||
}
|
||||
|
||||
private void assertThatPartnerIsPersisted(final HsAdminPartnerEntity saved) {
|
||||
private void assertThatPartnerIsPersisted(final HsOfficePartnerEntity saved) {
|
||||
final var found = partnerRepo.findByUuid(saved.getUuid());
|
||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
||||
}
|
||||
@@ -249,7 +249,7 @@ class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
jpaAttempt.transacted(() -> {
|
||||
final var remainingPartner = em.createNativeQuery("select p.uuid from hs_admin_partner p where p.uuid=?1")
|
||||
final var remainingPartner = em.createNativeQuery("select p.uuid from hs_office_partner p where p.uuid=?1")
|
||||
.setParameter(1, givenPartner.getUuid()).getResultList();
|
||||
assertThat(remainingPartner).isEmpty();
|
||||
final var remainingObject = em.createNativeQuery("select o.uuid from RbacObject o where o.uuid=?1")
|
||||
@@ -261,21 +261,21 @@ class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
context("customer-admin@forthcontact.example.com");
|
||||
assertThat(grantDisplaysOf(rawGrantRepo.findAll())).doesNotContain(
|
||||
"{ grant assumed role hs_admin_contact#forthcontact.owner to user customer-admin@forthcontact.example.com by role global#global.admin }");
|
||||
"{ grant assumed role hs_office_contact#forthcontact.owner to user customer-admin@forthcontact.example.com by role global#global.admin }");
|
||||
|
||||
context("person-ErbenBesslerMelBessler@example.com");
|
||||
assertThat(grantDisplaysOf(rawGrantRepo.findAll())).doesNotContain(
|
||||
"{ grant assumed role hs_admin_person#ErbenBesslerMelBessler.owner to user person-ErbenBesslerMelBessl@example.com by role global#global.admin }");
|
||||
"{ grant assumed role hs_office_person#ErbenBesslerMelBessler.owner to user person-ErbenBesslerMelBessl@example.com by role global#global.admin }");
|
||||
}).assertSuccessful();
|
||||
}
|
||||
}
|
||||
|
||||
private HsAdminPartnerEntity givenSomeTemporaryPartnerBessler() {
|
||||
private HsOfficePartnerEntity givenSomeTemporaryPartnerBessler() {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context("alex@hostsharing.net");
|
||||
final var givenPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0);
|
||||
final var newPartner = HsAdminPartnerEntity.builder()
|
||||
final var newPartner = HsOfficePartnerEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.person(givenPerson)
|
||||
.contact(givenContact)
|
||||
@@ -285,7 +285,7 @@ class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
}).assertSuccessful().returnedValue();
|
||||
}
|
||||
|
||||
private HsAdminPartnerEntity toCleanup(final HsAdminPartnerEntity tempPartner) {
|
||||
private HsOfficePartnerEntity toCleanup(final HsOfficePartnerEntity tempPartner) {
|
||||
tempPartners.add(tempPartner);
|
||||
return tempPartner;
|
||||
}
|
||||
@@ -300,18 +300,18 @@ class HsAdminPartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
});
|
||||
}
|
||||
|
||||
void exactlyThesePartnersAreReturned(final List<HsAdminPartnerEntity> actualResult, final String... partnerTradeNames) {
|
||||
void exactlyThesePartnersAreReturned(final List<HsOfficePartnerEntity> actualResult, final String... partnerTradeNames) {
|
||||
assertThat(actualResult)
|
||||
.hasSize(partnerTradeNames.length)
|
||||
.extracting(HsAdminPartnerEntity::getPerson)
|
||||
.extracting(HsAdminPersonEntity::getTradeName)
|
||||
.extracting(HsOfficePartnerEntity::getPerson)
|
||||
.extracting(HsOfficePersonEntity::getTradeName)
|
||||
.containsExactlyInAnyOrder(partnerTradeNames);
|
||||
}
|
||||
|
||||
void allThesePartnersAreReturned(final List<HsAdminPartnerEntity> actualResult, final String... partnerTradeNames) {
|
||||
void allThesePartnersAreReturned(final List<HsOfficePartnerEntity> actualResult, final String... partnerTradeNames) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsAdminPartnerEntity::getPerson)
|
||||
.extracting(HsAdminPersonEntity::getTradeName)
|
||||
.extracting(HsOfficePartnerEntity::getPerson)
|
||||
.extracting(HsOfficePersonEntity::getTradeName)
|
||||
.contains(partnerTradeNames);
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.LEGAL;
|
||||
|
||||
public class TestHsOfficePartner {
|
||||
|
||||
public static final HsOfficePartnerEntity testLtd = HsOfficePartnerWithLegalPerson("Test Ltd.");
|
||||
|
||||
static public HsOfficePartnerEntity HsOfficePartnerWithLegalPerson(final String tradeName) {
|
||||
return HsOfficePartnerEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.person(HsOfficePersonEntity.builder()
|
||||
.personType(LEGAL)
|
||||
.tradeName(tradeName)
|
||||
.build())
|
||||
.contact(HsOfficeContactEntity.builder()
|
||||
.label(tradeName)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -1,14 +1,14 @@
|
||||
package net.hostsharing.hsadminng.hs.admin.person;
|
||||
package net.hostsharing.hsadminng.hs.office.person;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class HsAdminPersonEntityUnitTest {
|
||||
class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void getDisplayReturnsTradeNameIfAvailable() {
|
||||
final var givenPersonEntity = HsAdminPersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
.tradeName("some trade name")
|
||||
.build();
|
||||
|
||||
@@ -19,7 +19,7 @@ class HsAdminPersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void getDisplayReturnsFamilyAndGivenNameIfNoTradeNameAvailable() {
|
||||
final var givenPersonEntity = HsAdminPersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
.familyName("some family name")
|
||||
.givenName("some given name")
|
||||
.build();
|
@@ -1,4 +1,4 @@
|
||||
package net.hostsharing.hsadminng.hs.admin.person;
|
||||
package net.hostsharing.hsadminng.hs.office.person;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.context.ContextBasedTest;
|
||||
@@ -21,7 +21,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.admin.person.TestHsAdminPerson.hsAdminPerson;
|
||||
import static net.hostsharing.hsadminng.hs.office.person.TestHsOfficePerson.hsOfficePerson;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantDisplayExtractor.grantDisplaysOf;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleNameExtractor.roleNamesOf;
|
||||
import static net.hostsharing.test.JpaAttempt.attempt;
|
||||
@@ -29,12 +29,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assumptions.assumeThat;
|
||||
|
||||
@DataJpaTest
|
||||
@ComponentScan(basePackageClasses = { HsAdminPersonRepository.class, Context.class, JpaAttempt.class })
|
||||
@ComponentScan(basePackageClasses = { HsOfficePersonRepository.class, Context.class, JpaAttempt.class })
|
||||
@DirtiesContext
|
||||
class HsAdminPersonRepositoryIntegrationTest extends ContextBasedTest {
|
||||
class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
@Autowired
|
||||
HsAdminPersonRepository personRepo;
|
||||
HsOfficePersonRepository personRepo;
|
||||
|
||||
@Autowired
|
||||
RawRbacRoleRepository rawRoleRepo;
|
||||
@@ -63,11 +63,11 @@ class HsAdminPersonRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// when
|
||||
|
||||
final var result = attempt(em, () -> personRepo.save(
|
||||
hsAdminPerson("a new person")));
|
||||
hsOfficePerson("a new person")));
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsAdminPersonEntity::getUuid).isNotNull();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonEntity::getUuid).isNotNull();
|
||||
assertThatPersonIsPersisted(result.returnedValue());
|
||||
assertThat(personRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
@@ -80,11 +80,11 @@ class HsAdminPersonRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> personRepo.save(
|
||||
hsAdminPerson("another new person")));
|
||||
hsOfficePerson("another new person")));
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsAdminPersonEntity::getUuid).isNotNull();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonEntity::getUuid).isNotNull();
|
||||
assertThatPersonIsPersisted(result.returnedValue());
|
||||
assertThat(personRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
@@ -99,31 +99,31 @@ class HsAdminPersonRepositoryIntegrationTest extends ContextBasedTest {
|
||||
|
||||
// when
|
||||
attempt(em, () -> personRepo.save(
|
||||
hsAdminPerson("another new person"))
|
||||
hsOfficePerson("another new person"))
|
||||
).assumeSuccessful();
|
||||
|
||||
// then
|
||||
assertThat(roleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(
|
||||
Array.from(
|
||||
initialRoleNames,
|
||||
"hs_admin_person#anothernewperson.owner",
|
||||
"hs_admin_person#anothernewperson.admin",
|
||||
"hs_admin_person#anothernewperson.tenant"
|
||||
"hs_office_person#anothernewperson.owner",
|
||||
"hs_office_person#anothernewperson.admin",
|
||||
"hs_office_person#anothernewperson.tenant"
|
||||
));
|
||||
assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(
|
||||
Array.from(
|
||||
initialGrantNames,
|
||||
"{ grant role hs_admin_person#anothernewperson.owner to role global#global.admin by system and assume }",
|
||||
"{ grant perm edit on hs_admin_person#anothernewperson to role hs_admin_person#anothernewperson.admin by system and assume }",
|
||||
"{ grant role hs_admin_person#anothernewperson.tenant to role hs_admin_person#anothernewperson.admin by system and assume }",
|
||||
"{ grant perm * on hs_admin_person#anothernewperson to role hs_admin_person#anothernewperson.owner by system and assume }",
|
||||
"{ grant role hs_admin_person#anothernewperson.admin to role hs_admin_person#anothernewperson.owner by system and assume }",
|
||||
"{ grant perm view on hs_admin_person#anothernewperson to role hs_admin_person#anothernewperson.tenant by system and assume }",
|
||||
"{ grant role hs_admin_person#anothernewperson.owner to user drew@hostsharing.org by global#global.admin and assume }"
|
||||
"{ grant role hs_office_person#anothernewperson.owner to role global#global.admin by system and assume }",
|
||||
"{ grant perm edit on hs_office_person#anothernewperson to role hs_office_person#anothernewperson.admin by system and assume }",
|
||||
"{ grant role hs_office_person#anothernewperson.tenant to role hs_office_person#anothernewperson.admin by system and assume }",
|
||||
"{ grant perm * on hs_office_person#anothernewperson to role hs_office_person#anothernewperson.owner by system and assume }",
|
||||
"{ grant role hs_office_person#anothernewperson.admin to role hs_office_person#anothernewperson.owner by system and assume }",
|
||||
"{ grant perm view on hs_office_person#anothernewperson to role hs_office_person#anothernewperson.tenant by system and assume }",
|
||||
"{ grant role hs_office_person#anothernewperson.owner to user drew@hostsharing.org by global#global.admin and assume }"
|
||||
));
|
||||
}
|
||||
|
||||
private void assertThatPersonIsPersisted(final HsAdminPersonEntity saved) {
|
||||
private void assertThatPersonIsPersisted(final HsOfficePersonEntity saved) {
|
||||
final var found = personRepo.findByUuid(saved.getUuid());
|
||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
||||
}
|
||||
@@ -271,29 +271,29 @@ class HsAdminPersonRepositoryIntegrationTest extends ContextBasedTest {
|
||||
});
|
||||
}
|
||||
|
||||
private HsAdminPersonEntity givenSomeTemporaryPerson(
|
||||
private HsOfficePersonEntity givenSomeTemporaryPerson(
|
||||
final String createdByUser,
|
||||
Supplier<HsAdminPersonEntity> entitySupplier) {
|
||||
Supplier<HsOfficePersonEntity> entitySupplier) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context(createdByUser);
|
||||
return personRepo.save(entitySupplier.get());
|
||||
}).assumeSuccessful().returnedValue();
|
||||
}
|
||||
|
||||
private HsAdminPersonEntity givenSomeTemporaryPerson(final String createdByUser) {
|
||||
private HsOfficePersonEntity givenSomeTemporaryPerson(final String createdByUser) {
|
||||
return givenSomeTemporaryPerson(createdByUser, () ->
|
||||
hsAdminPerson("some temporary person #" + RandomString.make(12)));
|
||||
hsOfficePerson("some temporary person #" + RandomString.make(12)));
|
||||
}
|
||||
|
||||
void exactlyThesePersonsAreReturned(final List<HsAdminPersonEntity> actualResult, final String... personLabels) {
|
||||
void exactlyThesePersonsAreReturned(final List<HsOfficePersonEntity> actualResult, final String... personLabels) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsAdminPersonEntity::getTradeName)
|
||||
.extracting(HsOfficePersonEntity::getTradeName)
|
||||
.containsExactlyInAnyOrder(personLabels);
|
||||
}
|
||||
|
||||
void allThesePersonsAreReturned(final List<HsAdminPersonEntity> actualResult, final String... personLabels) {
|
||||
void allThesePersonsAreReturned(final List<HsOfficePersonEntity> actualResult, final String... personLabels) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsAdminPersonEntity::getDisplayName)
|
||||
.extracting(HsOfficePersonEntity::getDisplayName)
|
||||
.contains(personLabels);
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package net.hostsharing.hsadminng.hs.office.person;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TestHsOfficePerson {
|
||||
|
||||
public static final HsOfficePersonEntity somePerson = hsOfficePerson("some person");
|
||||
|
||||
static public HsOfficePersonEntity hsOfficePerson(final String tradeName) {
|
||||
return HsOfficePersonEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.personType(HsOfficePersonType.NATURAL)
|
||||
.tradeName(tradeName)
|
||||
.build();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user