diff --git a/src/main/resources/api-definition/hs-booking/hs-booking-item-schemas.yaml b/src/main/resources/api-definition/hs-booking/hs-booking-item-schemas.yaml index a9f946b7..06f8b921 100644 --- a/src/main/resources/api-definition/hs-booking/hs-booking-item-schemas.yaml +++ b/src/main/resources/api-definition/hs-booking/hs-booking-item-schemas.yaml @@ -21,7 +21,6 @@ components: $ref: '#/components/schemas/BookingResources' required: - uuid - - debitor - validFrom - validTo - resources diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java index 55bdbb2c..cbd56570 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java @@ -278,78 +278,6 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup return true; }); } - - @Test - void globalAdmin_canPatchJustValidToOfArbitraryBookingItem() { - - context.define("superuser-alex@hostsharing.net"); - final var givenBookingItem = givenSomeTemporaryBookingItemForDebitorNumber(1000111, entry("something", 1)); - - RestAssured // @formatter:off - .given() - .header("current-user", "superuser-alex@hostsharing.net") - .contentType(ContentType.JSON) - .body(""" - { - "validTo": "2022-12-31" - } - """) - .port(port) - .when() - .patch("http://localhost/api/hs/booking/items/" + givenBookingItem.getUuid()) - .then().log().all().assertThat() - .statusCode(200) - .contentType(ContentType.JSON) - .body("", lenientlyEquals(""" - { - "caption": "some test-booking", - "validFrom": "2022-11-01", - "validTo": "2022-12-31", - "resources": { - "something": 1 - } - } - """)); // @formatter:on - - // finally, the bookingItem is actually updated - assertThat(bookingItemRepo.findByUuid(givenBookingItem.getUuid())).isPresent().get() - .matches(mandate -> { - assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: rel(anchor='LP First GmbH', type='DEBITOR', holder='LP First GmbH'), fir)"); - assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2023-01-01)"); - return true; - }); - } - - @Test - void globalAdmin_canNotPatchReferenceOfArbitraryBookingItem() { - - context.define("superuser-alex@hostsharing.net"); - final var givenBookingItem = givenSomeTemporaryBookingItemForDebitorNumber(1000111, entry("something", 1)); - - final var location = RestAssured // @formatter:off - .given() - .header("current-user", "superuser-alex@hostsharing.net") - .contentType(ContentType.JSON) - .body(""" - { - "reference": "temp ref CAT new" - } - """) - .port(port) - .when() - .patch("http://localhost/api/hs/booking/items/" + givenBookingItem.getUuid()) - .then().assertThat() - // TODO.impl: I'd prefer a 400, - // but OpenApi Spring Code Gen does not convert additonalProperties=false into a validation - .statusCode(200); // @formatter:on - - // finally, the bookingItem is actually updated - assertThat(bookingItemRepo.findByUuid(givenBookingItem.getUuid())).isPresent().get() - .matches(mandate -> { - assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2023-03-31)"); - return true; - }); - } } @Nested diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepositoryIntegrationTest.java index ad112896..9a5eaf00 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepositoryIntegrationTest.java @@ -121,17 +121,17 @@ class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup "{ grant perm:hs_booking_item#D-1000111:some new booking item:DELETE to role:global#global:ADMIN by system and assume }", // owner + "{ grant perm:hs_booking_item#D-1000111:some new booking item:UPDATE to role:hs_booking_item#D-1000111:some new booking item:OWNER by system and assume }", + "{ grant role:hs_booking_item#D-1000111:some new booking item:OWNER to role:relation#FirstGmbH-with-DEBITOR-FirstGmbH:AGENT by system and assume }", // admin + "{ grant role:hs_booking_item#D-1000111:some new booking item:ADMIN to role:hs_booking_item#D-1000111:some new booking item:OWNER by system and assume }", // tenant - - "{ grant perm:hs_booking_item#D-1000111:some new booking item:SELECT to role:hs_booking_item#D-1000111:some new booking item:TENANT by system and assume }", - "{ grant perm:hs_booking_item#D-1000111:some new booking item:UPDATE to role:hs_booking_item#D-1000111:some new booking item:OWNER by system and assume }", - "{ grant role:hs_booking_item#D-1000111:some new booking item:ADMIN to role:hs_booking_item#D-1000111:some new booking item:OWNER by system and assume }", - "{ grant role:hs_booking_item#D-1000111:some new booking item:OWNER to role:relation#FirstGmbH-with-DEBITOR-FirstGmbH:AGENT by system and assume }", "{ grant role:hs_booking_item#D-1000111:some new booking item:TENANT to role:hs_booking_item#D-1000111:some new booking item:ADMIN by system and assume }", + "{ grant perm:hs_booking_item#D-1000111:some new booking item:SELECT to role:hs_booking_item#D-1000111:some new booking item:TENANT by system and assume }", "{ grant role:relation#FirstGmbH-with-DEBITOR-FirstGmbH:TENANT to role:hs_booking_item#D-1000111:some new booking item:TENANT by system and assume }", + null)); } @@ -299,8 +299,8 @@ class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup // then assertThat(customerLogEntries).map(Arrays::toString).contains( "[creating booking-item test-data 1000111, hs_booking_item, INSERT]", - "[creating booking-item test-data 1000111, hs_booking_item, INSERT]", - "[creating booking-item test-data 1000111, hs_booking_item, INSERT]"); + "[creating booking-item test-data 1000212, hs_booking_item, INSERT]", + "[creating booking-item test-data 1000313, hs_booking_item, INSERT]"); } private HsBookingItemEntity givenSomeTemporaryBookingItem(final int debitorNumber) {