fix some tests
This commit is contained in:
parent
29fdad5f31
commit
98945bfbd2
@ -1,26 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.managedserver;
|
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.Repository;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface HsManagedServerRepository extends Repository<HsManagedServerEntity, UUID> {
|
|
||||||
|
|
||||||
List<HsManagedServerEntity> findAll();
|
|
||||||
Optional<HsManagedServerEntity> findByUuid(final UUID managedServerUuid);
|
|
||||||
|
|
||||||
@Query("""
|
|
||||||
SELECT s FROM HsManagedServerEntity s
|
|
||||||
WHERE s.bookingItem.debitor.uuid = :debitorUuid
|
|
||||||
""")
|
|
||||||
List<HsManagedServerEntity> findAllByDebitorUuid(final UUID debitorUuid);
|
|
||||||
|
|
||||||
HsManagedServerEntity save(HsManagedServerEntity current);
|
|
||||||
|
|
||||||
int deleteByUuid(final UUID uuid);
|
|
||||||
|
|
||||||
long count();
|
|
||||||
}
|
|
@ -1,11 +1,11 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.managedserver;
|
package net.hostsharing.hsadminng.hs.hosting.server;
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.api.HsHostingManagedserversApi;
|
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.api.HsHostingServersApi;
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.context.Context;
|
import net.hostsharing.hsadminng.context.Context;
|
||||||
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsManagedServerInsertResource;
|
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsServerInsertResource;
|
||||||
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsManagedServerPatchResource;
|
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsServerPatchResource;
|
||||||
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsManagedServerResource;
|
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsServerResource;
|
||||||
import net.hostsharing.hsadminng.mapper.KeyValueMap;
|
import net.hostsharing.hsadminng.mapper.KeyValueMap;
|
||||||
import net.hostsharing.hsadminng.mapper.Mapper;
|
import net.hostsharing.hsadminng.mapper.Mapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -21,7 +21,7 @@ import java.util.function.BiConsumer;
|
|||||||
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange;
|
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class HsManagedServerController implements HsHostingManagedserversApi {
|
public class HsHostingServerController implements HsHostingServersApi {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Context context;
|
private Context context;
|
||||||
@ -30,70 +30,70 @@ public class HsManagedServerController implements HsHostingManagedserversApi {
|
|||||||
private Mapper mapper;
|
private Mapper mapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HsManagedServerRepository managedServerRepo;
|
private HsHostingServerRepository serverRepo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public ResponseEntity<List<HsManagedServerResource>> listManagedServersByDebitorUuid(
|
public ResponseEntity<List<HsServerResource>> listServersByDebitorUuid(
|
||||||
final String currentUser,
|
final String currentUser,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
final UUID debitorUuid) {
|
final UUID debitorUuid) {
|
||||||
context.define(currentUser, assumedRoles);
|
context.define(currentUser, assumedRoles);
|
||||||
|
|
||||||
final var entities = managedServerRepo.findAllByDebitorUuid(debitorUuid);
|
final var entities = serverRepo.findAllByDebitorUuid(debitorUuid);
|
||||||
|
|
||||||
final var resources = mapper.mapList(entities, HsManagedServerResource.class, ENTITY_TO_RESOURCE_POSTMAPPER);
|
final var resources = mapper.mapList(entities, HsServerResource.class, ENTITY_TO_RESOURCE_POSTMAPPER);
|
||||||
return ResponseEntity.ok(resources);
|
return ResponseEntity.ok(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResponseEntity<HsManagedServerResource> addManagedServer(
|
public ResponseEntity<HsServerResource> addServer(
|
||||||
final String currentUser,
|
final String currentUser,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
final HsManagedServerInsertResource body) {
|
final HsServerInsertResource body) {
|
||||||
|
|
||||||
context.define(currentUser, assumedRoles);
|
context.define(currentUser, assumedRoles);
|
||||||
|
|
||||||
final var entityToSave = mapper.map(body, HsManagedServerEntity.class, RESOURCE_TO_ENTITY_POSTMAPPER);
|
final var entityToSave = mapper.map(body, HsHostingServerEntity.class, RESOURCE_TO_ENTITY_POSTMAPPER);
|
||||||
|
|
||||||
final var saved = managedServerRepo.save(entityToSave);
|
final var saved = serverRepo.save(entityToSave);
|
||||||
|
|
||||||
final var uri =
|
final var uri =
|
||||||
MvcUriComponentsBuilder.fromController(getClass())
|
MvcUriComponentsBuilder.fromController(getClass())
|
||||||
.path("/api/hs/hosting/managedservers/{id}")
|
.path("/api/hs/hosting/servers/{id}")
|
||||||
.buildAndExpand(saved.getUuid())
|
.buildAndExpand(saved.getUuid())
|
||||||
.toUri();
|
.toUri();
|
||||||
final var mapped = mapper.map(saved, HsManagedServerResource.class, ENTITY_TO_RESOURCE_POSTMAPPER);
|
final var mapped = mapper.map(saved, HsServerResource.class, ENTITY_TO_RESOURCE_POSTMAPPER);
|
||||||
return ResponseEntity.created(uri).body(mapped);
|
return ResponseEntity.created(uri).body(mapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public ResponseEntity<HsManagedServerResource> getManagedServerByUuid(
|
public ResponseEntity<HsServerResource> getServerByUuid(
|
||||||
final String currentUser,
|
final String currentUser,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
final UUID managedServerUuid) {
|
final UUID serverUuid) {
|
||||||
|
|
||||||
context.define(currentUser, assumedRoles);
|
context.define(currentUser, assumedRoles);
|
||||||
|
|
||||||
final var result = managedServerRepo.findByUuid(managedServerUuid);
|
final var result = serverRepo.findByUuid(serverUuid);
|
||||||
return result
|
return result
|
||||||
.map(managedServerEntity -> ResponseEntity.ok(
|
.map(serverEntity -> ResponseEntity.ok(
|
||||||
mapper.map(managedServerEntity, HsManagedServerResource.class, ENTITY_TO_RESOURCE_POSTMAPPER)))
|
mapper.map(serverEntity, HsServerResource.class, ENTITY_TO_RESOURCE_POSTMAPPER)))
|
||||||
.orElseGet(() -> ResponseEntity.notFound().build());
|
.orElseGet(() -> ResponseEntity.notFound().build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResponseEntity<Void> deleteManagedServerUuid(
|
public ResponseEntity<Void> deleteServerUuid(
|
||||||
final String currentUser,
|
final String currentUser,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
final UUID managedServerUuid) {
|
final UUID serverUuid) {
|
||||||
context.define(currentUser, assumedRoles);
|
context.define(currentUser, assumedRoles);
|
||||||
|
|
||||||
final var result = managedServerRepo.deleteByUuid(managedServerUuid);
|
final var result = serverRepo.deleteByUuid(serverUuid);
|
||||||
return result == 0
|
return result == 0
|
||||||
? ResponseEntity.notFound().build()
|
? ResponseEntity.notFound().build()
|
||||||
: ResponseEntity.noContent().build();
|
: ResponseEntity.noContent().build();
|
||||||
@ -101,24 +101,24 @@ public class HsManagedServerController implements HsHostingManagedserversApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResponseEntity<HsManagedServerResource> patchManagedServer(
|
public ResponseEntity<HsServerResource> patchServer(
|
||||||
final String currentUser,
|
final String currentUser,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
final UUID managedServerUuid,
|
final UUID serverUuid,
|
||||||
final HsManagedServerPatchResource body) {
|
final HsServerPatchResource body) {
|
||||||
|
|
||||||
context.define(currentUser, assumedRoles);
|
context.define(currentUser, assumedRoles);
|
||||||
|
|
||||||
final var current = managedServerRepo.findByUuid(managedServerUuid).orElseThrow();
|
final var current = serverRepo.findByUuid(serverUuid).orElseThrow();
|
||||||
|
|
||||||
new HsManagedServerEntityPatcher(current).apply(body);
|
new HsHostingServerEntityPatcher(current).apply(body);
|
||||||
|
|
||||||
final var saved = managedServerRepo.save(current);
|
final var saved = serverRepo.save(current);
|
||||||
final var mapped = mapper.map(saved, HsManagedServerResource.class, ENTITY_TO_RESOURCE_POSTMAPPER);
|
final var mapped = mapper.map(saved, HsServerResource.class, ENTITY_TO_RESOURCE_POSTMAPPER);
|
||||||
return ResponseEntity.ok(mapped);
|
return ResponseEntity.ok(mapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
final BiConsumer<HsManagedServerEntity, HsManagedServerResource> ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
|
final BiConsumer<HsHostingServerEntity, HsServerResource> ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
|
||||||
resource.setValidFrom(entity.getValidity().lower());
|
resource.setValidFrom(entity.getValidity().lower());
|
||||||
if (entity.getValidity().hasUpperBound()) {
|
if (entity.getValidity().hasUpperBound()) {
|
||||||
resource.setValidTo(entity.getValidity().upper().minusDays(1));
|
resource.setValidTo(entity.getValidity().upper().minusDays(1));
|
||||||
@ -126,7 +126,7 @@ public class HsManagedServerController implements HsHostingManagedserversApi {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final BiConsumer<HsManagedServerInsertResource, HsManagedServerEntity> RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> {
|
final BiConsumer<HsServerInsertResource, HsHostingServerEntity> RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> {
|
||||||
entity.setValidity(toPostgresDateRange(resource.getValidFrom(), resource.getValidTo()));
|
entity.setValidity(toPostgresDateRange(resource.getValidFrom(), resource.getValidTo()));
|
||||||
entity.putConfig(KeyValueMap.from(resource.getConfig()));
|
entity.putConfig(KeyValueMap.from(resource.getConfig()));
|
||||||
};
|
};
|
@ -1,4 +1,4 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.managedserver;
|
package net.hostsharing.hsadminng.hs.hosting.server;
|
||||||
|
|
||||||
import io.hypersistence.utils.hibernate.type.json.JsonType;
|
import io.hypersistence.utils.hibernate.type.json.JsonType;
|
||||||
import io.hypersistence.utils.hibernate.type.range.PostgreSQLRangeType;
|
import io.hypersistence.utils.hibernate.type.range.PostgreSQLRangeType;
|
||||||
@ -52,18 +52,18 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
|||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "hs_hosting_managedserver_rv")
|
@Table(name = "hs_hosting_server_rv")
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class HsManagedServerEntity implements Stringifyable, RbacObject {
|
public class HsHostingServerEntity implements Stringifyable, RbacObject {
|
||||||
|
|
||||||
private static Stringify<HsManagedServerEntity> stringify = stringify(HsManagedServerEntity.class)
|
private static Stringify<HsHostingServerEntity> stringify = stringify(HsHostingServerEntity.class)
|
||||||
.withProp(e -> e.getBookingItem().toShortString())
|
.withProp(e -> e.getBookingItem().toShortString())
|
||||||
.withProp(e -> e.getValidity().asString())
|
.withProp(e -> e.getValidity().asString())
|
||||||
.withProp(HsManagedServerEntity::getCaption)
|
.withProp(HsHostingServerEntity::getCaption)
|
||||||
.withProp(HsManagedServerEntity::getConfig)
|
.withProp(HsHostingServerEntity::getConfig)
|
||||||
.quotedValues(false);
|
.quotedValues(false);
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ -136,10 +136,10 @@ public class HsManagedServerEntity implements Stringifyable, RbacObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static RbacView rbac() {
|
public static RbacView rbac() {
|
||||||
return rbacViewFor("managedServer", HsManagedServerEntity.class)
|
return rbacViewFor("server", HsHostingServerEntity.class)
|
||||||
.withIdentityView(SQL.query("""
|
.withIdentityView(SQL.query("""
|
||||||
SELECT server.uuid as uuid, bookingItemIV.idName || ':' || cleanIdentifier(server.caption) as idName
|
SELECT server.uuid as uuid, bookingItemIV.idName || ':' || cleanIdentifier(server.caption) as idName
|
||||||
FROM hs_hosting_managedserver server
|
FROM hs_hosting_server server
|
||||||
JOIN hs_booking_item_iv bookingItemIV ON bookingItemIV.uuid = server.bookingItemUuid
|
JOIN hs_booking_item_iv bookingItemIV ON bookingItemIV.uuid = server.bookingItemUuid
|
||||||
"""))
|
"""))
|
||||||
.withRestrictedViewOrderBy(SQL.expression("validity"))
|
.withRestrictedViewOrderBy(SQL.expression("validity"))
|
||||||
@ -164,6 +164,6 @@ public class HsManagedServerEntity implements Stringifyable, RbacObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
rbac().generateWithBaseFileName("7-hs-hosting/701-hosting-managedserver/7013-hs-hosting-managedserver-rbac");
|
rbac().generateWithBaseFileName("7-hs-hosting/701-hosting-server/7013-hs-hosting-server-rbac");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.managedserver;
|
package net.hostsharing.hsadminng.hs.hosting.server;
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsManagedServerPatchResource;
|
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsServerPatchResource;
|
||||||
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
||||||
import net.hostsharing.hsadminng.mapper.KeyValueMap;
|
import net.hostsharing.hsadminng.mapper.KeyValueMap;
|
||||||
import net.hostsharing.hsadminng.mapper.OptionalFromJson;
|
import net.hostsharing.hsadminng.mapper.OptionalFromJson;
|
||||||
@ -8,16 +8,16 @@ import net.hostsharing.hsadminng.mapper.OptionalFromJson;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
public class HsManagedServerEntityPatcher implements EntityPatcher<HsManagedServerPatchResource> {
|
public class HsHostingServerEntityPatcher implements EntityPatcher<HsServerPatchResource> {
|
||||||
|
|
||||||
private final HsManagedServerEntity entity;
|
private final HsHostingServerEntity entity;
|
||||||
|
|
||||||
public HsManagedServerEntityPatcher(final HsManagedServerEntity entity) {
|
public HsHostingServerEntityPatcher(final HsHostingServerEntity entity) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(final HsManagedServerPatchResource resource) {
|
public void apply(final HsServerPatchResource resource) {
|
||||||
OptionalFromJson.of(resource.getCaption())
|
OptionalFromJson.of(resource.getCaption())
|
||||||
.ifPresent(entity::setCaption);
|
.ifPresent(entity::setCaption);
|
||||||
Optional.ofNullable(resource.getConfig())
|
Optional.ofNullable(resource.getConfig())
|
@ -0,0 +1,26 @@
|
|||||||
|
package net.hostsharing.hsadminng.hs.hosting.server;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface HsHostingServerRepository extends Repository<HsHostingServerEntity, UUID> {
|
||||||
|
|
||||||
|
List<HsHostingServerEntity> findAll();
|
||||||
|
Optional<HsHostingServerEntity> findByUuid(final UUID serverUuid);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT s FROM HsHostingServerEntity s
|
||||||
|
WHERE s.bookingItem.debitor.uuid = :debitorUuid
|
||||||
|
""")
|
||||||
|
List<HsHostingServerEntity> findAllByDebitorUuid(final UUID debitorUuid);
|
||||||
|
|
||||||
|
HsHostingServerEntity save(HsHostingServerEntity current);
|
||||||
|
|
||||||
|
int deleteByUuid(final UUID uuid);
|
||||||
|
|
||||||
|
long count();
|
||||||
|
}
|
@ -69,10 +69,10 @@ components:
|
|||||||
|
|
||||||
BookingResources:
|
BookingResources:
|
||||||
anyOf:
|
anyOf:
|
||||||
- $ref: '#/components/schemas/ManagedServerBookingResources'
|
- $ref: '#/components/schemas/ServerBookingResources'
|
||||||
- $ref: '#/components/schemas/ManagedWebspaceBookingResources'
|
- $ref: '#/components/schemas/ManagedWebspaceBookingResources'
|
||||||
|
|
||||||
ManagedServerBookingResources:
|
ServerBookingResources:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
CPU:
|
CPU:
|
||||||
|
@ -13,5 +13,5 @@ map:
|
|||||||
- type: string:uuid => java.util.UUID
|
- type: string:uuid => java.util.UUID
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/api/hs/hosting/managedservers/{managedServerUuid}:
|
/api/hs/hosting/servers/{serverUuid}:
|
||||||
null: org.openapitools.jackson.nullable.JsonNullable
|
null: org.openapitools.jackson.nullable.JsonNullable
|
||||||
|
@ -3,7 +3,7 @@ components:
|
|||||||
|
|
||||||
schemas:
|
schemas:
|
||||||
|
|
||||||
HsManagedServer:
|
HsServer:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
uuid:
|
uuid:
|
||||||
@ -18,14 +18,14 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
format: date
|
format: date
|
||||||
config:
|
config:
|
||||||
$ref: '#/components/schemas/ManagedServerConfiguration'
|
$ref: '#/components/schemas/ServerConfiguration'
|
||||||
required:
|
required:
|
||||||
- uuid
|
- uuid
|
||||||
- validFrom
|
- validFrom
|
||||||
- validTo
|
- validTo
|
||||||
- config
|
- config
|
||||||
|
|
||||||
HsManagedServerPatch:
|
HsServerPatch:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
caption:
|
caption:
|
||||||
@ -36,9 +36,9 @@ components:
|
|||||||
format: date
|
format: date
|
||||||
nullable: true
|
nullable: true
|
||||||
config:
|
config:
|
||||||
$ref: '#/components/schemas/ManagedServerConfiguration'
|
$ref: '#/components/schemas/ServerConfiguration'
|
||||||
|
|
||||||
HsManagedServerInsert:
|
HsServerInsert:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
bookingItemUuid:
|
bookingItemUuid:
|
||||||
@ -59,7 +59,7 @@ components:
|
|||||||
format: date
|
format: date
|
||||||
nullable: true
|
nullable: true
|
||||||
config:
|
config:
|
||||||
$ref: '#/components/schemas/ManagedServerConfiguration'
|
$ref: '#/components/schemas/ServerConfiguration'
|
||||||
required:
|
required:
|
||||||
- caption
|
- caption
|
||||||
- debitorUuid
|
- debitorUuid
|
||||||
@ -67,8 +67,8 @@ components:
|
|||||||
- config
|
- config
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
|
||||||
ManagedServerConfiguration:
|
ServerConfiguration:
|
||||||
# forces generating a java.lang.Object containing a Map, instead of class ManagedServerConfiguration
|
# forces generating a java.lang.Object containing a Map, instead of class ServerConfiguration
|
||||||
anyOf:
|
anyOf:
|
||||||
- type: object
|
- type: object
|
||||||
properties:
|
properties:
|
@ -1,12 +1,12 @@
|
|||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- hs-hosting-managedservers
|
- hs-hosting-servers
|
||||||
description: 'Fetch a single managed server by its uuid, if visible for the current subject.'
|
description: 'Fetch a single managed server by its uuid, if visible for the current subject.'
|
||||||
operationId: getManagedServerByUuid
|
operationId: getServerByUuid
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
||||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||||
- name: managedServerUuid
|
- name: serverUuid
|
||||||
in: path
|
in: path
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
@ -19,7 +19,7 @@ get:
|
|||||||
content:
|
content:
|
||||||
'application/json':
|
'application/json':
|
||||||
schema:
|
schema:
|
||||||
$ref: 'hs-hosting-managedserver-schemas.yaml#/components/schemas/HsManagedServer'
|
$ref: 'hs-hosting-server-schemas.yaml#/components/schemas/HsServer'
|
||||||
|
|
||||||
"401":
|
"401":
|
||||||
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
|
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
|
||||||
@ -28,13 +28,13 @@ get:
|
|||||||
|
|
||||||
patch:
|
patch:
|
||||||
tags:
|
tags:
|
||||||
- hs-hosting-managedservers
|
- hs-hosting-servers
|
||||||
description: 'Updates a single managed server identified by its uuid, if permitted for the current subject.'
|
description: 'Updates a single managed server identified by its uuid, if permitted for the current subject.'
|
||||||
operationId: patchManagedServer
|
operationId: patchServer
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
||||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||||
- name: managedServerUuid
|
- name: serverUuid
|
||||||
in: path
|
in: path
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
@ -44,14 +44,14 @@ patch:
|
|||||||
content:
|
content:
|
||||||
'application/json':
|
'application/json':
|
||||||
schema:
|
schema:
|
||||||
$ref: 'hs-hosting-managedserver-schemas.yaml#/components/schemas/HsManagedServerPatch'
|
$ref: 'hs-hosting-server-schemas.yaml#/components/schemas/HsServerPatch'
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
content:
|
content:
|
||||||
'application/json':
|
'application/json':
|
||||||
schema:
|
schema:
|
||||||
$ref: 'hs-hosting-managedserver-schemas.yaml#/components/schemas/HsManagedServer'
|
$ref: 'hs-hosting-server-schemas.yaml#/components/schemas/HsServer'
|
||||||
"401":
|
"401":
|
||||||
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
|
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
|
||||||
"403":
|
"403":
|
||||||
@ -59,13 +59,13 @@ patch:
|
|||||||
|
|
||||||
delete:
|
delete:
|
||||||
tags:
|
tags:
|
||||||
- hs-hosting-managedservers
|
- hs-hosting-servers
|
||||||
description: 'Delete a single managed server identified by its uuid, if permitted for the current subject.'
|
description: 'Delete a single managed server identified by its uuid, if permitted for the current subject.'
|
||||||
operationId: deleteManagedServerUuid
|
operationId: deleteServerUuid
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
||||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||||
- name: managedServerUuid
|
- name: serverUuid
|
||||||
in: path
|
in: path
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
@ -2,8 +2,8 @@ get:
|
|||||||
summary: Returns a list of all managed servers for a specified debitor.
|
summary: Returns a list of all managed servers for a specified debitor.
|
||||||
description: Returns the list of all managed servers for a debitor which are visible to the current user or any of it's assumed roles.
|
description: Returns the list of all managed servers for a debitor which are visible to the current user or any of it's assumed roles.
|
||||||
tags:
|
tags:
|
||||||
- hs-hosting-managedservers
|
- hs-hosting-servers
|
||||||
operationId: listManagedServersByDebitorUuid
|
operationId: listServersByDebitorUuid
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
||||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||||
@ -22,7 +22,7 @@ get:
|
|||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: 'hs-hosting-managedserver-schemas.yaml#/components/schemas/HsManagedServer'
|
$ref: 'hs-hosting-server-schemas.yaml#/components/schemas/HsServer'
|
||||||
"401":
|
"401":
|
||||||
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
|
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
|
||||||
"403":
|
"403":
|
||||||
@ -31,8 +31,8 @@ get:
|
|||||||
post:
|
post:
|
||||||
summary: Adds a new managed server.
|
summary: Adds a new managed server.
|
||||||
tags:
|
tags:
|
||||||
- hs-hosting-managedservers
|
- hs-hosting-servers
|
||||||
operationId: addManagedServer
|
operationId: addServer
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
- $ref: 'auth.yaml#/components/parameters/currentUser'
|
||||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||||
@ -42,14 +42,14 @@ post:
|
|||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: 'hs-hosting-managedserver-schemas.yaml#/components/schemas/HsManagedServerInsert'
|
$ref: 'hs-hosting-server-schemas.yaml#/components/schemas/HsServerInsert'
|
||||||
responses:
|
responses:
|
||||||
"201":
|
"201":
|
||||||
description: Created
|
description: Created
|
||||||
content:
|
content:
|
||||||
'application/json':
|
'application/json':
|
||||||
schema:
|
schema:
|
||||||
$ref: 'hs-hosting-managedserver-schemas.yaml#/components/schemas/HsManagedServer'
|
$ref: 'hs-hosting-server-schemas.yaml#/components/schemas/HsServer'
|
||||||
"401":
|
"401":
|
||||||
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
|
$ref: 'error-responses.yaml#/components/responses/Unauthorized'
|
||||||
"403":
|
"403":
|
@ -10,8 +10,8 @@ paths:
|
|||||||
|
|
||||||
# Items
|
# Items
|
||||||
|
|
||||||
/api/hs/hosting/managedservers:
|
/api/hs/hosting/servers:
|
||||||
$ref: "hs-hosting-managedservers.yaml"
|
$ref: "hs-hosting-servers.yaml"
|
||||||
|
|
||||||
/api/hs/hosting/managedservers/{managedServerUuid}:
|
/api/hs/hosting/servers/{serverUuid}:
|
||||||
$ref: "hs-hosting-managedservers-with-uuid.yaml"
|
$ref: "hs-hosting-servers-with-uuid.yaml"
|
||||||
|
@ -1,302 +0,0 @@
|
|||||||
### rbac managedServer
|
|
||||||
|
|
||||||
This code generated was by RbacViewMermaidFlowchartGenerator, do not amend manually.
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
%%{init:{'flowchart':{'htmlLabels':false}}}%%
|
|
||||||
flowchart TB
|
|
||||||
|
|
||||||
subgraph managedServer["`**managedServer**`"]
|
|
||||||
direction TB
|
|
||||||
style managedServer fill:#dd4901,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph managedServer:roles[ ]
|
|
||||||
style managedServer:roles fill:#dd4901,stroke:white
|
|
||||||
|
|
||||||
role:managedServer:OWNER[[managedServer:OWNER]]
|
|
||||||
role:managedServer:ADMIN[[managedServer:ADMIN]]
|
|
||||||
role:managedServer:TENANT[[managedServer:TENANT]]
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph managedServer:permissions[ ]
|
|
||||||
style managedServer:permissions fill:#dd4901,stroke:white
|
|
||||||
|
|
||||||
perm:managedServer:INSERT{{managedServer:INSERT}}
|
|
||||||
perm:managedServer:DELETE{{managedServer:DELETE}}
|
|
||||||
perm:managedServer:UPDATE{{managedServer:UPDATE}}
|
|
||||||
perm:managedServer:SELECT{{managedServer:SELECT}}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.debitorRel.anchorPerson["`**bookingItem.debitor.debitorRel.anchorPerson**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor.debitorRel.anchorPerson fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.debitorRel.anchorPerson:roles[ ]
|
|
||||||
style bookingItem.debitor.debitorRel.anchorPerson:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitor.debitorRel.anchorPerson:OWNER[[bookingItem.debitor.debitorRel.anchorPerson:OWNER]]
|
|
||||||
role:bookingItem.debitor.debitorRel.anchorPerson:ADMIN[[bookingItem.debitor.debitorRel.anchorPerson:ADMIN]]
|
|
||||||
role:bookingItem.debitor.debitorRel.anchorPerson:REFERRER[[bookingItem.debitor.debitorRel.anchorPerson:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.partnerRel.contact["`**bookingItem.debitor.partnerRel.contact**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor.partnerRel.contact fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.partnerRel.contact:roles[ ]
|
|
||||||
style bookingItem.debitor.partnerRel.contact:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitor.partnerRel.contact:OWNER[[bookingItem.debitor.partnerRel.contact:OWNER]]
|
|
||||||
role:bookingItem.debitor.partnerRel.contact:ADMIN[[bookingItem.debitor.partnerRel.contact:ADMIN]]
|
|
||||||
role:bookingItem.debitor.partnerRel.contact:REFERRER[[bookingItem.debitor.partnerRel.contact:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem["`**bookingItem**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem:roles[ ]
|
|
||||||
style bookingItem:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem:OWNER[[bookingItem:OWNER]]
|
|
||||||
role:bookingItem:ADMIN[[bookingItem:ADMIN]]
|
|
||||||
role:bookingItem:TENANT[[bookingItem:TENANT]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.partnerRel["`**bookingItem.debitor.partnerRel**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor.partnerRel fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.partnerRel:roles[ ]
|
|
||||||
style bookingItem.debitor.partnerRel:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitor.partnerRel:OWNER[[bookingItem.debitor.partnerRel:OWNER]]
|
|
||||||
role:bookingItem.debitor.partnerRel:ADMIN[[bookingItem.debitor.partnerRel:ADMIN]]
|
|
||||||
role:bookingItem.debitor.partnerRel:AGENT[[bookingItem.debitor.partnerRel:AGENT]]
|
|
||||||
role:bookingItem.debitor.partnerRel:TENANT[[bookingItem.debitor.partnerRel:TENANT]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.partnerRel.anchorPerson["`**bookingItem.debitor.partnerRel.anchorPerson**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor.partnerRel.anchorPerson fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.partnerRel.anchorPerson:roles[ ]
|
|
||||||
style bookingItem.debitor.partnerRel.anchorPerson:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitor.partnerRel.anchorPerson:OWNER[[bookingItem.debitor.partnerRel.anchorPerson:OWNER]]
|
|
||||||
role:bookingItem.debitor.partnerRel.anchorPerson:ADMIN[[bookingItem.debitor.partnerRel.anchorPerson:ADMIN]]
|
|
||||||
role:bookingItem.debitor.partnerRel.anchorPerson:REFERRER[[bookingItem.debitor.partnerRel.anchorPerson:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitorRel["`**bookingItem.debitorRel**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitorRel fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitorRel:roles[ ]
|
|
||||||
style bookingItem.debitorRel:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitorRel:OWNER[[bookingItem.debitorRel:OWNER]]
|
|
||||||
role:bookingItem.debitorRel:ADMIN[[bookingItem.debitorRel:ADMIN]]
|
|
||||||
role:bookingItem.debitorRel:AGENT[[bookingItem.debitorRel:AGENT]]
|
|
||||||
role:bookingItem.debitorRel:TENANT[[bookingItem.debitorRel:TENANT]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitorRel.anchorPerson["`**bookingItem.debitorRel.anchorPerson**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitorRel.anchorPerson fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitorRel.anchorPerson:roles[ ]
|
|
||||||
style bookingItem.debitorRel.anchorPerson:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitorRel.anchorPerson:OWNER[[bookingItem.debitorRel.anchorPerson:OWNER]]
|
|
||||||
role:bookingItem.debitorRel.anchorPerson:ADMIN[[bookingItem.debitorRel.anchorPerson:ADMIN]]
|
|
||||||
role:bookingItem.debitorRel.anchorPerson:REFERRER[[bookingItem.debitorRel.anchorPerson:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.partnerRel.holderPerson["`**bookingItem.debitor.partnerRel.holderPerson**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor.partnerRel.holderPerson fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.partnerRel.holderPerson:roles[ ]
|
|
||||||
style bookingItem.debitor.partnerRel.holderPerson:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitor.partnerRel.holderPerson:OWNER[[bookingItem.debitor.partnerRel.holderPerson:OWNER]]
|
|
||||||
role:bookingItem.debitor.partnerRel.holderPerson:ADMIN[[bookingItem.debitor.partnerRel.holderPerson:ADMIN]]
|
|
||||||
role:bookingItem.debitor.partnerRel.holderPerson:REFERRER[[bookingItem.debitor.partnerRel.holderPerson:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitorRel.contact["`**bookingItem.debitorRel.contact**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitorRel.contact fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitorRel.contact:roles[ ]
|
|
||||||
style bookingItem.debitorRel.contact:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitorRel.contact:OWNER[[bookingItem.debitorRel.contact:OWNER]]
|
|
||||||
role:bookingItem.debitorRel.contact:ADMIN[[bookingItem.debitorRel.contact:ADMIN]]
|
|
||||||
role:bookingItem.debitorRel.contact:REFERRER[[bookingItem.debitorRel.contact:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitorRel.holderPerson["`**bookingItem.debitorRel.holderPerson**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitorRel.holderPerson fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitorRel.holderPerson:roles[ ]
|
|
||||||
style bookingItem.debitorRel.holderPerson:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitorRel.holderPerson:OWNER[[bookingItem.debitorRel.holderPerson:OWNER]]
|
|
||||||
role:bookingItem.debitorRel.holderPerson:ADMIN[[bookingItem.debitorRel.holderPerson:ADMIN]]
|
|
||||||
role:bookingItem.debitorRel.holderPerson:REFERRER[[bookingItem.debitorRel.holderPerson:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.refundBankAccount["`**bookingItem.debitor.refundBankAccount**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor.refundBankAccount fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.refundBankAccount:roles[ ]
|
|
||||||
style bookingItem.debitor.refundBankAccount:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitor.refundBankAccount:OWNER[[bookingItem.debitor.refundBankAccount:OWNER]]
|
|
||||||
role:bookingItem.debitor.refundBankAccount:ADMIN[[bookingItem.debitor.refundBankAccount:ADMIN]]
|
|
||||||
role:bookingItem.debitor.refundBankAccount:REFERRER[[bookingItem.debitor.refundBankAccount:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.debitorRel.contact["`**bookingItem.debitor.debitorRel.contact**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor.debitorRel.contact fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.debitorRel.contact:roles[ ]
|
|
||||||
style bookingItem.debitor.debitorRel.contact:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitor.debitorRel.contact:OWNER[[bookingItem.debitor.debitorRel.contact:OWNER]]
|
|
||||||
role:bookingItem.debitor.debitorRel.contact:ADMIN[[bookingItem.debitor.debitorRel.contact:ADMIN]]
|
|
||||||
role:bookingItem.debitor.debitorRel.contact:REFERRER[[bookingItem.debitor.debitorRel.contact:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor["`**bookingItem.debitor**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.debitorRel.holderPerson["`**bookingItem.debitor.debitorRel.holderPerson**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor.debitorRel.holderPerson fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.debitorRel.holderPerson:roles[ ]
|
|
||||||
style bookingItem.debitor.debitorRel.holderPerson:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitor.debitorRel.holderPerson:OWNER[[bookingItem.debitor.debitorRel.holderPerson:OWNER]]
|
|
||||||
role:bookingItem.debitor.debitorRel.holderPerson:ADMIN[[bookingItem.debitor.debitorRel.holderPerson:ADMIN]]
|
|
||||||
role:bookingItem.debitor.debitorRel.holderPerson:REFERRER[[bookingItem.debitor.debitorRel.holderPerson:REFERRER]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.debitorRel["`**bookingItem.debitor.debitorRel**`"]
|
|
||||||
direction TB
|
|
||||||
style bookingItem.debitor.debitorRel fill:#99bcdb,stroke:#274d6e,stroke-width:8px
|
|
||||||
|
|
||||||
subgraph bookingItem.debitor.debitorRel:roles[ ]
|
|
||||||
style bookingItem.debitor.debitorRel:roles fill:#99bcdb,stroke:white
|
|
||||||
|
|
||||||
role:bookingItem.debitor.debitorRel:OWNER[[bookingItem.debitor.debitorRel:OWNER]]
|
|
||||||
role:bookingItem.debitor.debitorRel:ADMIN[[bookingItem.debitor.debitorRel:ADMIN]]
|
|
||||||
role:bookingItem.debitor.debitorRel:AGENT[[bookingItem.debitor.debitorRel:AGENT]]
|
|
||||||
role:bookingItem.debitor.debitorRel:TENANT[[bookingItem.debitor.debitorRel:TENANT]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
%% granting roles to roles
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitor.debitorRel.anchorPerson:OWNER
|
|
||||||
role:bookingItem.debitor.debitorRel.anchorPerson:OWNER -.-> role:bookingItem.debitor.debitorRel.anchorPerson:ADMIN
|
|
||||||
role:bookingItem.debitor.debitorRel.anchorPerson:ADMIN -.-> role:bookingItem.debitor.debitorRel.anchorPerson:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitor.debitorRel.holderPerson:OWNER
|
|
||||||
role:bookingItem.debitor.debitorRel.holderPerson:OWNER -.-> role:bookingItem.debitor.debitorRel.holderPerson:ADMIN
|
|
||||||
role:bookingItem.debitor.debitorRel.holderPerson:ADMIN -.-> role:bookingItem.debitor.debitorRel.holderPerson:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitor.debitorRel.contact:OWNER
|
|
||||||
role:bookingItem.debitor.debitorRel.contact:OWNER -.-> role:bookingItem.debitor.debitorRel.contact:ADMIN
|
|
||||||
role:bookingItem.debitor.debitorRel.contact:ADMIN -.-> role:bookingItem.debitor.debitorRel.contact:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitor.debitorRel:OWNER
|
|
||||||
role:bookingItem.debitor.debitorRel:OWNER -.-> role:bookingItem.debitor.debitorRel:ADMIN
|
|
||||||
role:bookingItem.debitor.debitorRel:ADMIN -.-> role:bookingItem.debitor.debitorRel:AGENT
|
|
||||||
role:bookingItem.debitor.debitorRel:AGENT -.-> role:bookingItem.debitor.debitorRel:TENANT
|
|
||||||
role:bookingItem.debitor.debitorRel.contact:ADMIN -.-> role:bookingItem.debitor.debitorRel:TENANT
|
|
||||||
role:bookingItem.debitor.debitorRel:TENANT -.-> role:bookingItem.debitor.debitorRel.anchorPerson:REFERRER
|
|
||||||
role:bookingItem.debitor.debitorRel:TENANT -.-> role:bookingItem.debitor.debitorRel.holderPerson:REFERRER
|
|
||||||
role:bookingItem.debitor.debitorRel:TENANT -.-> role:bookingItem.debitor.debitorRel.contact:REFERRER
|
|
||||||
role:bookingItem.debitor.debitorRel.anchorPerson:ADMIN -.-> role:bookingItem.debitor.debitorRel:OWNER
|
|
||||||
role:bookingItem.debitor.debitorRel.holderPerson:ADMIN -.-> role:bookingItem.debitor.debitorRel:AGENT
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitor.refundBankAccount:OWNER
|
|
||||||
role:bookingItem.debitor.refundBankAccount:OWNER -.-> role:bookingItem.debitor.refundBankAccount:ADMIN
|
|
||||||
role:bookingItem.debitor.refundBankAccount:ADMIN -.-> role:bookingItem.debitor.refundBankAccount:REFERRER
|
|
||||||
role:bookingItem.debitor.refundBankAccount:ADMIN -.-> role:bookingItem.debitor.debitorRel:AGENT
|
|
||||||
role:bookingItem.debitor.debitorRel:AGENT -.-> role:bookingItem.debitor.refundBankAccount:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitor.partnerRel.anchorPerson:OWNER
|
|
||||||
role:bookingItem.debitor.partnerRel.anchorPerson:OWNER -.-> role:bookingItem.debitor.partnerRel.anchorPerson:ADMIN
|
|
||||||
role:bookingItem.debitor.partnerRel.anchorPerson:ADMIN -.-> role:bookingItem.debitor.partnerRel.anchorPerson:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitor.partnerRel.holderPerson:OWNER
|
|
||||||
role:bookingItem.debitor.partnerRel.holderPerson:OWNER -.-> role:bookingItem.debitor.partnerRel.holderPerson:ADMIN
|
|
||||||
role:bookingItem.debitor.partnerRel.holderPerson:ADMIN -.-> role:bookingItem.debitor.partnerRel.holderPerson:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitor.partnerRel.contact:OWNER
|
|
||||||
role:bookingItem.debitor.partnerRel.contact:OWNER -.-> role:bookingItem.debitor.partnerRel.contact:ADMIN
|
|
||||||
role:bookingItem.debitor.partnerRel.contact:ADMIN -.-> role:bookingItem.debitor.partnerRel.contact:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitor.partnerRel:OWNER
|
|
||||||
role:bookingItem.debitor.partnerRel:OWNER -.-> role:bookingItem.debitor.partnerRel:ADMIN
|
|
||||||
role:bookingItem.debitor.partnerRel:ADMIN -.-> role:bookingItem.debitor.partnerRel:AGENT
|
|
||||||
role:bookingItem.debitor.partnerRel:AGENT -.-> role:bookingItem.debitor.partnerRel:TENANT
|
|
||||||
role:bookingItem.debitor.partnerRel.contact:ADMIN -.-> role:bookingItem.debitor.partnerRel:TENANT
|
|
||||||
role:bookingItem.debitor.partnerRel:TENANT -.-> role:bookingItem.debitor.partnerRel.anchorPerson:REFERRER
|
|
||||||
role:bookingItem.debitor.partnerRel:TENANT -.-> role:bookingItem.debitor.partnerRel.holderPerson:REFERRER
|
|
||||||
role:bookingItem.debitor.partnerRel:TENANT -.-> role:bookingItem.debitor.partnerRel.contact:REFERRER
|
|
||||||
role:bookingItem.debitor.partnerRel.anchorPerson:ADMIN -.-> role:bookingItem.debitor.partnerRel:OWNER
|
|
||||||
role:bookingItem.debitor.partnerRel.holderPerson:ADMIN -.-> role:bookingItem.debitor.partnerRel:AGENT
|
|
||||||
role:bookingItem.debitor.partnerRel:ADMIN -.-> role:bookingItem.debitor.debitorRel:ADMIN
|
|
||||||
role:bookingItem.debitor.partnerRel:AGENT -.-> role:bookingItem.debitor.debitorRel:AGENT
|
|
||||||
role:bookingItem.debitor.debitorRel:AGENT -.-> role:bookingItem.debitor.partnerRel:TENANT
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitorRel.anchorPerson:OWNER
|
|
||||||
role:bookingItem.debitorRel.anchorPerson:OWNER -.-> role:bookingItem.debitorRel.anchorPerson:ADMIN
|
|
||||||
role:bookingItem.debitorRel.anchorPerson:ADMIN -.-> role:bookingItem.debitorRel.anchorPerson:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitorRel.holderPerson:OWNER
|
|
||||||
role:bookingItem.debitorRel.holderPerson:OWNER -.-> role:bookingItem.debitorRel.holderPerson:ADMIN
|
|
||||||
role:bookingItem.debitorRel.holderPerson:ADMIN -.-> role:bookingItem.debitorRel.holderPerson:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitorRel.contact:OWNER
|
|
||||||
role:bookingItem.debitorRel.contact:OWNER -.-> role:bookingItem.debitorRel.contact:ADMIN
|
|
||||||
role:bookingItem.debitorRel.contact:ADMIN -.-> role:bookingItem.debitorRel.contact:REFERRER
|
|
||||||
role:global:ADMIN -.-> role:bookingItem.debitorRel:OWNER
|
|
||||||
role:bookingItem.debitorRel:OWNER -.-> role:bookingItem.debitorRel:ADMIN
|
|
||||||
role:bookingItem.debitorRel:ADMIN -.-> role:bookingItem.debitorRel:AGENT
|
|
||||||
role:bookingItem.debitorRel:AGENT -.-> role:bookingItem.debitorRel:TENANT
|
|
||||||
role:bookingItem.debitorRel.contact:ADMIN -.-> role:bookingItem.debitorRel:TENANT
|
|
||||||
role:bookingItem.debitorRel:TENANT -.-> role:bookingItem.debitorRel.anchorPerson:REFERRER
|
|
||||||
role:bookingItem.debitorRel:TENANT -.-> role:bookingItem.debitorRel.holderPerson:REFERRER
|
|
||||||
role:bookingItem.debitorRel:TENANT -.-> role:bookingItem.debitorRel.contact:REFERRER
|
|
||||||
role:bookingItem.debitorRel.anchorPerson:ADMIN -.-> role:bookingItem.debitorRel:OWNER
|
|
||||||
role:bookingItem.debitorRel.holderPerson:ADMIN -.-> role:bookingItem.debitorRel:AGENT
|
|
||||||
role:bookingItem.debitorRel:AGENT -.-> role:bookingItem:OWNER
|
|
||||||
role:bookingItem:OWNER -.-> role:bookingItem:ADMIN
|
|
||||||
role:bookingItem:ADMIN -.-> role:bookingItem:TENANT
|
|
||||||
role:bookingItem:TENANT -.-> role:bookingItem.debitorRel:TENANT
|
|
||||||
role:bookingItem:ADMIN ==> role:managedServer:OWNER
|
|
||||||
role:managedServer:OWNER ==> role:managedServer:ADMIN
|
|
||||||
role:managedServer:ADMIN ==> role:managedServer:TENANT
|
|
||||||
role:managedServer:TENANT ==> role:bookingItem:TENANT
|
|
||||||
|
|
||||||
%% granting permissions to roles
|
|
||||||
role:bookingItem:ADMIN ==> perm:managedServer:INSERT
|
|
||||||
role:global:ADMIN ==> perm:managedServer:DELETE
|
|
||||||
role:managedServer:OWNER ==> perm:managedServer:UPDATE
|
|
||||||
role:managedServer:TENANT ==> perm:managedServer:SELECT
|
|
||||||
|
|
||||||
```
|
|
@ -1,10 +1,10 @@
|
|||||||
--liquibase formatted sql
|
--liquibase formatted sql
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hosting-managedserver-MAIN-TABLE:1 endDelimiter:--//
|
--changeset hosting-server-MAIN-TABLE:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
create table if not exists hs_hosting_managedserver
|
create table if not exists hs_hosting_server
|
||||||
(
|
(
|
||||||
uuid uuid unique references RbacObject (uuid),
|
uuid uuid unique references RbacObject (uuid),
|
||||||
version int not null default 0,
|
version int not null default 0,
|
||||||
@ -17,8 +17,8 @@ create table if not exists hs_hosting_managedserver
|
|||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-hosting-managedserver-MAIN-TABLE-JOURNAL:1 endDelimiter:--//
|
--changeset hs-hosting-server-MAIN-TABLE-JOURNAL:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
call create_journal('hs_hosting_managedserver');
|
call create_journal('hs_hosting_server');
|
||||||
--//
|
--//
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-hosting-managedserver-TEST-DATA-GENERATOR:1 endDelimiter:--//
|
--changeset hs-hosting-server-TEST-DATA-GENERATOR:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates a single hs_hosting_managedserver test record.
|
Creates a single hs_hosting_server test record.
|
||||||
*/
|
*/
|
||||||
create or replace procedure createHsHostingManagedServerTestData(
|
create or replace procedure createHsHostingServerTestData(
|
||||||
givenPartnerNumber numeric,
|
givenPartnerNumber numeric,
|
||||||
givenDebitorSuffix char(2)
|
givenDebitorSuffix char(2)
|
||||||
)
|
)
|
||||||
@ -18,7 +18,7 @@ declare
|
|||||||
relatedDebitor hs_office_debitor;
|
relatedDebitor hs_office_debitor;
|
||||||
relatedBookingItem hs_booking_item;
|
relatedBookingItem hs_booking_item;
|
||||||
begin
|
begin
|
||||||
currentTask := 'creating hosting-managedserver test-data ' || givenPartnerNumber::text || givenDebitorSuffix;
|
currentTask := 'creating hosting-server test-data ' || givenPartnerNumber::text || givenDebitorSuffix;
|
||||||
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
|
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
|
||||||
execute format('set local hsadminng.currentTask to %L', currentTask);
|
execute format('set local hsadminng.currentTask to %L', currentTask);
|
||||||
|
|
||||||
@ -33,10 +33,10 @@ begin
|
|||||||
where item.debitoruuid = relatedDebitor.uuid
|
where item.debitoruuid = relatedDebitor.uuid
|
||||||
and item.caption = 'some PrivateCloud';
|
and item.caption = 'some PrivateCloud';
|
||||||
|
|
||||||
raise notice 'creating test hosting-managedserver: %', givenPartnerNumber::text || givenDebitorSuffix::text;
|
raise notice 'creating test hosting-server: %', givenPartnerNumber::text || givenDebitorSuffix::text;
|
||||||
raise notice '- using debitor (%): %', relatedDebitor.uuid, relatedDebitor;
|
raise notice '- using debitor (%): %', relatedDebitor.uuid, relatedDebitor;
|
||||||
insert
|
insert
|
||||||
into hs_hosting_managedserver (uuid, bookingitemuuid, caption, validity, config)
|
into hs_hosting_server (uuid, bookingitemuuid, caption, validity, config)
|
||||||
values (uuid_generate_v4(), relatedBookingItem.uuid, 'some ManagedServer', daterange('20221001', null, '[]'), '{ "CPU": 2, "SDD": 512, "extra": 42 }'::jsonb),
|
values (uuid_generate_v4(), relatedBookingItem.uuid, 'some ManagedServer', daterange('20221001', null, '[]'), '{ "CPU": 2, "SDD": 512, "extra": 42 }'::jsonb),
|
||||||
(uuid_generate_v4(), relatedBookingItem.uuid, 'another CloudServer', daterange('20230115', '20240415', '[)'), '{ "CPU": 2, "HDD": 1024, "extra": 42 }'::jsonb),
|
(uuid_generate_v4(), relatedBookingItem.uuid, 'another CloudServer', daterange('20230115', '20240415', '[)'), '{ "CPU": 2, "HDD": 1024, "extra": 42 }'::jsonb),
|
||||||
(uuid_generate_v4(), relatedBookingItem.uuid, 'some Whatever', daterange('20240401', null, '[]'), '{ "CPU": 1, "SDD": 512, "HDD": 2048, "extra": 42 }'::jsonb);
|
(uuid_generate_v4(), relatedBookingItem.uuid, 'some Whatever', daterange('20240401', null, '[]'), '{ "CPU": 1, "SDD": 512, "HDD": 2048, "extra": 42 }'::jsonb);
|
||||||
@ -45,13 +45,13 @@ end; $$;
|
|||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-hosting-managedserver-TEST-DATA-GENERATION:1 –context=dev,tc endDelimiter:--//
|
--changeset hs-hosting-server-TEST-DATA-GENERATION:1 –context=dev,tc endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
do language plpgsql $$
|
do language plpgsql $$
|
||||||
begin
|
begin
|
||||||
call createHsHostingManagedServerTestData(10001, '11');
|
call createHsHostingServerTestData(10001, '11');
|
||||||
call createHsHostingManagedServerTestData(10002, '12');
|
call createHsHostingServerTestData(10002, '12');
|
||||||
call createHsHostingManagedServerTestData(10003, '13');
|
call createHsHostingServerTestData(10003, '13');
|
||||||
end;
|
end;
|
||||||
$$;
|
$$;
|
@ -134,8 +134,8 @@ databaseChangeLog:
|
|||||||
- include:
|
- include:
|
||||||
file: db/changelog/6-hs-booking/601-booking-item/6018-hs-booking-item-test-data.sql
|
file: db/changelog/6-hs-booking/601-booking-item/6018-hs-booking-item-test-data.sql
|
||||||
- include:
|
- include:
|
||||||
file: db/changelog/7-hs-hosting/701-hosting-managedserver/7010-hs-hosting-managedserver.sql
|
file: db/changelog/7-hs-hosting/701-hosting-server/7010-hs-hosting-server.sql
|
||||||
- include:
|
- include:
|
||||||
file: db/changelog/7-hs-hosting/701-hosting-managedserver/7013-hs-hosting-managedserver-rbac.sql
|
file: db/changelog/7-hs-hosting/701-hosting-server/7013-hs-hosting-server-rbac.sql
|
||||||
- include:
|
- include:
|
||||||
file: db/changelog/7-hs-hosting/701-hosting-managedserver/7018-hs-hosting-managedserver-test-data.sql
|
file: db/changelog/7-hs-hosting/701-hosting-server/7018-hs-hosting-server-test-data.sql
|
||||||
|
@ -51,7 +51,7 @@ public class ArchitectureTest {
|
|||||||
"..hs.office.relation",
|
"..hs.office.relation",
|
||||||
"..hs.office.sepamandate",
|
"..hs.office.sepamandate",
|
||||||
"..hs.booking.item",
|
"..hs.booking.item",
|
||||||
"..hs.hosting.managedserver",
|
"..hs.hosting.server",
|
||||||
"..errors",
|
"..errors",
|
||||||
"..mapper",
|
"..mapper",
|
||||||
"..ping",
|
"..ping",
|
||||||
@ -131,6 +131,7 @@ public class ArchitectureTest {
|
|||||||
.resideInAnyPackage(
|
.resideInAnyPackage(
|
||||||
"..hs.office.(*)..",
|
"..hs.office.(*)..",
|
||||||
"..hs.booking.(*)..",
|
"..hs.booking.(*)..",
|
||||||
|
"..hs.hosting.(*)..",
|
||||||
"..rbac.rbacgrant" // TODO.test: just because of RbacGrantsDiagramServiceIntegrationTest
|
"..rbac.rbacgrant" // TODO.test: just because of RbacGrantsDiagramServiceIntegrationTest
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.managedserver;
|
package net.hostsharing.hsadminng.hs.hosting.server;
|
||||||
|
|
||||||
import io.hypersistence.utils.hibernate.type.range.Range;
|
import io.hypersistence.utils.hibernate.type.range.Range;
|
||||||
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsManagedServerPatchResource;
|
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsServerPatchResource;
|
||||||
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
|
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
|
||||||
import net.hostsharing.hsadminng.mapper.KeyValueMap;
|
import net.hostsharing.hsadminng.mapper.KeyValueMap;
|
||||||
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
|
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
|
||||||
@ -27,9 +27,9 @@ import static org.mockito.Mockito.lenient;
|
|||||||
|
|
||||||
@TestInstance(PER_CLASS)
|
@TestInstance(PER_CLASS)
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
class HsManagedServerEntityPatcherUnitTest extends PatchUnitTestBase<
|
class HsHostingServerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||||
HsManagedServerPatchResource,
|
HsServerPatchResource,
|
||||||
HsManagedServerEntity
|
HsHostingServerEntity
|
||||||
> {
|
> {
|
||||||
|
|
||||||
private static final UUID INITIAL_BOOKING_ITEM_UUID = UUID.randomUUID();
|
private static final UUID INITIAL_BOOKING_ITEM_UUID = UUID.randomUUID();
|
||||||
@ -62,13 +62,13 @@ class HsManagedServerEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
void initMocks() {
|
void initMocks() {
|
||||||
lenient().when(em.getReference(eq(HsOfficeDebitorEntity.class), any())).thenAnswer(invocation ->
|
lenient().when(em.getReference(eq(HsOfficeDebitorEntity.class), any())).thenAnswer(invocation ->
|
||||||
HsOfficeDebitorEntity.builder().uuid(invocation.getArgument(1)).build());
|
HsOfficeDebitorEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||||
lenient().when(em.getReference(eq(HsManagedServerEntity.class), any())).thenAnswer(invocation ->
|
lenient().when(em.getReference(eq(HsHostingServerEntity.class), any())).thenAnswer(invocation ->
|
||||||
HsManagedServerEntity.builder().uuid(invocation.getArgument(1)).build());
|
HsHostingServerEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HsManagedServerEntity newInitialEntity() {
|
protected HsHostingServerEntity newInitialEntity() {
|
||||||
final var entity = new HsManagedServerEntity();
|
final var entity = new HsHostingServerEntity();
|
||||||
entity.setUuid(INITIAL_BOOKING_ITEM_UUID);
|
entity.setUuid(INITIAL_BOOKING_ITEM_UUID);
|
||||||
entity.setBookingItem(TEST_BOOKING_ITEM);
|
entity.setBookingItem(TEST_BOOKING_ITEM);
|
||||||
entity.getConfig().putAll(KeyValueMap.from(INITIAL_CONFIG));
|
entity.getConfig().putAll(KeyValueMap.from(INITIAL_CONFIG));
|
||||||
@ -78,13 +78,13 @@ class HsManagedServerEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HsManagedServerPatchResource newPatchResource() {
|
protected HsServerPatchResource newPatchResource() {
|
||||||
return new HsManagedServerPatchResource();
|
return new HsServerPatchResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HsManagedServerEntityPatcher createPatcher(final HsManagedServerEntity managedServer) {
|
protected HsHostingServerEntityPatcher createPatcher(final HsHostingServerEntity server) {
|
||||||
return new HsManagedServerEntityPatcher(managedServer);
|
return new HsHostingServerEntityPatcher(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -92,21 +92,21 @@ class HsManagedServerEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
return Stream.of(
|
return Stream.of(
|
||||||
new JsonNullableProperty<>(
|
new JsonNullableProperty<>(
|
||||||
"caption",
|
"caption",
|
||||||
HsManagedServerPatchResource::setCaption,
|
HsServerPatchResource::setCaption,
|
||||||
PATCHED_CAPTION,
|
PATCHED_CAPTION,
|
||||||
HsManagedServerEntity::setCaption),
|
HsHostingServerEntity::setCaption),
|
||||||
new SimpleProperty<>(
|
new SimpleProperty<>(
|
||||||
"config",
|
"config",
|
||||||
HsManagedServerPatchResource::setConfig,
|
HsServerPatchResource::setConfig,
|
||||||
PATCH_CONFIG,
|
PATCH_CONFIG,
|
||||||
HsManagedServerEntity::putConfig,
|
HsHostingServerEntity::putConfig,
|
||||||
PATCHED_CONFIG)
|
PATCHED_CONFIG)
|
||||||
.notNullable(),
|
.notNullable(),
|
||||||
new JsonNullableProperty<>(
|
new JsonNullableProperty<>(
|
||||||
"validto",
|
"validto",
|
||||||
HsManagedServerPatchResource::setValidTo,
|
HsServerPatchResource::setValidTo,
|
||||||
PATCHED_VALID_TO,
|
PATCHED_VALID_TO,
|
||||||
HsManagedServerEntity::setValidTo)
|
HsHostingServerEntity::setValidTo)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.managedserver;
|
package net.hostsharing.hsadminng.hs.hosting.server;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@ -10,11 +10,11 @@ import static net.hostsharing.hsadminng.hs.booking.item.TestHsBookingItem.TEST_B
|
|||||||
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange;
|
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class HsManagedServerEntityUnitTest {
|
class HsHostingServerEntityUnitTest {
|
||||||
public static final LocalDate GIVEN_VALID_FROM = LocalDate.parse("2020-01-01");
|
public static final LocalDate GIVEN_VALID_FROM = LocalDate.parse("2020-01-01");
|
||||||
public static final LocalDate GIVEN_VALID_TO = LocalDate.parse("2030-12-31");
|
public static final LocalDate GIVEN_VALID_TO = LocalDate.parse("2030-12-31");
|
||||||
|
|
||||||
final HsManagedServerEntity givenManagedServer = HsManagedServerEntity.builder()
|
final HsHostingServerEntity givenServer = HsHostingServerEntity.builder()
|
||||||
.bookingItem(TEST_BOOKING_ITEM)
|
.bookingItem(TEST_BOOKING_ITEM)
|
||||||
.caption("some caption")
|
.caption("some caption")
|
||||||
.config(Map.ofEntries(
|
.config(Map.ofEntries(
|
||||||
@ -26,32 +26,32 @@ class HsManagedServerEntityUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void toStringContainsAllPropertiesAndResourcesSortedByKey() {
|
void toStringContainsAllPropertiesAndResourcesSortedByKey() {
|
||||||
final var result = givenManagedServer.toString();
|
final var result = givenServer.toString();
|
||||||
|
|
||||||
assertThat(result).isEqualTo(
|
assertThat(result).isEqualTo(
|
||||||
"HsManagedServerEntity(D-1000100:test booking item, [2020-01-01,2031-01-01), some caption, { CPUs: 2, HDD-storage: 2048, SSD-storage: 512 })");
|
"HsServerEntity(D-1000100:test booking item, [2020-01-01,2031-01-01), some caption, { CPUs: 2, HDD-storage: 2048, SSD-storage: 512 })");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void toShortStringContainsOnlyMemberNumberAndCaption() {
|
void toShortStringContainsOnlyMemberNumberAndCaption() {
|
||||||
final var result = givenManagedServer.toShortString();
|
final var result = givenServer.toShortString();
|
||||||
|
|
||||||
assertThat(result).isEqualTo("D-1000100:test booking item:some caption");
|
assertThat(result).isEqualTo("D-1000100:test booking item:some caption");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void settingValidFromKeepsValidTo() {
|
void settingValidFromKeepsValidTo() {
|
||||||
givenManagedServer.setValidFrom(LocalDate.parse("2023-12-31"));
|
givenServer.setValidFrom(LocalDate.parse("2023-12-31"));
|
||||||
assertThat(givenManagedServer.getValidFrom()).isEqualTo(LocalDate.parse("2023-12-31"));
|
assertThat(givenServer.getValidFrom()).isEqualTo(LocalDate.parse("2023-12-31"));
|
||||||
assertThat(givenManagedServer.getValidTo()).isEqualTo(GIVEN_VALID_TO);
|
assertThat(givenServer.getValidTo()).isEqualTo(GIVEN_VALID_TO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void settingValidToKeepsValidFrom() {
|
void settingValidToKeepsValidFrom() {
|
||||||
givenManagedServer.setValidTo(LocalDate.parse("2024-12-31"));
|
givenServer.setValidTo(LocalDate.parse("2024-12-31"));
|
||||||
assertThat(givenManagedServer.getValidFrom()).isEqualTo(GIVEN_VALID_FROM);
|
assertThat(givenServer.getValidFrom()).isEqualTo(GIVEN_VALID_FROM);
|
||||||
assertThat(givenManagedServer.getValidTo()).isEqualTo(LocalDate.parse("2024-12-31"));
|
assertThat(givenServer.getValidTo()).isEqualTo(LocalDate.parse("2024-12-31"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.managedserver;
|
package net.hostsharing.hsadminng.hs.hosting.server;
|
||||||
|
|
||||||
import io.hypersistence.utils.hibernate.type.range.Range;
|
import io.hypersistence.utils.hibernate.type.range.Range;
|
||||||
import net.hostsharing.hsadminng.context.Context;
|
import net.hostsharing.hsadminng.context.Context;
|
||||||
@ -35,10 +35,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
@DataJpaTest
|
@DataJpaTest
|
||||||
@Import({ Context.class, JpaAttempt.class })
|
@Import({ Context.class, JpaAttempt.class })
|
||||||
class HsManagedServerRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
class HsHostingServerRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsManagedServerRepository managedServerRepo;
|
HsHostingServerRepository serverRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsBookingItemRepository bookingItemRepo;
|
HsBookingItemRepository bookingItemRepo;
|
||||||
@ -62,32 +62,32 @@ class HsManagedServerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
HttpServletRequest request;
|
HttpServletRequest request;
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class CreateManagedServer {
|
class CreateServer {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHostsharingAdmin_withoutAssumedRole_canCreateNewManagedServer() {
|
public void testHostsharingAdmin_withoutAssumedRole_canCreateNewServer() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var count = managedServerRepo.count();
|
final var count = serverRepo.count();
|
||||||
final var givenBookingItem = givenBookingItem("First", "some CloudServer");
|
final var givenBookingItem = givenBookingItem("First", "some CloudServer");
|
||||||
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = attempt(em, () -> {
|
final var result = attempt(em, () -> {
|
||||||
final var newManagedServer = HsManagedServerEntity.builder()
|
final var newServer = HsHostingServerEntity.builder()
|
||||||
.bookingItem(givenBookingItem)
|
.bookingItem(givenBookingItem)
|
||||||
.caption("some new booking managedserver")
|
.caption("some new booking server")
|
||||||
.validity(Range.closedOpen(
|
.validity(Range.closedOpen(
|
||||||
LocalDate.parse("2020-01-01"), LocalDate.parse("2023-01-01")))
|
LocalDate.parse("2020-01-01"), LocalDate.parse("2023-01-01")))
|
||||||
.build();
|
.build();
|
||||||
return toCleanup(managedServerRepo.save(newManagedServer));
|
return toCleanup(serverRepo.save(newServer));
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertSuccessful();
|
result.assertSuccessful();
|
||||||
assertThat(result.returnedValue()).isNotNull().extracting(HsManagedServerEntity::getUuid).isNotNull();
|
assertThat(result.returnedValue()).isNotNull().extracting(HsHostingServerEntity::getUuid).isNotNull();
|
||||||
assertThatManagedServerIsPersisted(result.returnedValue());
|
assertThatServerIsPersisted(result.returnedValue());
|
||||||
assertThat(managedServerRepo.count()).isEqualTo(count + 1);
|
assertThat(serverRepo.count()).isEqualTo(count + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -102,47 +102,47 @@ class HsManagedServerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
attempt(em, () -> {
|
attempt(em, () -> {
|
||||||
final var newManagedServer = HsManagedServerEntity.builder()
|
final var newServer = HsHostingServerEntity.builder()
|
||||||
.bookingItem(givenBookingItem)
|
.bookingItem(givenBookingItem)
|
||||||
.caption("some new booking managedserver")
|
.caption("some new booking server")
|
||||||
.validity(Range.closedOpen(
|
.validity(Range.closedOpen(
|
||||||
LocalDate.parse("2020-01-01"), LocalDate.parse("2023-01-01")))
|
LocalDate.parse("2020-01-01"), LocalDate.parse("2023-01-01")))
|
||||||
.build();
|
.build();
|
||||||
return toCleanup(managedServerRepo.save(newManagedServer));
|
return toCleanup(serverRepo.save(newServer));
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
final var all = rawRoleRepo.findAll();
|
final var all = rawRoleRepo.findAll();
|
||||||
assertThat(distinctRoleNamesOf(all)).containsExactlyInAnyOrder(Array.from(
|
assertThat(distinctRoleNamesOf(all)).containsExactlyInAnyOrder(Array.from(
|
||||||
initialRoleNames,
|
initialRoleNames,
|
||||||
"hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:ADMIN",
|
"hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:ADMIN",
|
||||||
"hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:OWNER",
|
"hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:OWNER",
|
||||||
"hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:TENANT"));
|
"hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:TENANT"));
|
||||||
assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll()))
|
assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll()))
|
||||||
.map(s -> s.replace("hs_office_", ""))
|
.map(s -> s.replace("hs_office_", ""))
|
||||||
.containsExactlyInAnyOrder(fromFormatted(
|
.containsExactlyInAnyOrder(fromFormatted(
|
||||||
initialGrantNames,
|
initialGrantNames,
|
||||||
// global-admin
|
// global-admin
|
||||||
"{ grant perm:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:DELETE to role:global#global:ADMIN by system and assume }",
|
"{ grant perm:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:DELETE to role:global#global:ADMIN by system and assume }",
|
||||||
|
|
||||||
// owner
|
// owner
|
||||||
"{ grant perm:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:UPDATE to role:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:OWNER by system and assume }",
|
"{ grant perm:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:UPDATE to role:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:OWNER by system and assume }",
|
||||||
"{ grant role:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:OWNER to role:hs_booking_item#D-1000111:someCloudServer:ADMIN by system and assume }",
|
"{ grant role:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:OWNER to role:hs_booking_item#D-1000111:someCloudServer:ADMIN by system and assume }",
|
||||||
|
|
||||||
// admin
|
// admin
|
||||||
"{ grant role:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:ADMIN to role:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:OWNER by system and assume }",
|
"{ grant role:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:ADMIN to role:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:OWNER by system and assume }",
|
||||||
|
|
||||||
// tenant
|
// tenant
|
||||||
"{ grant role:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:TENANT to role:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:ADMIN by system and assume }",
|
"{ grant role:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:TENANT to role:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:ADMIN by system and assume }",
|
||||||
"{ grant perm:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:SELECT to role:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:TENANT by system and assume }",
|
"{ grant perm:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:SELECT to role:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:TENANT by system and assume }",
|
||||||
"{ grant role:hs_booking_item#D-1000111:someCloudServer:TENANT to role:hs_hosting_managedserver#D-1000111:someCloudServer:somenewbookingmanagedserver:TENANT by system and assume }",
|
"{ grant role:hs_booking_item#D-1000111:someCloudServer:TENANT to role:hs_hosting_server#D-1000111:someCloudServer:somenewbookingserver:TENANT by system and assume }",
|
||||||
|
|
||||||
null));
|
null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatManagedServerIsPersisted(final HsManagedServerEntity saved) {
|
private void assertThatServerIsPersisted(final HsHostingServerEntity saved) {
|
||||||
final var found = managedServerRepo.findByUuid(saved.getUuid());
|
final var found = serverRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().map(HsManagedServerEntity::toString).get().isEqualTo(saved.toString());
|
assertThat(found).isNotEmpty().map(HsHostingServerEntity::toString).get().isEqualTo(saved.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,71 +150,71 @@ class HsManagedServerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
class FindByDebitorUuid {
|
class FindByDebitorUuid {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void globalAdmin_withoutAssumedRole_canViewAllManagedServersOfArbitraryDebitor() {
|
public void globalAdmin_withoutAssumedRole_canViewAllServersOfArbitraryDebitor() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var debitorUuid = debitorRepo.findDebitorByDebitorNumber(1000212).stream()
|
final var debitorUuid = debitorRepo.findDebitorByDebitorNumber(1000212).stream()
|
||||||
.findAny().orElseThrow().getUuid();
|
.findAny().orElseThrow().getUuid();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = managedServerRepo.findAllByDebitorUuid(debitorUuid);
|
final var result = serverRepo.findAllByDebitorUuid(debitorUuid);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
allTheseManagedServersAreReturned(
|
allTheseServersAreReturned(
|
||||||
result,
|
result,
|
||||||
"HsManagedServerEntity(D-1000212:some PrivateCloud, [2022-10-01,), some ManagedServer, { CPU: 2, SDD: 512, extra: 42 })",
|
"HsServerEntity(D-1000212:some PrivateCloud, [2022-10-01,), some ManagedServer, { CPU: 2, SDD: 512, extra: 42 })",
|
||||||
"HsManagedServerEntity(D-1000212:some PrivateCloud, [2023-01-15,2024-04-15), another CloudServer, { CPU: 2, HDD: 1024, extra: 42 })",
|
"HsServerEntity(D-1000212:some PrivateCloud, [2023-01-15,2024-04-15), another CloudServer, { CPU: 2, HDD: 1024, extra: 42 })",
|
||||||
"HsManagedServerEntity(D-1000212:some PrivateCloud, [2024-04-01,), some Whatever, { CPU: 1, HDD: 2048, SDD: 512, extra: 42 })");
|
"HsServerEntity(D-1000212:some PrivateCloud, [2024-04-01,), some Whatever, { CPU: 1, HDD: 2048, SDD: 512, extra: 42 })");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void normalUser_canViewOnlyRelatedManagedServers() {
|
public void normalUser_canViewOnlyRelatedServers() {
|
||||||
// given:
|
// given:
|
||||||
context("person-FirbySusan@example.com");
|
context("person-FirbySusan@example.com");
|
||||||
final var debitorUuid = debitorRepo.findDebitorByDebitorNumber(1000111).stream().findAny().orElseThrow().getUuid();
|
final var debitorUuid = debitorRepo.findDebitorByDebitorNumber(1000111).stream().findAny().orElseThrow().getUuid();
|
||||||
|
|
||||||
// when:
|
// when:
|
||||||
final var result = managedServerRepo.findAllByDebitorUuid(debitorUuid);
|
final var result = serverRepo.findAllByDebitorUuid(debitorUuid);
|
||||||
|
|
||||||
// then:
|
// then:
|
||||||
exactlyTheseManagedServersAreReturned(
|
exactlyTheseServersAreReturned(
|
||||||
result,
|
result,
|
||||||
"HsManagedServerEntity(D-1000111:some PrivateCloud, [2022-10-01,), some ManagedServer, { CPU: 2, SDD: 512, extra: 42 })",
|
"HsServerEntity(D-1000111:some PrivateCloud, [2022-10-01,), some ManagedServer, { CPU: 2, SDD: 512, extra: 42 })",
|
||||||
"HsManagedServerEntity(D-1000111:some PrivateCloud, [2023-01-15,2024-04-15), another CloudServer, { CPU: 2, HDD: 1024, extra: 42 })",
|
"HsServerEntity(D-1000111:some PrivateCloud, [2023-01-15,2024-04-15), another CloudServer, { CPU: 2, HDD: 1024, extra: 42 })",
|
||||||
"HsManagedServerEntity(D-1000111:some PrivateCloud, [2024-04-01,), some Whatever, { CPU: 1, HDD: 2048, SDD: 512, extra: 42 })");
|
"HsServerEntity(D-1000111:some PrivateCloud, [2024-04-01,), some Whatever, { CPU: 1, HDD: 2048, SDD: 512, extra: 42 })");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class UpdateManagedServer {
|
class UpdateServer {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hostsharingAdmin_canUpdateArbitraryManagedServer() {
|
public void hostsharingAdmin_canUpdateArbitraryServer() {
|
||||||
// given
|
// given
|
||||||
final var givenManagedServerUuid = givenSomeTemporaryManagedServer(1000111).getUuid();
|
final var givenServerUuid = givenSomeTemporaryServer(1000111).getUuid();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var foundManagedServer = em.find(HsManagedServerEntity.class, givenManagedServerUuid);
|
final var foundServer = em.find(HsHostingServerEntity.class, givenServerUuid);
|
||||||
foundManagedServer.getConfig().put("CPUs", 2);
|
foundServer.getConfig().put("CPUs", 2);
|
||||||
foundManagedServer.getConfig().remove("SSD-storage");
|
foundServer.getConfig().remove("SSD-storage");
|
||||||
foundManagedServer.getConfig().put("HSD-storage", 2048);
|
foundServer.getConfig().put("HSD-storage", 2048);
|
||||||
foundManagedServer.setValidity(Range.closedOpen(
|
foundServer.setValidity(Range.closedOpen(
|
||||||
LocalDate.parse("2019-05-17"), LocalDate.parse("2023-01-01")));
|
LocalDate.parse("2019-05-17"), LocalDate.parse("2023-01-01")));
|
||||||
return toCleanup(managedServerRepo.save(foundManagedServer));
|
return toCleanup(serverRepo.save(foundServer));
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertSuccessful();
|
result.assertSuccessful();
|
||||||
jpaAttempt.transacted(() -> {
|
jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
assertThatManagedServerActuallyInDatabase(result.returnedValue());
|
assertThatServerActuallyInDatabase(result.returnedValue());
|
||||||
}).assertSuccessful();
|
}).assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatManagedServerActuallyInDatabase(final HsManagedServerEntity saved) {
|
private void assertThatServerActuallyInDatabase(final HsHostingServerEntity saved) {
|
||||||
final var found = managedServerRepo.findByUuid(saved.getUuid());
|
final var found = serverRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().isNotSameAs(saved)
|
assertThat(found).isNotEmpty().get().isNotSameAs(saved)
|
||||||
.extracting(Object::toString).isEqualTo(saved.toString());
|
.extracting(Object::toString).isEqualTo(saved.toString());
|
||||||
}
|
}
|
||||||
@ -224,61 +224,61 @@ class HsManagedServerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
class DeleteByUuid {
|
class DeleteByUuid {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void globalAdmin_withoutAssumedRole_canDeleteAnyManagedServer() {
|
public void globalAdmin_withoutAssumedRole_canDeleteAnyServer() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net", null);
|
context("superuser-alex@hostsharing.net", null);
|
||||||
final var givenManagedServer = givenSomeTemporaryManagedServer(1000111);
|
final var givenServer = givenSomeTemporaryServer(1000111);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
managedServerRepo.deleteByUuid(givenManagedServer.getUuid());
|
serverRepo.deleteByUuid(givenServer.getUuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertSuccessful();
|
result.assertSuccessful();
|
||||||
assertThat(jpaAttempt.transacted(() -> {
|
assertThat(jpaAttempt.transacted(() -> {
|
||||||
context("superuser-fran@hostsharing.net", null);
|
context("superuser-fran@hostsharing.net", null);
|
||||||
return managedServerRepo.findByUuid(givenManagedServer.getUuid());
|
return serverRepo.findByUuid(givenServer.getUuid());
|
||||||
}).assertSuccessful().returnedValue()).isEmpty();
|
}).assertSuccessful().returnedValue()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nonGlobalAdmin_canNotDeleteTheirRelatedManagedServer() {
|
public void nonGlobalAdmin_canNotDeleteTheirRelatedServer() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net", null);
|
context("superuser-alex@hostsharing.net", null);
|
||||||
final var givenManagedServer = givenSomeTemporaryManagedServer(1000111);
|
final var givenServer = givenSomeTemporaryServer(1000111);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("person-FirbySusan@example.com");
|
context("person-FirbySusan@example.com");
|
||||||
assertThat(managedServerRepo.findByUuid(givenManagedServer.getUuid())).isPresent();
|
assertThat(serverRepo.findByUuid(givenServer.getUuid())).isPresent();
|
||||||
|
|
||||||
managedServerRepo.deleteByUuid(givenManagedServer.getUuid());
|
serverRepo.deleteByUuid(givenServer.getUuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertExceptionWithRootCauseMessage(
|
result.assertExceptionWithRootCauseMessage(
|
||||||
JpaSystemException.class,
|
JpaSystemException.class,
|
||||||
"[403] Subject ", " is not allowed to delete hs_hosting_managedserver");
|
"[403] Subject ", " is not allowed to delete hs_hosting_server");
|
||||||
assertThat(jpaAttempt.transacted(() -> {
|
assertThat(jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
return managedServerRepo.findByUuid(givenManagedServer.getUuid());
|
return serverRepo.findByUuid(givenServer.getUuid());
|
||||||
}).assertSuccessful().returnedValue()).isPresent(); // still there
|
}).assertSuccessful().returnedValue()).isPresent(); // still there
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deletingAManagedServerAlsoDeletesRelatedRolesAndGrants() {
|
public void deletingAServerAlsoDeletesRelatedRolesAndGrants() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var initialRoleNames = Array.from(distinctRoleNamesOf(rawRoleRepo.findAll()));
|
final var initialRoleNames = Array.from(distinctRoleNamesOf(rawRoleRepo.findAll()));
|
||||||
final var initialGrantNames = Array.from(distinctGrantDisplaysOf(rawGrantRepo.findAll()));
|
final var initialGrantNames = Array.from(distinctGrantDisplaysOf(rawGrantRepo.findAll()));
|
||||||
final var givenManagedServer = givenSomeTemporaryManagedServer(1000111);
|
final var givenServer = givenSomeTemporaryServer(1000111);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
return managedServerRepo.deleteByUuid(givenManagedServer.getUuid());
|
return serverRepo.deleteByUuid(givenServer.getUuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
@ -295,7 +295,7 @@ class HsManagedServerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var query = em.createNativeQuery("""
|
final var query = em.createNativeQuery("""
|
||||||
select currentTask, targetTable, targetOp
|
select currentTask, targetTable, targetOp
|
||||||
from tx_journal_v
|
from tx_journal_v
|
||||||
where targettable = 'hs_hosting_managedserver';
|
where targettable = 'hs_hosting_server';
|
||||||
""");
|
""");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -303,18 +303,18 @@ class HsManagedServerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||||
"[creating hosting-managedserver test-data 1000111, hs_hosting_managedserver, INSERT]",
|
"[creating hosting-server test-data 1000111, hs_hosting_server, INSERT]",
|
||||||
"[creating hosting-managedserver test-data 1000212, hs_hosting_managedserver, INSERT]",
|
"[creating hosting-server test-data 1000212, hs_hosting_server, INSERT]",
|
||||||
"[creating hosting-managedserver test-data 1000313, hs_hosting_managedserver, INSERT]");
|
"[creating hosting-server test-data 1000313, hs_hosting_server, INSERT]");
|
||||||
}
|
}
|
||||||
|
|
||||||
private HsManagedServerEntity givenSomeTemporaryManagedServer(final int debitorNumber) {
|
private HsHostingServerEntity givenSomeTemporaryServer(final int debitorNumber) {
|
||||||
return jpaAttempt.transacted(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var givenBookingItem = givenBookingItem("First", "some CloudServer");
|
final var givenBookingItem = givenBookingItem("First", "some CloudServer");
|
||||||
final var newManagedServer = HsManagedServerEntity.builder()
|
final var newServer = HsHostingServerEntity.builder()
|
||||||
.bookingItem(givenBookingItem)
|
.bookingItem(givenBookingItem)
|
||||||
.caption("some temp booking managedserver")
|
.caption("some temp booking server")
|
||||||
.validity(Range.closedOpen(
|
.validity(Range.closedOpen(
|
||||||
LocalDate.parse("2020-01-01"), LocalDate.parse("2023-01-01")))
|
LocalDate.parse("2020-01-01"), LocalDate.parse("2023-01-01")))
|
||||||
.config(Map.ofEntries(
|
.config(Map.ofEntries(
|
||||||
@ -322,7 +322,7 @@ class HsManagedServerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
entry("SSD-storage", 256)))
|
entry("SSD-storage", 256)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return toCleanup(managedServerRepo.save(newManagedServer));
|
return toCleanup(serverRepo.save(newServer));
|
||||||
}).assertSuccessful().returnedValue();
|
}).assertSuccessful().returnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,17 +333,17 @@ class HsManagedServerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
.findAny().orElseThrow();
|
.findAny().orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void exactlyTheseManagedServersAreReturned(
|
void exactlyTheseServersAreReturned(
|
||||||
final List<HsManagedServerEntity> actualResult,
|
final List<HsHostingServerEntity> actualResult,
|
||||||
final String... managedServerNames) {
|
final String... serverNames) {
|
||||||
assertThat(actualResult)
|
assertThat(actualResult)
|
||||||
.extracting(managedServerEntity -> managedServerEntity.toString())
|
.extracting(serverEntity -> serverEntity.toString())
|
||||||
.containsExactlyInAnyOrder(managedServerNames);
|
.containsExactlyInAnyOrder(serverNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
void allTheseManagedServersAreReturned(final List<HsManagedServerEntity> actualResult, final String... managedServerNames) {
|
void allTheseServersAreReturned(final List<HsHostingServerEntity> actualResult, final String... serverNames) {
|
||||||
assertThat(actualResult)
|
assertThat(actualResult)
|
||||||
.extracting(managedServerEntity -> managedServerEntity.toString())
|
.extracting(serverEntity -> serverEntity.toString())
|
||||||
.contains(managedServerNames);
|
.contains(serverNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.hostsharing.hsadminng.hs.hosting.managedserver;
|
package net.hostsharing.hsadminng.hs.hosting.server;
|
||||||
|
|
||||||
import io.hypersistence.utils.hibernate.type.range.Range;
|
import io.hypersistence.utils.hibernate.type.range.Range;
|
||||||
import io.restassured.RestAssured;
|
import io.restassured.RestAssured;
|
||||||
@ -30,13 +30,13 @@ import static org.hamcrest.Matchers.matchesRegex;
|
|||||||
classes = { HsadminNgApplication.class, JpaAttempt.class }
|
classes = { HsadminNgApplication.class, JpaAttempt.class }
|
||||||
)
|
)
|
||||||
@Transactional
|
@Transactional
|
||||||
class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanup {
|
class HsServerControllerAcceptanceTest extends ContextBasedTestWithCleanup {
|
||||||
|
|
||||||
@LocalServerPort
|
@LocalServerPort
|
||||||
private Integer port;
|
private Integer port;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsManagedServerRepository managedServerRepo;
|
HsHostingServerRepository serverRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsBookingItemRepository bookingItemRepo;
|
HsBookingItemRepository bookingItemRepo;
|
||||||
@ -48,10 +48,10 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
JpaAttempt jpaAttempt;
|
JpaAttempt jpaAttempt;
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class ListManagedServers {
|
class ListServers {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canViewAllManagedServersOfArbitraryDebitor() {
|
void globalAdmin_canViewAllServersOfArbitraryDebitor() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
@ -62,7 +62,7 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/hosting/managedservers?debitorUuid=" + givenDebitor.getUuid())
|
.get("http://localhost/api/hs/hosting/servers?debitorUuid=" + givenDebitor.getUuid())
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
@ -106,10 +106,10 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class AddManagedServer {
|
class AddServer {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canAddManagedServer() {
|
void globalAdmin_canAddServer() {
|
||||||
|
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenBookingItem = givenBookingItem("First", "some PrivateCloud");
|
final var givenBookingItem = givenBookingItem("First", "some PrivateCloud");
|
||||||
@ -128,7 +128,7 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
""".formatted(givenBookingItem.getUuid()))
|
""".formatted(givenBookingItem.getUuid()))
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.post("http://localhost/api/hs/hosting/managedservers")
|
.post("http://localhost/api/hs/hosting/servers")
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(201)
|
.statusCode(201)
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
@ -139,10 +139,10 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
"validFrom": "2024-04-17"
|
"validFrom": "2024-04-17"
|
||||||
}
|
}
|
||||||
"""))
|
"""))
|
||||||
.header("Location", matchesRegex("http://localhost:[1-9][0-9]*/api/hs/hosting/managedservers/[^/]*"))
|
.header("Location", matchesRegex("http://localhost:[1-9][0-9]*/api/hs/hosting/servers/[^/]*"))
|
||||||
.extract().header("Location"); // @formatter:on
|
.extract().header("Location"); // @formatter:on
|
||||||
|
|
||||||
// finally, the new managedServer can be accessed under the generated UUID
|
// finally, the new server can be accessed under the generated UUID
|
||||||
final var newUserUuid = UUID.fromString(
|
final var newUserUuid = UUID.fromString(
|
||||||
location.substring(location.lastIndexOf('/') + 1));
|
location.substring(location.lastIndexOf('/') + 1));
|
||||||
assertThat(newUserUuid).isNotNull();
|
assertThat(newUserUuid).isNotNull();
|
||||||
@ -150,12 +150,12 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class GetManagedServer {
|
class GetServer {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canGetArbitraryManagedServer() {
|
void globalAdmin_canGetArbitraryServer() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenManagedServerUuid = managedServerRepo.findAll().stream()
|
final var givenServerUuid = serverRepo.findAll().stream()
|
||||||
.filter(bi -> bi.getBookingItem().getDebitor().getDebitorNumber() == 1000111)
|
.filter(bi -> bi.getBookingItem().getDebitor().getDebitorNumber() == 1000111)
|
||||||
.filter(item -> item.getCaption().equals("some ManagedServer"))
|
.filter(item -> item.getCaption().equals("some ManagedServer"))
|
||||||
.findAny().orElseThrow().getUuid();
|
.findAny().orElseThrow().getUuid();
|
||||||
@ -165,7 +165,7 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/hosting/managedservers/" + givenManagedServerUuid)
|
.get("http://localhost/api/hs/hosting/servers/" + givenServerUuid)
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
@ -184,11 +184,11 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void normalUser_canNotGetUnrelatedManagedServer() {
|
void normalUser_canNotGetUnrelatedServer() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenManagedServerUuid = managedServerRepo.findAll().stream()
|
final var givenServerUuid = serverRepo.findAll().stream()
|
||||||
.filter(bi -> bi.getBookingItem().getDebitor().getDebitorNumber() == 1000212)
|
.filter(bi -> bi.getBookingItem().getDebitor().getDebitorNumber() == 1000212)
|
||||||
.map(HsManagedServerEntity::getUuid)
|
.map(HsHostingServerEntity::getUuid)
|
||||||
.findAny().orElseThrow();
|
.findAny().orElseThrow();
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
@ -196,15 +196,15 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.header("current-user", "selfregistered-user-drew@hostsharing.org")
|
.header("current-user", "selfregistered-user-drew@hostsharing.org")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/hosting/managedservers/" + givenManagedServerUuid)
|
.get("http://localhost/api/hs/hosting/servers/" + givenServerUuid)
|
||||||
.then().log().body().assertThat()
|
.then().log().body().assertThat()
|
||||||
.statusCode(404); // @formatter:on
|
.statusCode(404); // @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void debitorAgentUser_canGetRelatedManagedServer() {
|
void debitorAgentUser_canGetRelatedServer() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenManagedServerUuid = managedServerRepo.findAll().stream()
|
final var givenServerUuid = serverRepo.findAll().stream()
|
||||||
.filter(bi -> bi.getBookingItem().getDebitor().getDebitorNumber() == 1000313)
|
.filter(bi -> bi.getBookingItem().getDebitor().getDebitorNumber() == 1000313)
|
||||||
.filter(bi -> bi.getCaption().equals("some ManagedServer"))
|
.filter(bi -> bi.getCaption().equals("some ManagedServer"))
|
||||||
.findAny().orElseThrow().getUuid();
|
.findAny().orElseThrow().getUuid();
|
||||||
@ -214,7 +214,7 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.header("current-user", "person-TuckerJack@example.com")
|
.header("current-user", "person-TuckerJack@example.com")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/hosting/managedservers/" + givenManagedServerUuid)
|
.get("http://localhost/api/hs/hosting/servers/" + givenServerUuid)
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
@ -234,12 +234,12 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class PatchManagedServer {
|
class PatchServer {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canPatchAllUpdatablePropertiesOfManagedServer() {
|
void globalAdmin_canPatchAllUpdatablePropertiesOfServer() {
|
||||||
|
|
||||||
final var givenManagedServer = givenSomeTemporaryManagedServerForDebitorNumber(1000111, entry("something", 1));
|
final var givenServer = givenSomeTemporaryServerForDebitorNumber(1000111, entry("something", 1));
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
@ -258,7 +258,7 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
""")
|
""")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.patch("http://localhost/api/hs/hosting/managedservers/" + givenManagedServer.getUuid())
|
.patch("http://localhost/api/hs/hosting/servers/" + givenServer.getUuid())
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
@ -275,9 +275,9 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
}
|
}
|
||||||
""")); // @formatter:on
|
""")); // @formatter:on
|
||||||
|
|
||||||
// finally, the managedServer is actually updated
|
// finally, the server is actually updated
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
assertThat(managedServerRepo.findByUuid(givenManagedServer.getUuid())).isPresent().get()
|
assertThat(serverRepo.findByUuid(givenServer.getUuid())).isPresent().get()
|
||||||
.matches(mandate -> {
|
.matches(mandate -> {
|
||||||
assertThat(mandate.getBookingItem().toShortString()).isEqualTo("D-1000111:some CloudServer");
|
assertThat(mandate.getBookingItem().toShortString()).isEqualTo("D-1000111:some CloudServer");
|
||||||
assertThat(mandate.getValidFrom()).isEqualTo("2022-11-01");
|
assertThat(mandate.getValidFrom()).isEqualTo("2022-11-01");
|
||||||
@ -288,42 +288,42 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class DeleteManagedServer {
|
class DeleteServer {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canDeleteArbitraryManagedServer() {
|
void globalAdmin_canDeleteArbitraryServer() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenManagedServer = givenSomeTemporaryManagedServerForDebitorNumber(1000111, entry("something", 1));
|
final var givenServer = givenSomeTemporaryServerForDebitorNumber(1000111, entry("something", 1));
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.delete("http://localhost/api/hs/hosting/managedservers/" + givenManagedServer.getUuid())
|
.delete("http://localhost/api/hs/hosting/servers/" + givenServer.getUuid())
|
||||||
.then().log().body().assertThat()
|
.then().log().body().assertThat()
|
||||||
.statusCode(204); // @formatter:on
|
.statusCode(204); // @formatter:on
|
||||||
|
|
||||||
// then the given managedServer is gone
|
// then the given server is gone
|
||||||
assertThat(managedServerRepo.findByUuid(givenManagedServer.getUuid())).isEmpty();
|
assertThat(serverRepo.findByUuid(givenServer.getUuid())).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void normalUser_canNotDeleteUnrelatedManagedServer() {
|
void normalUser_canNotDeleteUnrelatedServer() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenManagedServer = givenSomeTemporaryManagedServerForDebitorNumber(1000111, entry("something", 1));
|
final var givenServer = givenSomeTemporaryServerForDebitorNumber(1000111, entry("something", 1));
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "selfregistered-user-drew@hostsharing.org")
|
.header("current-user", "selfregistered-user-drew@hostsharing.org")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.delete("http://localhost/api/hs/hosting/managedservers/" + givenManagedServer.getUuid())
|
.delete("http://localhost/api/hs/hosting/servers/" + givenServer.getUuid())
|
||||||
.then().log().body().assertThat()
|
.then().log().body().assertThat()
|
||||||
.statusCode(404); // @formatter:on
|
.statusCode(404); // @formatter:on
|
||||||
|
|
||||||
// then the given managedServer is still there
|
// then the given server is still there
|
||||||
assertThat(managedServerRepo.findByUuid(givenManagedServer.getUuid())).isNotEmpty();
|
assertThat(serverRepo.findByUuid(givenServer.getUuid())).isNotEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,11 +334,11 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.findAny().orElseThrow();
|
.findAny().orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HsManagedServerEntity givenSomeTemporaryManagedServerForDebitorNumber(final int debitorNumber,
|
private HsHostingServerEntity givenSomeTemporaryServerForDebitorNumber(final int debitorNumber,
|
||||||
final Map.Entry<String, Integer> resources) {
|
final Map.Entry<String, Integer> resources) {
|
||||||
return jpaAttempt.transacted(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var newManagedServer = HsManagedServerEntity.builder()
|
final var newServer = HsHostingServerEntity.builder()
|
||||||
.uuid(UUID.randomUUID())
|
.uuid(UUID.randomUUID())
|
||||||
.bookingItem(givenBookingItem("First", "some CloudServer"))
|
.bookingItem(givenBookingItem("First", "some CloudServer"))
|
||||||
.caption("some test-booking")
|
.caption("some test-booking")
|
||||||
@ -347,7 +347,7 @@ class HsManagedServerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
LocalDate.parse("2022-11-01"), LocalDate.parse("2023-03-31")))
|
LocalDate.parse("2022-11-01"), LocalDate.parse("2023-03-31")))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return managedServerRepo.save(newManagedServer);
|
return serverRepo.save(newServer);
|
||||||
}).assertSuccessful().returnedValue();
|
}).assertSuccessful().returnedValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -620,6 +620,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
private void deleteTestDataFromHsOfficeTables() {
|
private void deleteTestDataFromHsOfficeTables() {
|
||||||
jpaAttempt.transacted(() -> {
|
jpaAttempt.transacted(() -> {
|
||||||
context(rbacSuperuser);
|
context(rbacSuperuser);
|
||||||
|
em.createNativeQuery("delete from hs_hosting_server where true").executeUpdate();
|
||||||
em.createNativeQuery("delete from hs_booking_item where true").executeUpdate();
|
em.createNativeQuery("delete from hs_booking_item where true").executeUpdate();
|
||||||
em.createNativeQuery("delete from hs_office_coopassetstransaction where true").executeUpdate();
|
em.createNativeQuery("delete from hs_office_coopassetstransaction where true").executeUpdate();
|
||||||
em.createNativeQuery("delete from hs_office_coopassetstransaction_legacy_id where true").executeUpdate();
|
em.createNativeQuery("delete from hs_office_coopassetstransaction_legacy_id where true").executeUpdate();
|
||||||
|
Loading…
Reference in New Issue
Block a user