Upgrade to SpringBoot 3.4.1 and dependencies #147
@ -5,6 +5,7 @@ import lombok.Builder;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import net.hostsharing.hsadminng.errors.DisplayAs;
|
import net.hostsharing.hsadminng.errors.DisplayAs;
|
||||||
|
import net.hostsharing.hsadminng.rbac.role.WithRoleId;
|
||||||
import net.hostsharing.hsadminng.repr.Stringify;
|
import net.hostsharing.hsadminng.repr.Stringify;
|
||||||
import net.hostsharing.hsadminng.repr.Stringifyable;
|
import net.hostsharing.hsadminng.repr.Stringifyable;
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ import static net.hostsharing.hsadminng.repr.Stringify.stringify;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@DisplayAs("BookingDebitor")
|
@DisplayAs("BookingDebitor")
|
||||||
public class HsBookingDebitorEntity implements Stringifyable {
|
public class HsBookingDebitorEntity implements Stringifyable, WithRoleId {
|
||||||
|
|
||||||
public static final String DEBITOR_NUMBER_TAG = "D-";
|
public static final String DEBITOR_NUMBER_TAG = "D-";
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ import net.hostsharing.hsadminng.errors.DisplayAs;
|
|||||||
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity;
|
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity;
|
||||||
import net.hostsharing.hsadminng.persistence.BaseEntity;
|
import net.hostsharing.hsadminng.persistence.BaseEntity;
|
||||||
import net.hostsharing.hsadminng.rbac.generator.RbacSpec;
|
import net.hostsharing.hsadminng.rbac.generator.RbacSpec;
|
||||||
|
import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL;
|
||||||
import net.hostsharing.hsadminng.repr.Stringify;
|
import net.hostsharing.hsadminng.repr.Stringify;
|
||||||
import net.hostsharing.hsadminng.repr.Stringifyable;
|
import net.hostsharing.hsadminng.repr.Stringifyable;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -57,8 +57,7 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, BaseE
|
|||||||
.quotedValues(false);
|
.quotedValues(false);
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(generator = "UUID")
|
@GeneratedValue
|
||||||
@GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
|
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
@Version
|
@Version
|
||||||
@ -141,7 +140,7 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, BaseE
|
|||||||
|
|
||||||
public static RbacSpec rbac() {
|
public static RbacSpec rbac() {
|
||||||
return rbacViewFor("coopAssetsTransaction", HsOfficeCoopAssetsTransactionEntity.class)
|
return rbacViewFor("coopAssetsTransaction", HsOfficeCoopAssetsTransactionEntity.class)
|
||||||
.withIdentityView(RbacSpec.SQL.projection("reference"))
|
.withIdentityView(SQL.projection("reference"))
|
||||||
.withUpdatableColumns("comment")
|
.withUpdatableColumns("comment")
|
||||||
.importEntityAlias("membership", HsOfficeMembershipEntity.class, usingDefaultCase(),
|
.importEntityAlias("membership", HsOfficeMembershipEntity.class, usingDefaultCase(),
|
||||||
dependsOnColumn("membershipUuid"),
|
dependsOnColumn("membershipUuid"),
|
||||||
|
@ -197,7 +197,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
|
|||||||
|
|
||||||
context.define(currentSubject, assumedRoles);
|
context.define(currentSubject, assumedRoles);
|
||||||
|
|
||||||
final var current = debitorRepo.findByUuid(debitorUuid).orElseThrow();
|
final var current = debitorRepo.findByUuid(debitorUuid).orElseThrow().load();
|
||||||
|
|
||||||
new HsOfficeDebitorEntityPatcher(em, current).apply(body);
|
new HsOfficeDebitorEntityPatcher(em, current).apply(body);
|
||||||
|
|
||||||
|
@ -170,7 +170,9 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
|||||||
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101).orElseThrow();
|
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101).orElseThrow();
|
||||||
|
|
||||||
final var location = RestAssured // @formatter:off
|
final var location = RestAssured // @formatter:off
|
||||||
.given().header("current-subject", "superuser-alex@hostsharing.net").contentType(ContentType.JSON).body("""
|
.given()
|
||||||
|
.header("current-subject", "superuser-alex@hostsharing.net")
|
||||||
|
.contentType(ContentType.JSON).body("""
|
||||||
{
|
{
|
||||||
"membership.uuid": "%s",
|
"membership.uuid": "%s",
|
||||||
"transactionType": "SUBSCRIPTION",
|
"transactionType": "SUBSCRIPTION",
|
||||||
@ -179,15 +181,29 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
|||||||
"reference": "temp ref A",
|
"reference": "temp ref A",
|
||||||
"comment": "just some test coop shares transaction"
|
"comment": "just some test coop shares transaction"
|
||||||
}
|
}
|
||||||
""".formatted(givenMembership.getUuid())).port(port).when().post("http://localhost/api/hs/office/coopsharestransactions").then().log().all().assertThat().statusCode(201).contentType(ContentType.JSON).body("uuid", isUuidValid()).body("", lenientlyEquals("""
|
""".formatted(givenMembership.getUuid()))
|
||||||
|
.port(port)
|
||||||
|
.when()
|
||||||
|
.post("http://localhost/api/hs/office/coopsharestransactions")
|
||||||
|
.then()
|
||||||
|
.log().all()
|
||||||
|
.assertThat()
|
||||||
|
.statusCode(201)
|
||||||
|
.contentType(ContentType.JSON)
|
||||||
|
.body("uuid", isUuidValid())
|
||||||
|
.body("", lenientlyEquals("""
|
||||||
{
|
{
|
||||||
|
"membership.uuid": "%s",
|
||||||
"transactionType": "SUBSCRIPTION",
|
"transactionType": "SUBSCRIPTION",
|
||||||
"shareCount": 8,
|
"shareCount": 8,
|
||||||
"valueDate": "2022-10-13",
|
"valueDate": "2022-10-13",
|
||||||
"reference": "temp ref A",
|
"reference": "temp ref A",
|
||||||
"comment": "just some test coop shares transaction"
|
"comment": "just some test coop shares transaction"
|
||||||
}
|
}
|
||||||
""")).header("Location", startsWith("http://localhost")).extract().header("Location"); // @formatter:on
|
""".formatted(givenMembership.getUuid())))
|
||||||
|
.header("Location", startsWith("http://localhost"))
|
||||||
|
.extract()
|
||||||
|
.header("Location"); // @formatter:on
|
||||||
|
|
||||||
// finally, the new coopSharesTransaction can be accessed under the generated UUID
|
// finally, the new coopSharesTransaction can be accessed under the generated UUID
|
||||||
final var newShareTxUuid = UUID.fromString(location.substring(location.lastIndexOf('/') + 1));
|
final var newShareTxUuid = UUID.fromString(location.substring(location.lastIndexOf('/') + 1));
|
||||||
@ -197,7 +213,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
|||||||
@Test
|
@Test
|
||||||
void globalAdmin_canAddCoopSharesReversalTransaction() {
|
void globalAdmin_canAddCoopSharesReversalTransaction() {
|
||||||
|
|
||||||
context.define("superuser-alex@hostsharing.net", "global#global:ADMIN");
|
context.define("superuser-alex@hostsharing.net", "rbac.global#global:ADMIN");
|
||||||
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101).orElseThrow();
|
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101).orElseThrow();
|
||||||
final var givenTransaction = jpaAttempt.transacted(() -> {
|
final var givenTransaction = jpaAttempt.transacted(() -> {
|
||||||
// TODO.impl: introduce something like transactedAsSuperuser / transactedAs("...", ...)
|
// TODO.impl: introduce something like transactedAsSuperuser / transactedAs("...", ...)
|
||||||
|
@ -10,6 +10,7 @@ import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
|||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
|
||||||
|
import net.hostsharing.hsadminng.rbac.role.RbacRoleType;
|
||||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||||
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
import net.hostsharing.hsadminng.config.DisableSecurityConfig;
|
||||||
@ -704,7 +705,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-subject", "superuser-alex@hostsharing.net")
|
.header("current-subject", "superuser-alex@hostsharing.net")
|
||||||
.header("assumed-roles", "hs_office.contact#tenthcontact:ADMIN")
|
.header("assumed-roles", givenDebitor.getDebitorRel().roleId(RbacRoleType.ADMIN) )
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user