diff --git a/.env.unix.example b/.env.unix.example index 9f087cb8e2d40cb0db81f208e98eedfce68ab9c9..54986336db71fa576456e6638245f6a36574a34b 100644 --- a/.env.unix.example +++ b/.env.unix.example @@ -12,7 +12,7 @@ METADATA_PASSWORD=dbrepo AUTH_DB=keycloak AUTH_USERNAME=root AUTH_PASSWORD=dbrepo -BROKER_ENDPOINT=http://broker-service:15672/api/broker +BROKER_ENDPOINT=http://broker-service:15672/admin/broker BROKER_USERNAME=fda BROKER_PASSWORD=fda KEYCLOAK_ADMIN=fda diff --git a/dbrepo-broker-service/rabbitmq.conf b/dbrepo-broker-service/rabbitmq.conf index a2b3bf521b37b6a880d4e86dfc5932f6ee4614d8..e1883b4b825a9f9a6aa79a050fc01d8f8a1efdf0 100644 --- a/dbrepo-broker-service/rabbitmq.conf +++ b/dbrepo-broker-service/rabbitmq.conf @@ -10,8 +10,8 @@ default_permissions.write = .* # enable http outside localhost listeners.tcp.1 = 0.0.0.0:5672 -# management ui (https://www.rabbitmq.com/management.html#path-prefix) -management.path_prefix = /api/broker +# management prefix (https://www.rabbitmq.com/management.html#path-prefix) +management.path_prefix = /admin/broker # logging log.console = true diff --git a/dbrepo-gateway-service/dbrepo.conf b/dbrepo-gateway-service/dbrepo.conf index b5f706fced78f9438ef7d9de98f2c321f92bfed2..68abcdeb0fbaaf2ebeadca382e60c2aad6b96056 100644 --- a/dbrepo-gateway-service/dbrepo.conf +++ b/dbrepo-gateway-service/dbrepo.conf @@ -34,8 +34,7 @@ server { listen 80 default_server; server_name _; - location /api/broker { - rewrite /api/broker/(.*) /api/$1 break; + location /admin/broker { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -44,22 +43,22 @@ server { proxy_read_timeout 90; } - location /api/analyse { + location /api/broker { + rewrite /api/broker/(.*) /admin/broker/api/$1 break; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass http://analyse; + proxy_pass http://broker; proxy_read_timeout 90; } - location /pid { - rewrite /pid/(.*) /api/pid/$1 break; + location /api/analyse { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass http://metadata; + proxy_pass http://analyse; proxy_read_timeout 90; } @@ -91,17 +90,17 @@ server { proxy_read_timeout 90; } - location /retrieve { - rewrite /retrieve/(.*) /$1 break; + location /api { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass http://search; + proxy_pass http://metadata; proxy_read_timeout 90; } - location /api { + location /pid { + rewrite /pid/(.*) /api/pid/$1 break; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -110,6 +109,16 @@ server { proxy_read_timeout 90; } + location /retrieve { + rewrite /retrieve/(.*) /$1 break; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://search; + proxy_read_timeout 90; + } + location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/dbrepo-metadata-service/Dockerfile b/dbrepo-metadata-service/Dockerfile index 6e9c922e45aaa46bf1988cc766cd0e2b8eb9e119..f88b37c5ec15bad047103c445298aa48569c4078 100644 --- a/dbrepo-metadata-service/Dockerfile +++ b/dbrepo-metadata-service/Dockerfile @@ -36,7 +36,7 @@ ENV ADMIN_MAIL="noreply@localhost" ENV BASE_URL="http://localhost" ENV GRANT_PRIVILEGES="SELECT, CREATE, CREATE VIEW, CREATE ROUTINE, CREATE TEMPORARY TABLES, LOCK TABLES, INDEX, TRIGGER, INSERT, UPDATE, DELETE" ENV BROKER_CONSUMERS=2 -ENV BROKER_ENDPOINT="http://broker-service:15672/api/broker" +ENV BROKER_ENDPOINT="http://broker-service:15672/admin/broker" ENV BROKER_USERNAME=fda ENV BROKER_PASSWORD=fda ENV DELETED_RECORD=persistent diff --git a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/exception/BrokerRemoteException.java b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/exception/BrokerRemoteException.java new file mode 100644 index 0000000000000000000000000000000000000000..922462d2ee95b4cfea228b64cab7f80e40fa7661 --- /dev/null +++ b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/exception/BrokerRemoteException.java @@ -0,0 +1,21 @@ +package at.tuwien.exception; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@ResponseStatus(code = HttpStatus.SERVICE_UNAVAILABLE) +public class BrokerRemoteException extends Exception { + + public BrokerRemoteException(String msg) { + super(msg); + } + + public BrokerRemoteException(String msg, Throwable thr) { + super(msg, thr); + } + + public BrokerRemoteException(Throwable thr) { + super(thr); + } + +} diff --git a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/exception/KeycloakRemoteException.java b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/exception/KeycloakRemoteException.java index 594d70340303f18a3504324d75a445d1457158de..6616739278b0b02b8160d09e94c87f304f809628 100644 --- a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/exception/KeycloakRemoteException.java +++ b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/exception/KeycloakRemoteException.java @@ -3,7 +3,7 @@ package at.tuwien.exception; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; -@ResponseStatus(code = HttpStatus.LOCKED) +@ResponseStatus(code = HttpStatus.SERVICE_UNAVAILABLE) public class KeycloakRemoteException extends Exception { public KeycloakRemoteException(String msg) { diff --git a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/mapper/DatabaseMapper.java b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/mapper/DatabaseMapper.java index a889b2ee10a01328a477e4acf247f7fcc079bd84..5890c1b0193d7808e82cfa25943e908c771b9d6d 100644 --- a/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/mapper/DatabaseMapper.java +++ b/dbrepo-metadata-service/repositories/src/main/java/at/tuwien/mapper/DatabaseMapper.java @@ -163,9 +163,9 @@ public interface DatabaseMapper { } default PreparedStatement rawGrantCreatorAccessQuery(Connection connection, String databaseName, String username, - String priviliges) throws QueryMalformedException { + String privileges) throws QueryMalformedException { final StringBuilder statement = new StringBuilder("GRANT ") - .append(priviliges) + .append(privileges) .append(" ON ") .append(databaseName) .append(".* TO `") diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/DatabaseEndpoint.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/DatabaseEndpoint.java index 4c77a4ac257500f57fb03c03819e6a1c0c14d858..2bad13e644869b64b0a24eee67b2abaee7732c0f 100644 --- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/DatabaseEndpoint.java +++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/DatabaseEndpoint.java @@ -84,7 +84,7 @@ public class DatabaseEndpoint { } @PostMapping - @Transactional + @Transactional(rollbackFor = Exception.class) @PreAuthorize("hasAuthority('create-database')") @Timed(value = "database.create", description = "Time needed to create a database") @Operation(summary = "Create database", security = @SecurityRequirement(name = "bearerAuth")) @@ -141,7 +141,7 @@ public class DatabaseEndpoint { AmqpException, ContainerConnectionException, UserNotFoundException, DatabaseNotFoundException, DatabaseNameExistsException, DatabaseConnectionException, QueryMalformedException, NotAllowedException, BrokerVirtualHostCreationException, QueryStoreException, - BrokerVirtualHostGrantException, KeycloakRemoteException, AccessDeniedException { + BrokerVirtualHostGrantException, KeycloakRemoteException, AccessDeniedException, BrokerRemoteException { log.debug("endpoint create database, createDto={}, principal={}", createDto, principal); final User user = userService.findByUsername(principal.getName()); @@ -272,7 +272,7 @@ public class DatabaseEndpoint { } @DeleteMapping("/{id}") - @Transactional + @Transactional(rollbackFor = Exception.class) @PreAuthorize("hasAuthority('delete-database')") @Timed(value = "database.delete", description = "Time needed to delete a database") @Operation(summary = "Delete some database", security = @SecurityRequirement(name = "bearerAuth")) @@ -321,7 +321,7 @@ public class DatabaseEndpoint { public ResponseEntity<?> delete(@NotNull @PathVariable Long id, Principal principal) throws DatabaseNotFoundException, ImageNotSupportedException, DatabaseMalformedException, AmqpException, QueryMalformedException, UserNotFoundException, BrokerVirtualHostGrantException, - DatabaseConnectionException, KeycloakRemoteException, AccessDeniedException { + DatabaseConnectionException, KeycloakRemoteException, AccessDeniedException, BrokerRemoteException { log.debug("endpoint delete database, id={}, principal={}", id, principal); final Database database = databaseService.findById(id); diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java index c4d587c99ca7cb153d5ebf3617aae58d62806348..ced4aa34104430d9e31cb96d6adaab026ce4bf92 100644 --- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java +++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/endpoints/UserEndpoint.java @@ -75,7 +75,7 @@ public class UserEndpoint { } @PostMapping - @Transactional + @Transactional(rollbackFor = Exception.class) @PreAuthorize("!isAuthenticated()") @Timed(value = "user.create", description = "Time needed to create a user in the metadata database") @Operation(summary = "Create user") @@ -85,8 +85,11 @@ public class UserEndpoint { content = {@Content( mediaType = "application/json", schema = @Schema(implementation = UserBriefDto.class))}), + @ApiResponse(responseCode = "400", + description = "Parameters are not well-formed (likely email)", + content = {@Content(mediaType = "application/json")}), @ApiResponse(responseCode = "404", - description = "Realm or default role not found", + description = "default role not found", content = {@Content( mediaType = "application/json", schema = @Schema(implementation = ApiErrorDto.class))}), @@ -102,8 +105,8 @@ public class UserEndpoint { schema = @Schema(implementation = ApiErrorDto.class))}), }) public ResponseEntity<UserBriefDto> create(@NotNull @Valid @RequestBody SignupRequestDto data) - throws RealmNotFoundException, UserAlreadyExistsException, UserEmailAlreadyExistsException, - UserNotFoundException, KeycloakRemoteException, AccessDeniedException, BrokerVirtualHostCreationException { + throws UserAlreadyExistsException, UserEmailAlreadyExistsException, UserNotFoundException, + KeycloakRemoteException, AccessDeniedException, BrokerRemoteException { log.debug("endpoint create a user, data={}", data); /* check */ userService.validateUsernameNotExists(data.getUsername()); diff --git a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/handlers/ApiExceptionHandler.java b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/handlers/ApiExceptionHandler.java index b792981dfc61eea5763f456f51d0fd3749454b43..27663c461e14d4eca46a24f1a9476d8f9d4bffc1 100644 --- a/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/handlers/ApiExceptionHandler.java +++ b/dbrepo-metadata-service/rest-service/src/main/java/at/tuwien/handlers/ApiExceptionHandler.java @@ -40,17 +40,29 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { } @Hidden - @ResponseStatus(HttpStatus.LOCKED) + @ResponseStatus(HttpStatus.SERVICE_UNAVAILABLE) @ExceptionHandler(KeycloakRemoteException.class) public ResponseEntity<ApiErrorDto> handle(KeycloakRemoteException e, WebRequest request) { final ApiErrorDto response = ApiErrorDto.builder() - .status(HttpStatus.LOCKED) + .status(HttpStatus.SERVICE_UNAVAILABLE) .message(e.getLocalizedMessage()) .code("error.metadata.keycloak") .build(); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); } + @Hidden + @ResponseStatus(HttpStatus.SERVICE_UNAVAILABLE) + @ExceptionHandler(BrokerRemoteException.class) + public ResponseEntity<ApiErrorDto> handle(BrokerRemoteException e, WebRequest request) { + final ApiErrorDto response = ApiErrorDto.builder() + .status(HttpStatus.SERVICE_UNAVAILABLE) + .message(e.getLocalizedMessage()) + .code("error.metadata.broker") + .build(); + return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); + } + @Hidden @ResponseStatus(HttpStatus.CONFLICT) @ExceptionHandler(ContainerAlreadyExistsException.class) diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/DatabaseEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/DatabaseEndpointUnitTest.java index d9ae17223957d0014fb074fac4c20784bb53d4dc..66aa04b7fbb20344d4cc1d25cd0108814ff062e6 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/DatabaseEndpointUnitTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/DatabaseEndpointUnitTest.java @@ -117,7 +117,7 @@ public class DatabaseEndpointUnitTest extends BaseUnitTest { DatabaseNameExistsException, NotAllowedException, ContainerConnectionException, DatabaseMalformedException, QueryStoreException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, AmqpException, BrokerVirtualHostCreationException, ContainerNotFoundException, - KeycloakRemoteException, AccessDeniedException { + KeycloakRemoteException, AccessDeniedException, BrokerRemoteException { final DatabaseCreateDto request = DatabaseCreateDto.builder() .cid(CONTAINER_1_ID) .name(DATABASE_1_NAME) @@ -399,7 +399,7 @@ public class DatabaseEndpointUnitTest extends BaseUnitTest { @WithMockUser(username = USER_2_USERNAME, authorities = {"delete-database"}) public void delete_hasRole_succeeds() throws UserNotFoundException, BrokerVirtualHostGrantException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, - AmqpException, DatabaseMalformedException, KeycloakRemoteException, AccessDeniedException { + AmqpException, DatabaseMalformedException, KeycloakRemoteException, AccessDeniedException, BrokerRemoteException { /* test */ delete_generic(DATABASE_2_ID, DATABASE_2, USER_2_PRINCIPAL); @@ -430,7 +430,7 @@ public class DatabaseEndpointUnitTest extends BaseUnitTest { NotAllowedException, ContainerConnectionException, DatabaseMalformedException, QueryStoreException, DatabaseConnectionException, QueryMalformedException, DatabaseNotFoundException, ImageNotSupportedException, AmqpException, BrokerVirtualHostCreationException, ContainerNotFoundException, - BrokerVirtualHostGrantException, KeycloakRemoteException, AccessDeniedException { + BrokerVirtualHostGrantException, KeycloakRemoteException, AccessDeniedException, BrokerRemoteException { /* mock */ doNothing() @@ -499,7 +499,7 @@ public class DatabaseEndpointUnitTest extends BaseUnitTest { public void delete_generic(Long databaseId, Database database, Principal principal) throws DatabaseNotFoundException, UserNotFoundException, DatabaseConnectionException, QueryMalformedException, ImageNotSupportedException, AmqpException, DatabaseMalformedException, - BrokerVirtualHostGrantException, KeycloakRemoteException, AccessDeniedException { + BrokerVirtualHostGrantException, KeycloakRemoteException, AccessDeniedException, BrokerRemoteException { /* mock */ if (database != null) { diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/UserEndpointUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/UserEndpointUnitTest.java index 21b81f10e9ee1e4d095b7eba00b6ebae3d4b0470..e783f9b1ca9b2411eb46c45f896731c66d504334 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/UserEndpointUnitTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/UserEndpointUnitTest.java @@ -67,7 +67,7 @@ public class UserEndpointUnitTest extends BaseUnitTest { @WithAnonymousUser public void create_anonymous_succeeds() throws UserNotFoundException, UserEmailAlreadyExistsException, RealmNotFoundException, UserAlreadyExistsException, KeycloakRemoteException, - at.tuwien.exception.AccessDeniedException, BrokerVirtualHostCreationException { + at.tuwien.exception.AccessDeniedException, BrokerRemoteException { final SignupRequestDto request = SignupRequestDto.builder() .email(USER_1_EMAIL) .username(USER_1_USERNAME) @@ -304,7 +304,7 @@ public class UserEndpointUnitTest extends BaseUnitTest { protected void create_generic(SignupRequestDto data, User user) throws UserEmailAlreadyExistsException, RealmNotFoundException, UserAlreadyExistsException, UserNotFoundException, KeycloakRemoteException, - AccessDeniedException, BrokerVirtualHostCreationException { + AccessDeniedException, BrokerRemoteException { /* mock */ when(userService.create(data)) diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/gateway/BrokerServiceGatewayTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/gateway/BrokerServiceGatewayTest.java index ef9682a26d73a567883962dcc285cbb32fb88de3..bfa22db2fb4cdbc2e42ed45e28fbc49898a2fe8f 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/gateway/BrokerServiceGatewayTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/gateway/BrokerServiceGatewayTest.java @@ -3,6 +3,7 @@ package at.tuwien.gateway; import at.tuwien.BaseUnitTest; import at.tuwien.annotations.MockAmqp; import at.tuwien.annotations.MockOpensearch; +import at.tuwien.exception.BrokerRemoteException; import at.tuwien.exception.BrokerVirtualHostCreationException; import at.tuwien.exception.BrokerVirtualHostGrantException; import lombok.extern.log4j.Log4j2; @@ -37,7 +38,7 @@ public class BrokerServiceGatewayTest extends BaseUnitTest { private BrokerServiceGateway brokerServiceGateway; @Test - public void createVirtualHost_succeeds() throws BrokerVirtualHostCreationException { + public void createVirtualHost_succeeds() throws BrokerVirtualHostCreationException, BrokerRemoteException { final ResponseEntity<Void> mock = ResponseEntity.status(HttpStatus.CREATED) .build(); @@ -65,7 +66,7 @@ public class BrokerServiceGatewayTest extends BaseUnitTest { } @Test - public void grantPermission_exchangeNoRightsBefore_succeeds() throws BrokerVirtualHostGrantException { + public void grantPermission_exchangeNoRightsBefore_succeeds() throws BrokerVirtualHostGrantException, BrokerRemoteException { final ResponseEntity<Void> mock = ResponseEntity.status(HttpStatus.CREATED) .build(); @@ -78,7 +79,7 @@ public class BrokerServiceGatewayTest extends BaseUnitTest { } @Test - public void grantPermission_exchangeRightsSame_succeeds() throws BrokerVirtualHostGrantException { + public void grantPermission_exchangeRightsSame_succeeds() throws BrokerVirtualHostGrantException, BrokerRemoteException { final ResponseEntity<Void> mock = ResponseEntity.status(HttpStatus.NO_CONTENT) .build(); @@ -106,7 +107,7 @@ public class BrokerServiceGatewayTest extends BaseUnitTest { } @Test - public void grantPermission_virtualHostNoRightsBefore_succeeds() throws BrokerVirtualHostGrantException { + public void grantPermission_virtualHostNoRightsBefore_succeeds() throws BrokerRemoteException { final ResponseEntity<Void> mock = ResponseEntity.status(HttpStatus.CREATED) .build(); @@ -119,7 +120,7 @@ public class BrokerServiceGatewayTest extends BaseUnitTest { } @Test - public void grantPermission_virtualHostRightsSame_succeeds() throws BrokerVirtualHostGrantException { + public void grantPermission_virtualHostRightsSame_succeeds() throws BrokerRemoteException { final ResponseEntity<Void> mock = ResponseEntity.status(HttpStatus.NO_CONTENT) .build(); @@ -147,7 +148,7 @@ public class BrokerServiceGatewayTest extends BaseUnitTest { } @Test - public void createUser_succeeds() throws BrokerVirtualHostCreationException { + public void createUser_succeeds() throws BrokerRemoteException { final ResponseEntity<Void> mock = ResponseEntity.status(HttpStatus.NO_CONTENT) .build(); diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/SwaggerComponentTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/SwaggerEndpointMvcTest.java similarity index 85% rename from dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/SwaggerComponentTest.java rename to dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/SwaggerEndpointMvcTest.java index c19bd4bc018cb102665690188d3ab575bff44cfb..c07446eee592ebdb8d2b7d7e631fdc9f10eca927 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/endpoints/SwaggerComponentTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/SwaggerEndpointMvcTest.java @@ -1,16 +1,14 @@ -package at.tuwien.endpoints; +package at.tuwien.mvc; import at.tuwien.BaseUnitTest; import at.tuwien.annotations.MockAmqp; import at.tuwien.annotations.MockOpensearch; -import at.tuwien.repository.sdb.DatabaseIdxRepository; import lombok.extern.log4j.Log4j2; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; @@ -24,7 +22,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest @MockAmqp @MockOpensearch -public class SwaggerComponentTest extends BaseUnitTest { +public class SwaggerEndpointMvcTest extends BaseUnitTest { @Autowired private MockMvc mockMvc; diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/UserEndpointMvcTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/UserEndpointMvcTest.java new file mode 100644 index 0000000000000000000000000000000000000000..44e4c35fcc3cbfa133a258f440a0fa0ef8b604f6 --- /dev/null +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/UserEndpointMvcTest.java @@ -0,0 +1,109 @@ +package at.tuwien.mvc; + +import at.tuwien.BaseUnitTest; +import at.tuwien.annotations.MockAmqp; +import at.tuwien.annotations.MockOpensearch; +import at.tuwien.api.auth.CreateUserDto; +import at.tuwien.api.auth.SignupRequestDto; +import at.tuwien.api.keycloak.UserCreateDto; +import at.tuwien.exception.BrokerRemoteException; +import at.tuwien.exception.KeycloakRemoteException; +import at.tuwien.gateway.BrokerServiceGateway; +import at.tuwien.gateway.KeycloakGateway; +import at.tuwien.gateway.impl.KeycloakGatewayImpl; +import lombok.extern.log4j.Log4j2; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.web.servlet.MockMvc; + +import static at.tuwien.test.utils.ObjectUtil.asJsonString; +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@Log4j2 +@ExtendWith(SpringExtension.class) +@AutoConfigureMockMvc +@SpringBootTest +@MockAmqp +@MockOpensearch +public class UserEndpointMvcTest extends BaseUnitTest { + + @MockBean + private BrokerServiceGateway brokerServiceGateway; + + @MockBean + private KeycloakGatewayImpl keycloakGateway; + + @Autowired + private MockMvc mockMvc; + + @Test + public void createUser_malformed_fails() throws Exception { + final SignupRequestDto request = SignupRequestDto.builder() + .username(USER_1_USERNAME) + .password(USER_1_PASSWORD) + .email("invalid_email") + .build(); + + /* mock */ + doNothing() + .when(brokerServiceGateway) + .createUser(USER_1_USERNAME); + + /* test */ + this.mockMvc.perform(post("/api/user") + .content(asJsonString(request)) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andDo(print()) + .andExpect(status().is(400)); + } + + @Test + public void createUser_keycloakOffline_503_fails() throws Exception { + + /* mock */ + doThrow(KeycloakRemoteException.class) + .when(keycloakGateway) + .createUser(any(UserCreateDto.class)); + + /* test */ + this.mockMvc.perform(post("/api/user") + .content(asJsonString(USER_1_SIGNUP_REQUEST_DTO)) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andDo(print()) + .andExpect(status().is(503)); + } + + @Test + public void createUser_brokerOffline_503_fails() throws Exception { + + /* mock */ + doNothing() + .when(keycloakGateway) + .createUser(any(UserCreateDto.class)); + when(keycloakGateway.findByUsername(USER_1_USERNAME)) + .thenReturn(USER_1_KEYCLOAK_DTO); + doThrow(BrokerRemoteException.class) + .when(brokerServiceGateway) + .createUser(USER_1_USERNAME); + + /* test */ + this.mockMvc.perform(post("/api/user") + .content(asJsonString(USER_1_SIGNUP_REQUEST_DTO)) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andDo(print()) + .andExpect(status().is(503)); + } + +} diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceIntegrationTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceIntegrationTest.java index 67de4364b64bc0dcc5d5f32612a89bbcb5945f03..426f086caa7b394f7171d3c6fd8b48629883b6de 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceIntegrationTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceIntegrationTest.java @@ -6,10 +6,12 @@ import at.tuwien.annotations.MockOpensearch; import at.tuwien.api.database.*; import at.tuwien.config.MariaDbConfig; import at.tuwien.config.MariaDbContainerConfig; +import at.tuwien.config.QueryConfig; import at.tuwien.entities.database.Database; import at.tuwien.entities.user.User; import at.tuwien.exception.*; import at.tuwien.gateway.KeycloakGateway; +import at.tuwien.mapper.DatabaseMapper; import at.tuwien.repository.mdb.*; import at.tuwien.repository.sdb.DatabaseIdxRepository; import at.tuwien.service.impl.MariaDbServiceImpl; @@ -17,6 +19,7 @@ import lombok.extern.log4j.Log4j2; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Answers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; @@ -26,13 +29,14 @@ import org.testcontainers.containers.MariaDBContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; +import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLInvalidAuthorizationSpecException; import java.util.List; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; @Log4j2 @Testcontainers @@ -46,6 +50,9 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { @MockBean private DatabaseIdxRepository databaseIdxRepository; + @MockBean + private QueryConfig queryConfig; + @Autowired private UserRepository userRepository; @@ -109,6 +116,8 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { .thenReturn(DATABASE_1_DTO); when(databaseIdxRepository.save(any(DatabaseDto.class))) .thenReturn(DATABASE_1_DTO); + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); /* test */ generic_create(DATABASE_1_CREATE, DATABASE_1); @@ -123,6 +132,8 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { .thenReturn(DATABASE_1_DTO); when(databaseIdxRepository.save(any(DatabaseDto.class))) .thenReturn(DATABASE_1_DTO); + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); /* test */ generic_create(DATABASE_1_CREATE, DATABASE_1); @@ -139,6 +150,8 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { when(databaseIdxRepository.save(any(DatabaseDto.class))) .thenReturn(DATABASE_2_DTO) .thenReturn(DATABASE_3_DTO); + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); /* test */ generic_create(DATABASE_2_CREATE, DATABASE_2); @@ -155,6 +168,8 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { when(databaseIdxRepository.save(any(DatabaseDto.class))) .thenReturn(DATABASE_3_DTO) .thenReturn(DATABASE_2_DTO); + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); /* test */ generic_create(DATABASE_3_CREATE, DATABASE_3); @@ -169,6 +184,8 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { databaseRepository.deleteAll(); when(databaseIdxRepository.save(any(DatabaseDto.class))) .thenReturn(DATABASE_1_DTO); + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); final Database database = generic_create(DATABASE_1_CREATE, DATABASE_1); @@ -176,6 +193,24 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { MariaDbConfig.getPrivileges(mariaDBContainer.getHost(), mariaDBContainer.getMappedPort(3306), database.getInternalName(), USER_1_USERNAME, USER_1_PASSWORD); } + @Test + public void create_existsRollbackSucceeds_fails() throws Exception { + + /* mock */ + MariaDbConfig.dropDatabase(CONTAINER_1, DATABASE_1_INTERNALNAME); + databaseRepository.deleteAll(); + when(databaseIdxRepository.save(any(DatabaseDto.class))) + .thenReturn(DATABASE_1_DTO); + when(queryConfig.getGrantPrivileges()) + .thenReturn("" /* (1) */, "ALL"/* (2) */); + + /* test */ + assertThrows(DatabaseMalformedException.class, () -> { + databaseService.create(DATABASE_1_CREATE, USER_1_PRINCIPAL); // (1) + }); + generic_create(DATABASE_1_CREATE, DATABASE_1); // (2) + } + @Test public void updatePassword_canLogin_succeeds() throws Exception { @@ -184,15 +219,17 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { databaseAccessRepository.save(DATABASE_1_USER_3_READ_ACCESS); when(databaseIdxRepository.save(any(DatabaseDto.class))) .thenReturn(DATABASE_1_DTO); + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); /* test */ assertThrows(SQLInvalidAuthorizationSpecException.class, () -> { MariaDbConfig.getPrivileges(mariaDBContainer.getHost(), mariaDBContainer.getMappedPort(3306), USER_3_USERNAME, USER_4_PASSWORD); }); databaseService.updatePassword(User.builder() - .id(USER_3_ID) - .username(USER_3_USERNAME) - .mariadbPassword(USER_4_DATABASE_PASSWORD) + .id(USER_3_ID) + .username(USER_3_USERNAME) + .mariadbPassword(USER_4_DATABASE_PASSWORD) .build()); MariaDbConfig.getPrivileges(mariaDBContainer.getHost(), mariaDBContainer.getMappedPort(3306), USER_3_USERNAME, USER_4_PASSWORD); } @@ -200,6 +237,10 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { @Test public void create_queryStore_succeeds() throws Exception { + /* mock */ + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); + /* test */ generic_insert(QUERY_4_STATEMENT, 1L); } @@ -207,6 +248,10 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { @Test public void create_queryStoreSameQueryHash_succeeds() throws Exception { + /* mock */ + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); + /* test */ generic_insert(QUERY_4_STATEMENT, 1L); generic_insert(QUERY_5_STATEMENT, 2L); @@ -216,6 +261,10 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { @Test public void create_systemProcedure_succeeds() throws Exception { + /* mock */ + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); + /* test */ generic_system_insert(CONTAINER_1_PRIVILEGED_USERNAME, CONTAINER_1_PRIVILEGED_PASSWORD); } @@ -223,6 +272,10 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { @Test public void create_systemProcedure_fails() { + /* mock */ + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); + /* test */ assertThrows(SQLException.class, () -> { generic_system_insert("junit1", "junit1"); @@ -232,6 +285,10 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { @Test public void create_userProcedureRoot_succeeds() throws SQLException, QueryMalformedException { + /* mock */ + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); + /* test */ generic_user_insert(CONTAINER_1_PRIVILEGED_USERNAME, CONTAINER_1_PRIVILEGED_PASSWORD); } @@ -244,6 +301,8 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { MariaDbConfig.createInitDatabase(CONTAINER_1, DATABASE_3); mariaDbConfig.grantUserPermissions(CONTAINER_1, DATABASE_3, "junit1"); databaseAccessRepository.save(DATABASE_3_USER_1_WRITE_ALL_ACCESS); + when(queryConfig.getGrantPrivileges()) + .thenCallRealMethod(); /* test */ generic_user_insert("junit1", "junit1"); @@ -275,7 +334,7 @@ public class DatabaseServiceIntegrationTest extends BaseUnitTest { } @Test - public void transfer_succeeds() throws DatabaseNotFoundException, UserNotFoundException{ + public void transfer_succeeds() throws DatabaseNotFoundException, UserNotFoundException { final DatabaseTransferDto request = DatabaseTransferDto.builder() .username(USER_2_USERNAME) .build(); diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceUnitTest.java index 73429969253b1e2ea7761d20d995c4ba95a52716..92236fbb31b2c70db18906792c5c5a0068ef0b1d 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceUnitTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/DatabaseServiceUnitTest.java @@ -100,7 +100,7 @@ public class DatabaseServiceUnitTest extends BaseUnitTest { } @Test - public void create_notFound_fails() throws UserNotFoundException, KeycloakRemoteException, AccessDeniedException { + public void create_notFound_fails() throws UserNotFoundException { final DatabaseCreateDto request = DatabaseCreateDto.builder() .cid(CONTAINER_1_ID) .name(DATABASE_1_NAME) diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/MessageQueueServiceIntegrationTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/MessageQueueServiceIntegrationTest.java index b68d07b0df8de1599b9c0918b304b26cf72787cb..a2059e3539defdbed471eea16cf665b3054690bc 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/MessageQueueServiceIntegrationTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/MessageQueueServiceIntegrationTest.java @@ -4,6 +4,7 @@ import at.tuwien.BaseUnitTest; import at.tuwien.annotations.MockOpensearch; import at.tuwien.api.amqp.PermissionDto; import at.tuwien.exception.AmqpException; +import at.tuwien.exception.BrokerRemoteException; import at.tuwien.exception.BrokerVirtualHostCreationException; import at.tuwien.exception.BrokerVirtualHostGrantException; import at.tuwien.repository.mdb.DatabaseRepository; @@ -85,14 +86,14 @@ public class MessageQueueServiceIntegrationTest extends BaseUnitTest { } @Test - public void createUser_succeeds() throws BrokerVirtualHostCreationException { + public void createUser_succeeds() throws BrokerRemoteException { /* test */ messageQueueService.createUser(USER_1_USERNAME); } @Test - public void updatePermissions_empty_succeeds() throws BrokerVirtualHostGrantException { + public void updatePermissions_empty_succeeds() throws BrokerRemoteException { /* test */ final PermissionDto permissions = updatePermissions_generic(); @@ -104,7 +105,7 @@ public class MessageQueueServiceIntegrationTest extends BaseUnitTest { } @Test - public void updatePermissions_owner_succeeds() throws BrokerVirtualHostGrantException { + public void updatePermissions_owner_succeeds() throws BrokerRemoteException { /* mock */ when(databaseRepository.findConfigureAccess(USER_1_ID)) @@ -124,7 +125,7 @@ public class MessageQueueServiceIntegrationTest extends BaseUnitTest { } @Test - public void updatePermissions_ownerNoAccess_succeeds() throws BrokerVirtualHostGrantException { + public void updatePermissions_ownerNoAccess_succeeds() throws BrokerRemoteException { /* mock */ when(databaseRepository.findConfigureAccess(USER_1_ID)) @@ -163,7 +164,7 @@ public class MessageQueueServiceIntegrationTest extends BaseUnitTest { /* ## GENERIC TEST CASES ## */ /* ################################################################################################### */ - protected PermissionDto updatePermissions_generic() throws BrokerVirtualHostGrantException { + protected PermissionDto updatePermissions_generic() throws BrokerRemoteException { /* mock */ amqpUtils.createUser(USER_1_USERNAME, USER_1_RABBITMQ_CREATE_DTO); diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/QueueServiceIntegrationTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/QueueServiceIntegrationTest.java index c5669b5407ea0225db338a63b204364895ebf1c4..4be1fb518bebd3dcc00d03bf092903a2a63f396d 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/QueueServiceIntegrationTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/QueueServiceIntegrationTest.java @@ -10,6 +10,7 @@ import at.tuwien.config.MariaDbConfig; import at.tuwien.config.MariaDbContainerConfig; import at.tuwien.config.RabbitMqConfig; import at.tuwien.exception.AmqpException; +import at.tuwien.exception.BrokerRemoteException; import at.tuwien.gateway.BrokerServiceGateway; import at.tuwien.listener.impl.RabbitMqListenerImpl; import at.tuwien.repository.mdb.DatabaseRepository; @@ -208,7 +209,7 @@ public class QueueServiceIntegrationTest extends BaseUnitTest { @Test @Disabled("Not testable") - public void restore_succeeds() throws AmqpException, IOException { + public void restore_succeeds() throws AmqpException, IOException, BrokerRemoteException { /* mock */ when(tableRepository.findAll()) diff --git a/dbrepo-metadata-service/rest-service/src/test/resources/application.properties b/dbrepo-metadata-service/rest-service/src/test/resources/application.properties index 2e2bd0d465c79c57ce5ed3a24071c10789e2c503..a004db1bceab10545f026b3752c6db633ddc80b2 100644 --- a/dbrepo-metadata-service/rest-service/src/test/resources/application.properties +++ b/dbrepo-metadata-service/rest-service/src/test/resources/application.properties @@ -16,7 +16,7 @@ spring.jpa.hibernate.ddl-auto=create # logging logging.level.root=error -logging.level.at.tuwien.=debug +logging.level.at.tuwien.=${LOG_LEVEL:-debug} # rabbitmq fda.broker.endpoint=http://localhost:15672 diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/BrokerServiceGateway.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/BrokerServiceGateway.java index ba38f6118fce9c18829ed8cf5c96d9866a37cb47..e1d3f15b8b872fbca4ee2564a8653ad12a76601f 100644 --- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/BrokerServiceGateway.java +++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/BrokerServiceGateway.java @@ -4,6 +4,7 @@ import at.tuwien.api.amqp.ConsumerDto; import at.tuwien.api.amqp.CreateVirtualHostDto; import at.tuwien.api.amqp.GrantVirtualHostPermissionsDto; import at.tuwien.api.user.ExchangeUpdatePermissionsDto; +import at.tuwien.exception.BrokerRemoteException; import at.tuwien.exception.BrokerVirtualHostCreationException; import at.tuwien.exception.BrokerVirtualHostGrantException; @@ -11,40 +12,47 @@ import java.util.List; public interface BrokerServiceGateway { - List<ConsumerDto> findAllConsumers(); + /** + * Finds all active consumers on the virtual host "dbrepo". + * + * @return The list of active consumers. + * @throws BrokerRemoteException The Broker Service did not respond within the 3s timeout. + */ + List<ConsumerDto> findAllConsumers() throws BrokerRemoteException; /** * Create virtual host at the queue service. * * @param data The virtual host. - * @throws BrokerVirtualHostCreationException The queue service did not respond within the 3s timeout. + * @throws BrokerVirtualHostCreationException The virtual host could not be created. + * @throws BrokerRemoteException The Broker Service did not respond within the 3s timeout. */ - void createVirtualHost(CreateVirtualHostDto data) throws BrokerVirtualHostCreationException; + void createVirtualHost(CreateVirtualHostDto data) throws BrokerVirtualHostCreationException, BrokerRemoteException; /** * Grants a user permission at a virtual host in the queue service. * * @param username The username of the user. * @param data The grant data. - * @throws BrokerVirtualHostGrantException The queue service did not respond within the 3s timeout. + * @throws BrokerVirtualHostGrantException The permissions could not be granted. + * @throws BrokerRemoteException The Broker Service did not respond within the 3s timeout. */ - void grantPermission(String username, ExchangeUpdatePermissionsDto data) - throws BrokerVirtualHostGrantException; + void grantPermission(String username, ExchangeUpdatePermissionsDto data) throws BrokerVirtualHostGrantException, BrokerRemoteException; /** * Create user on the broker service * * @param username The new username. - * @throws BrokerVirtualHostCreationException The user could not be created. + * @throws BrokerRemoteException The Broker Service did not respond within the 3s timeout. */ - void createUser(String username) throws BrokerVirtualHostCreationException; + void createUser(String username) throws BrokerRemoteException; /** * Grants a user permission at a virtual host in the queue service. * * @param username The username of the user. * @param data The grant data. - * @throws BrokerVirtualHostGrantException The queue service did not respond within the 3s timeout. + * @throws BrokerRemoteException The Broker Service did not respond within the 3s timeout. */ - void grantPermission(String username, GrantVirtualHostPermissionsDto data) throws BrokerVirtualHostGrantException; + void grantPermission(String username, GrantVirtualHostPermissionsDto data) throws BrokerRemoteException; } diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/KeycloakGateway.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/KeycloakGateway.java index 612ee2eb372cbee0f0c10067d55eba0d2029f988..17e779f918ac5788262e7bb58cc7cd6b27a6acb3 100644 --- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/KeycloakGateway.java +++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/KeycloakGateway.java @@ -9,11 +9,37 @@ import java.util.UUID; public interface KeycloakGateway { + /** + * Creates a user at the Authentication Service with given credentials. + * + * @param data The user credentials. + * @throws AccessDeniedException The admin token could not be obtained. + * @throws KeycloakRemoteException The Authentication Service was not able to respond within the 3s timeout. + * @throws UserAlreadyExistsException The user already exists at the Authentication Service. + * @throws UserEmailAlreadyExistsException The user email already exists in the metadata database. + */ void createUser(UserCreateDto data) throws AccessDeniedException, KeycloakRemoteException, UserAlreadyExistsException, UserEmailAlreadyExistsException; + /** + * Update the credentials for a given user. + * + * @param id The user id. + * @param password The user credential. + * @throws AccessDeniedException The admin token could not be obtained. + * @throws KeycloakRemoteException The Authentication Service was not able to respond within the 3s timeout. + */ void updateUserCredentials(UUID id, UserPasswordDto password) throws AccessDeniedException, KeycloakRemoteException; + /** + * Finds a user in the metadata database by given username. + * + * @param username The user username. + * @return The updated user. + * @throws AccessDeniedException The admin token could not be obtained. + * @throws UserNotFoundException The user was not found, + * @throws KeycloakRemoteException The Authentication Service was not able to respond within the 3s timeout. + */ UserDto findByUsername(String username) throws AccessDeniedException, UserNotFoundException, KeycloakRemoteException; } diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/impl/BrokerServiceGatewayImpl.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/impl/BrokerServiceGatewayImpl.java index de50b0538a1f3a8f8f7e7358d9351b12330a452d..1e44ecec628e86676d2d4b546f848c7188fb38c3 100644 --- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/impl/BrokerServiceGatewayImpl.java +++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/impl/BrokerServiceGatewayImpl.java @@ -7,8 +7,10 @@ import at.tuwien.api.amqp.GrantVirtualHostPermissionsDto; import at.tuwien.api.user.ExchangeUpdatePermissionsDto; import at.tuwien.config.AmqpConfig; import at.tuwien.config.GatewayConfig; +import at.tuwien.exception.BrokerRemoteException; import at.tuwien.exception.BrokerVirtualHostCreationException; import at.tuwien.exception.BrokerVirtualHostGrantException; +import at.tuwien.exception.KeycloakRemoteException; import at.tuwien.gateway.BrokerServiceGateway; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; @@ -33,26 +35,29 @@ import java.util.List; @Service public class BrokerServiceGatewayImpl implements BrokerServiceGateway { - private final Environment environment; private final RestTemplate restTemplate; private final GatewayConfig gatewayConfig; private final static String VIRTUAL_SERVER = "dbrepo"; @Autowired - public BrokerServiceGatewayImpl(Environment environment, GatewayConfig gatewayConfig, + public BrokerServiceGatewayImpl(GatewayConfig gatewayConfig, @Qualifier("brokerRestTemplate") RestTemplate restTemplate) { - this.environment = environment; this.restTemplate = restTemplate; this.gatewayConfig = gatewayConfig; } @Override - public void createVirtualHost(CreateVirtualHostDto data) throws BrokerVirtualHostCreationException { + public void createVirtualHost(CreateVirtualHostDto data) throws BrokerVirtualHostCreationException, BrokerRemoteException { final String url = "/api/vhost"; log.trace("POST {}{}", gatewayConfig.getBrokerEndpoint(), url); - final ResponseEntity<Void> response = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(data), - Void.class); + final ResponseEntity<Void> response; + try { + response = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(data), Void.class); + } catch (Exception e) { + log.error("Failed to create virtual host: remote host answered unexpected: {}", e.getMessage()); + throw new BrokerRemoteException("Failed to create virtual host: remote host answered unexpected", e); + } if (!response.getStatusCode().equals(HttpStatus.CREATED)) { log.error("Failed to create virtual host: {}", response.getStatusCode()); throw new BrokerVirtualHostCreationException("Failed to create virtual host"); @@ -62,11 +67,16 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway { @Override public void grantPermission(String username, ExchangeUpdatePermissionsDto data) - throws BrokerVirtualHostGrantException { + throws BrokerVirtualHostGrantException, BrokerRemoteException { final String url = "/api/topic-permissions/dbrepo/" + username; log.trace("PUT {}{}", gatewayConfig.getBrokerEndpoint(), url); - final ResponseEntity<Void> response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), - Void.class); + final ResponseEntity<Void> response; + try { + response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), Void.class); + } catch (Exception e) { + log.error("Failed to grant permissions: remote host answered unexpected: {}", e.getMessage()); + throw new BrokerRemoteException("Failed to grant permissions: remote host answered unexpected", e); + } if (!response.getStatusCode().equals(HttpStatus.CREATED) && !response.getStatusCode().equals(HttpStatus.NO_CONTENT)) { log.error("Failed to grant exchange: {}", response.getStatusCode()); throw new BrokerVirtualHostGrantException("Failed to grant exchange"); @@ -75,44 +85,59 @@ public class BrokerServiceGatewayImpl implements BrokerServiceGateway { } @Override - public void createUser(String username) throws BrokerVirtualHostCreationException { + public void createUser(String username) throws BrokerRemoteException { final CreateUserDto data = CreateUserDto.builder() .passwordHash("") .tags("") .build(); final String url = "/api/users/" + username; log.trace("PUT {}{}", gatewayConfig.getBrokerEndpoint(), url); - final ResponseEntity<Void> response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), - Void.class); + final ResponseEntity<Void> response; + try { + response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), Void.class); + } catch (Exception e) { + log.error("Failed to create user: remote host answered unexpected: {}", e.getMessage()); + throw new BrokerRemoteException("Failed to create user: remote host answered unexpected", e); + } if (!response.getStatusCode().equals(HttpStatus.CREATED) && !response.getStatusCode().equals(HttpStatus.NO_CONTENT)) { log.error("Failed to create user: {}", response.getStatusCode()); - throw new BrokerVirtualHostCreationException("Failed to create user"); + throw new BrokerRemoteException("Failed to create user"); } log.info("Created user with username {}", username); } @Override - public void grantPermission(String username, GrantVirtualHostPermissionsDto data) - throws BrokerVirtualHostGrantException { + public void grantPermission(String username, GrantVirtualHostPermissionsDto data) throws BrokerRemoteException { final String url = "/api/permissions/dbrepo/" + username; log.trace("PUT {}{}", gatewayConfig.getBrokerEndpoint(), url); - final ResponseEntity<Void> response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), - Void.class); + final ResponseEntity<Void> response; + try { + response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(data), Void.class); + } catch (Exception e) { + log.error("Failed to create permissions: remote host answered unexpected: {}", e.getMessage()); + throw new BrokerRemoteException("Failed to create permissions: remote host answered unexpected", e); + } if (!response.getStatusCode().equals(HttpStatus.CREATED) && !response.getStatusCode().equals(HttpStatus.NO_CONTENT)) { log.error("Failed to grant virtual host: {}", response.getStatusCode()); - throw new BrokerVirtualHostGrantException("Failed to grant virtual host"); + throw new BrokerRemoteException("Failed to grant virtual host"); } log.info("Grant permission for user with username {}", username); } @Override - public List<ConsumerDto> findAllConsumers() { + public List<ConsumerDto> findAllConsumers() throws BrokerRemoteException { final String url = "/api/consumers/" + VIRTUAL_SERVER; log.trace("gateway broker find all consumers, virtual server={}", VIRTUAL_SERVER); log.trace("GET {}{}", gatewayConfig.getBrokerEndpoint(), url); - final ResponseEntity<List<ConsumerDto>> response = restTemplate.exchange(URI.create(url), HttpMethod.GET, - HttpEntity.EMPTY, new ParameterizedTypeReference<>() { - }); + final ResponseEntity<List<ConsumerDto>> response; + try { + response = restTemplate.exchange(URI.create(url), HttpMethod.GET, HttpEntity.EMPTY, + new ParameterizedTypeReference<>() { + }); + } catch (Exception e) { + log.error("Failed to find consumers: remote host answered unexpected: {}", e.getMessage()); + throw new BrokerRemoteException("Failed to find consumers: remote host answered unexpected", e); + } return response.getBody(); } diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/impl/KeycloakGatewayImpl.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/impl/KeycloakGatewayImpl.java index 91f33c336c3bb80322d573a2ad6737c0f32b40a7..d887fd8eb27c918dfb7c2889885fe689d84263bd 100644 --- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/impl/KeycloakGatewayImpl.java +++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/gateway/impl/KeycloakGatewayImpl.java @@ -33,7 +33,7 @@ public class KeycloakGatewayImpl implements KeycloakGateway { this.keycloakConfig = keycloakConfig; } - public TokenDto obtainToken() throws AccessDeniedException { + public TokenDto obtainToken() throws AccessDeniedException, KeycloakRemoteException { final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); final MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(); @@ -49,6 +49,9 @@ public class KeycloakGatewayImpl implements KeycloakGateway { } catch (ResourceAccessException | HttpServerErrorException.ServiceUnavailable e) { log.error("Failed to obtain admin token: {}", e.getMessage()); throw new AccessDeniedException("Failed to obtain admin token: " + e.getMessage()); + } catch (Exception e) { + log.error("Failed to create user: remote host answered unexpected: {}", e.getMessage()); + throw new KeycloakRemoteException("Failed to create user: remote host answered unexpected", e); } return response.getBody(); } @@ -76,6 +79,9 @@ public class KeycloakGatewayImpl implements KeycloakGateway { log.error("Conflict when creating user: {}", e.getMessage()); throw new UserAlreadyExistsException("Conflict when creating user: " + e.getMessage()); } + } catch (Exception e) { + log.error("Failed to create user: remote host answered unexpected: {}", e.getMessage()); + throw new KeycloakRemoteException("Failed to create user: remote host answered unexpected", e); } if (!response.getStatusCode().equals(HttpStatus.CREATED)) { log.error("Failed to create user: status {} was not expected", response.getStatusCode().value()); @@ -99,6 +105,9 @@ public class KeycloakGatewayImpl implements KeycloakGateway { } catch (ResourceAccessException | HttpServerErrorException.ServiceUnavailable e) { log.error("Failed to update user credentials: {}", e.getMessage()); throw new KeycloakRemoteException("Failed to update user credentials: " + e.getMessage()); + } catch (Exception e) { + log.error("Failed to create user: remote host answered unexpected: {}", e.getMessage()); + throw new KeycloakRemoteException("Failed to create user: remote host answered unexpected", e); } if (!response.getStatusCode().equals(HttpStatus.NO_CONTENT)) { log.error("Failed to update user credentials: status {} was not expected", response.getStatusCode().value()); @@ -121,6 +130,9 @@ public class KeycloakGatewayImpl implements KeycloakGateway { } catch (ResourceAccessException | HttpServerErrorException.ServiceUnavailable e) { log.error("Failed to find user: {}", e.getMessage()); throw new KeycloakRemoteException("Failed to find user: " + e.getMessage()); + } catch (Exception e) { + log.error("Failed to create user: remote host answered unexpected: {}", e.getMessage()); + throw new KeycloakRemoteException("Failed to create user: remote host answered unexpected", e); } final UserDto[] body = response.getBody(); if (body == null || body.length != 1) { diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/listener/MessageQueueListener.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/listener/MessageQueueListener.java index f6c0d703b0783e57ca580a58436ddd48a8abc468..7b5c1ffa2cf16f1996372a085f7a0958f36cf931 100644 --- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/listener/MessageQueueListener.java +++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/listener/MessageQueueListener.java @@ -1,6 +1,7 @@ package at.tuwien.listener; import at.tuwien.exception.AmqpException; +import at.tuwien.exception.BrokerRemoteException; import org.springframework.scheduling.annotation.Scheduled; import java.util.concurrent.TimeUnit; @@ -13,5 +14,5 @@ public interface MessageQueueListener { * @throws AmqpException The consumer could not be created. */ @Scheduled(fixedDelay = 5, initialDelay = 300, timeUnit = TimeUnit.SECONDS) - void updateConsumers() throws AmqpException; + void updateConsumers() throws AmqpException, BrokerRemoteException; } diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/listener/impl/RabbitMqListenerImpl.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/listener/impl/RabbitMqListenerImpl.java index cb6c74658562238f4d17d0d86b12ef104d4d849c..cc454351e616943f6179ab5a2bce9b43a91b9972 100644 --- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/listener/impl/RabbitMqListenerImpl.java +++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/listener/impl/RabbitMqListenerImpl.java @@ -1,6 +1,7 @@ package at.tuwien.listener.impl; import at.tuwien.exception.AmqpException; +import at.tuwien.exception.BrokerRemoteException; import at.tuwien.listener.MessageQueueListener; import at.tuwien.service.MessageQueueService; import lombok.extern.log4j.Log4j2; @@ -23,7 +24,7 @@ public class RabbitMqListenerImpl implements MessageQueueListener { @Override @Scheduled(fixedDelay = 5, initialDelay = 300, timeUnit = TimeUnit.SECONDS) @Transactional(readOnly = true) - public void updateConsumers() throws AmqpException { + public void updateConsumers() throws AmqpException, BrokerRemoteException { messageQueueService.restore(); } diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/MessageQueueService.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/MessageQueueService.java index bfd0d4a1d32f1c2817f67ec57a977fe94b6016af..63d5bd064a168343586aae5be63bf052572d62bf 100644 --- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/MessageQueueService.java +++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/MessageQueueService.java @@ -5,6 +5,7 @@ import at.tuwien.entities.database.Database; import at.tuwien.entities.database.table.Table; import at.tuwien.entities.user.User; import at.tuwien.exception.AmqpException; +import at.tuwien.exception.BrokerRemoteException; import at.tuwien.exception.BrokerVirtualHostCreationException; import at.tuwien.exception.BrokerVirtualHostGrantException; import jakarta.annotation.PostConstruct; @@ -46,9 +47,9 @@ public interface MessageQueueService { * Create user on the broker service * * @param username The username. - * @throws BrokerVirtualHostCreationException The user could not be created. + * @throws BrokerRemoteException The user could not be created. */ - void createUser(String username) throws BrokerVirtualHostCreationException; + void createUser(String username) throws BrokerRemoteException; /** @@ -57,7 +58,7 @@ public interface MessageQueueService { * @param user The user. * @throws BrokerVirtualHostGrantException The Broker Service refused to grant the permissions. */ - void updatePermissions(User user) throws BrokerVirtualHostGrantException; + void updatePermissions(User user) throws BrokerVirtualHostGrantException, BrokerRemoteException; /** * Deletes an exchange for a database. @@ -82,5 +83,5 @@ public interface MessageQueueService { * * @throws AmqpException The consumer could not be created. */ - void restore() throws AmqpException; + void restore() throws AmqpException, BrokerRemoteException; } diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/RabbitMqServiceImpl.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/RabbitMqServiceImpl.java index 40272285475a690f8904c7583f5c8a8f6b88d4e2..320c321614c4fc8d152ec8263d2eecb5ef32bd38 100644 --- a/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/RabbitMqServiceImpl.java +++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/service/impl/RabbitMqServiceImpl.java @@ -8,8 +8,8 @@ import at.tuwien.entities.database.Database; import at.tuwien.entities.database.table.Table; import at.tuwien.entities.user.User; import at.tuwien.exception.AmqpException; +import at.tuwien.exception.BrokerRemoteException; import at.tuwien.exception.BrokerVirtualHostCreationException; -import at.tuwien.exception.BrokerVirtualHostGrantException; import at.tuwien.gateway.BrokerServiceGateway; import at.tuwien.mapper.AmqpMapper; import at.tuwien.repository.mdb.DatabaseRepository; @@ -20,7 +20,6 @@ import at.tuwien.service.TableService; import com.fasterxml.jackson.databind.ObjectMapper; import com.rabbitmq.client.BuiltinExchangeType; import com.rabbitmq.client.Channel; -import com.rabbitmq.client.Connection; import com.rabbitmq.client.ConnectionFactory; import lombok.extern.log4j.Log4j2; import org.apache.http.auth.BasicUserPrincipal; @@ -104,12 +103,12 @@ public class RabbitMqServiceImpl implements MessageQueueService { } @Override - public void createUser(String username) throws BrokerVirtualHostCreationException { + public void createUser(String username) throws BrokerRemoteException { brokerServiceGateway.createUser(username); } @Override - public void updatePermissions(User user) throws BrokerVirtualHostGrantException { + public void updatePermissions(User user) throws BrokerRemoteException { final GrantVirtualHostPermissionsDto permissions = GrantVirtualHostPermissionsDto.builder() .configure(amqpMapper.databaseListToPermissionString(databaseRepository.findConfigureAccess(user.getId()))) .write(amqpMapper.databaseListToPermissionString(databaseRepository.findWriteAccess(user.getId()))) @@ -145,7 +144,7 @@ public class RabbitMqServiceImpl implements MessageQueueService { } @Override - public void restore() throws AmqpException { + public void restore() throws AmqpException, BrokerRemoteException { final List<Table> tables = tableService.findAll(); final List<ConsumerDto> consumers = brokerServiceGateway.findAllConsumers(); for (Table table : tables) { diff --git a/dbrepo-metadata-service/test/src/main/java/at/tuwien/test/utils/ObjectUtil.java b/dbrepo-metadata-service/test/src/main/java/at/tuwien/test/utils/ObjectUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..10286fc6bd0635fc340ef538658fcb9d4c267cde --- /dev/null +++ b/dbrepo-metadata-service/test/src/main/java/at/tuwien/test/utils/ObjectUtil.java @@ -0,0 +1,15 @@ +package at.tuwien.test.utils; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ObjectUtil { + + public static String asJsonString(final Object obj) { + try { + return new ObjectMapper().writeValueAsString(obj); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/dbrepo-ui/Dockerfile b/dbrepo-ui/Dockerfile index def7915b216fe1f8e919e397219f6cb00f4c87f5..066d69cb53013b5a7de4d685545cfd0d2538d18b 100644 --- a/dbrepo-ui/Dockerfile +++ b/dbrepo-ui/Dockerfile @@ -41,7 +41,7 @@ EXPOSE 9100 ENV BROKER_USERNAME="fda" ENV BROKER_PASSWORD="fda" -ENV BROKER_LOGIN_URL="/broker/" +ENV BROKER_LOGIN_URL="/admin/broker/" ENV KEYCLOAK_LOGIN_URL="/api/auth/" ENV SHARED_FILESYSTEM="/tmp" ENV LOGO="/logo.png" diff --git a/dbrepo-ui/config.js b/dbrepo-ui/config.js index 480968cd52d0b6053437b3251a50f34b22ce5555..29847aaebe790ef5cdcc825951b8496496931eeb 100644 --- a/dbrepo-ui/config.js +++ b/dbrepo-ui/config.js @@ -1,21 +1,21 @@ const config = {} -config.title = process.env.TITLE || 'Database Repository' -config.icon = process.env.ICON || '/favicon.ico' -config.brokerUsername = process.env.BROKER_USERNAME || 'fda' -config.brokerPassword = process.env.BROKER_PASSWORD || 'fda' -config.brokerLoginUrl = process.env.BROKER_LOGIN_URL || '/broker/' -config.keycloakLoginUrl = process.env.KEYCLOAK_LOGIN_URL || '/api/auth/' -config.sharedFilesystem = process.env.SHARED_FILESYSTEM || '/tmp' -config.version = process.env.VERSION || 'latest' -config.logo = process.env.LOGO || '/logo.png' -config.tokenMax = process.env.TOKEN_MAX || 5 -config.searchUsername = process.env.SEARCH_USERNAME || 'admin' -config.searchPassword = process.env.SEARCH_PASSWORD || 'admin' -config.clientId = process.env.DBREPO_CLIENT_ID || 'dbrepo-client' -config.clientSecret = process.env.DBREPO_CLIENT_SECRET || 'MUwRc7yfXSJwX8AdRMWaQC3Nep1VjwgG' -config.defaultPublisher = process.env.DEFAULT_PID_PUBLISHER || 'Example University' -config.doiUrl = process.env.DOI_URL || 'https://doi.org' -config.uploadPath = process.env.UPLOAD_PATH || '/tmp/' +config.title = process.env.TITLE +config.icon = process.env.ICON +config.brokerUsername = process.env.BROKER_USERNAME +config.brokerPassword = process.env.BROKER_PASSWORD +config.brokerLoginUrl = process.env.BROKER_LOGIN_URL +config.keycloakLoginUrl = process.env.KEYCLOAK_LOGIN_URL +config.sharedFilesystem = process.env.SHARED_FILESYSTEM +config.version = process.env.VERSION +config.logo = process.env.LOGO +config.tokenMax = process.env.TOKEN_MAX +config.searchUsername = process.env.SEARCH_USERNAME +config.searchPassword = process.env.SEARCH_PASSWORD +config.clientId = process.env.DBREPO_CLIENT_ID +config.clientSecret = process.env.DBREPO_CLIENT_SECRET +config.defaultPublisher = process.env.DEFAULT_PID_PUBLISHER +config.doiUrl = process.env.DOI_URL +config.uploadPath = process.env.UPLOAD_PATH module.exports = config diff --git a/dbrepo-ui/pages/login.vue b/dbrepo-ui/pages/login.vue index d99b9622e9ed480642cabf9a0c164e37eef15265..fe6ce6651a514c5a2c904b6e8e623eeb64ae873d 100644 --- a/dbrepo-ui/pages/login.vue +++ b/dbrepo-ui/pages/login.vue @@ -52,8 +52,12 @@ </v-btn> </v-card-actions> <v-card-subtitle class="text-right"> - <a v-if="rabbitMqUrl" color="orange" class="mr-1" plain :href="rabbitMqUrl">RabbitMQ Admin</a> - <a v-if="keycloakUrl" color="secondary" class="ml-1" plain :href="keycloakUrl">Keycloak Admin</a> + <a v-if="rabbitMqUrl" class="mr-1" :href="rabbitMqUrl" target="_blank"> + RabbitMQ Admin <sup><v-icon color="primary" x-small>mdi-open-in-new</v-icon></sup> + </a> + <a v-if="keycloakUrl" class="ml-1" :href="keycloakUrl" target="_blank"> + Keycloak Admin <sup><v-icon color="primary" x-small>mdi-open-in-new</v-icon></sup> + </a> </v-card-subtitle> </v-card> </v-form> diff --git a/docker-compose.yml b/docker-compose.yml index 32d7641a39a1defaead81925c3146706761e47f9..c8c0f5534b4599364949d2588cdac869f4686e8c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -224,7 +224,7 @@ services: - "5672:5672" - "15672:15672" healthcheck: - test: wget -qO- localhost:15672/api/broker | grep "RabbitMQ" || exit 1 + test: wget -qO- localhost:15672/admin/broker | grep "RabbitMQ" || exit 1 interval: 10s timeout: 5s retries: 12 @@ -278,8 +278,8 @@ services: environment: BROKER_USERNAME: "${BROKER_USERNAME:-fda}" BROKER_PASSWORD: "${BROKER_PASSWORD:-fda}" - BROKER_LOGIN_URL: "${BROKER_LOGIN_URL:-/broker/}" - KEYCLOAK_LOGIN_URL: "${KEYCLOAK_LOGIN_URL:-/api/auth/}" + BROKER_LOGIN_URL: "${BROKER_LOGIN_URL:-/admin/broker/}" + KEYCLOAK_LOGIN_URL: "${KEYCLOAK_LOGIN_URL:-/api/auth/admin/}" SHARED_FILESYSTEM: "${SHARED_FILESYSTEM:-/tmp}" LOGO: "${LOGO:-/logo.png}" SEARCH_USERNAME: "${SEARCH_USERNAME:-admin}"