From d996dc0648c6ed5838407e281d0e2f86211958da Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:42:30 +0200 Subject: [PATCH 1/9] add oracle db to docker compose --- stack/docker-compose.yml | 17 ++++++++++++++++- .../1-add-user-wls-broadcast-service.sql | 9 +++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 stack/oracle-database/1-add-user-wls-broadcast-service.sql diff --git a/stack/docker-compose.yml b/stack/docker-compose.yml index 7afe152aa..e54e54055 100644 --- a/stack/docker-compose.yml +++ b/stack/docker-compose.yml @@ -50,6 +50,21 @@ services: networks: - keycloak + wls-db-oracle: + container_name: wls-db-oracle + image: gvenzl/oracle-xe:21-faststart + ports: + - 1521:1521 + environment: + ORACLE_PASSWORD: secret + APP_USER: app_user + APP_USER_PASSWORD: secret + volumes: + - './oracle-database:/container-entrypoint-startdb.d' + networks: + - services + networks: internal: - keycloak: \ No newline at end of file + keycloak: + services: \ No newline at end of file diff --git a/stack/oracle-database/1-add-user-wls-broadcast-service.sql b/stack/oracle-database/1-add-user-wls-broadcast-service.sql new file mode 100644 index 000000000..27e6f56b2 --- /dev/null +++ b/stack/oracle-database/1-add-user-wls-broadcast-service.sql @@ -0,0 +1,9 @@ +-- Switch to pluggable database +alter session set container=XEPDB1; + +-- produces ignorable error message `user name 'WLS_BROADCAST_SERVICE' conflicts with another ...` +-- when the user already exists + +-- add user for wls-broadcast-service +CREATE USER wls_broadcast_service IDENTIFIED BY secret QUOTA UNLIMITED ON USERS; +GRANT CONNECT, RESOURCE, CREATE SESSION TO wls_broadcast_service; \ No newline at end of file From 8bf43a8a24e566e2356d889e827856a65eca210b Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:45:00 +0200 Subject: [PATCH 2/9] add flyway files for h2 and oracle --- .../db/migrations/h2/V0_1__createTableTheEntity.sql | 5 +++++ .../db/migrations/oracle/V0_1__createTableTheEntity.sql | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 wls-broadcast-service/src/main/resources/db/migrations/h2/V0_1__createTableTheEntity.sql create mode 100644 wls-broadcast-service/src/main/resources/db/migrations/oracle/V0_1__createTableTheEntity.sql diff --git a/wls-broadcast-service/src/main/resources/db/migrations/h2/V0_1__createTableTheEntity.sql b/wls-broadcast-service/src/main/resources/db/migrations/h2/V0_1__createTableTheEntity.sql new file mode 100644 index 000000000..1f2b83f72 --- /dev/null +++ b/wls-broadcast-service/src/main/resources/db/migrations/h2/V0_1__createTableTheEntity.sql @@ -0,0 +1,5 @@ +CREATE TABLE theEntity +( + id varchar2(36) NOT NULL primary key, + textAttribute varchar2(8) NOT NULL +) \ No newline at end of file diff --git a/wls-broadcast-service/src/main/resources/db/migrations/oracle/V0_1__createTableTheEntity.sql b/wls-broadcast-service/src/main/resources/db/migrations/oracle/V0_1__createTableTheEntity.sql new file mode 100644 index 000000000..1f2b83f72 --- /dev/null +++ b/wls-broadcast-service/src/main/resources/db/migrations/oracle/V0_1__createTableTheEntity.sql @@ -0,0 +1,5 @@ +CREATE TABLE theEntity +( + id varchar2(36) NOT NULL primary key, + textAttribute varchar2(8) NOT NULL +) \ No newline at end of file From b4f6efceaf191a3e38df53eb189ad24b2ef60c68 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:46:25 +0200 Subject: [PATCH 3/9] =?UTF-8?q?=E2=9E=95=20add=20dep=20for=20flyway=20and?= =?UTF-8?q?=20oracle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wls-broadcast-service/pom.xml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/wls-broadcast-service/pom.xml b/wls-broadcast-service/pom.xml index aab520883..abe4b23dc 100644 --- a/wls-broadcast-service/pom.xml +++ b/wls-broadcast-service/pom.xml @@ -135,6 +135,19 @@ org.hibernate.orm hibernate-core + + org.flywaydb + flyway-core + + + org.flywaydb + flyway-database-oracle + + + com.oracle.database.jdbc + ojdbc11 + 23.3.0.23.09 + org.hibernate.orm @@ -321,7 +334,7 @@ maven-surefire-plugin ${maven-surefire-plugin.version} - ${surefireArgLine} -Dfile.encoding=${project.build.sourceEncoding} + ${surefireArgLine} -Dfile.encoding=${project.build.sourceEncoding} @@ -341,10 +354,10 @@ prepare-agent - true - ${sonar.jacoco.reportPath} - - surefireArgLine + true + ${sonar.jacoco.reportPath} + + surefireArgLine From fa66ddcc69808bac40153ab3bdf3dfd8f612fb91 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:48:58 +0200 Subject: [PATCH 4/9] create profiles for h2 and oracle --- .../src/main/resources/application-db-h2.yml | 17 +++++++++++++++++ .../main/resources/application-db-oracle.yml | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 wls-broadcast-service/src/main/resources/application-db-h2.yml create mode 100644 wls-broadcast-service/src/main/resources/application-db-oracle.yml diff --git a/wls-broadcast-service/src/main/resources/application-db-h2.yml b/wls-broadcast-service/src/main/resources/application-db-h2.yml new file mode 100644 index 000000000..a16613891 --- /dev/null +++ b/wls-broadcast-service/src/main/resources/application-db-h2.yml @@ -0,0 +1,17 @@ +spring: + h2.console.enabled: true + datasource: + username: sa + password: + url: jdbc:h2:mem:wls-broadcast-service + flyway: + enabled: true + jpa: + database: H2 + hibernate: + ddl-auto: validate + naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + properties: + hibernate: + format_sql: true + show-sql: true \ No newline at end of file diff --git a/wls-broadcast-service/src/main/resources/application-db-oracle.yml b/wls-broadcast-service/src/main/resources/application-db-oracle.yml new file mode 100644 index 000000000..e493ef934 --- /dev/null +++ b/wls-broadcast-service/src/main/resources/application-db-oracle.yml @@ -0,0 +1,16 @@ +spring: + datasource: + username: wls_broadcast_service + password: secret + url: jdbc:oracle:thin:@//localhost:1521/XEPDB1 + flyway: + enabled: true + jpa: + database: oracle + hibernate: + ddl-auto: validate + naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + properties: + hibernate: + format_sql: true + show-sql: true \ No newline at end of file From 56ddc7a0695c1706634e6ad762cfbe5a6bf85819 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:49:24 +0200 Subject: [PATCH 5/9] remove database configuration from local profile --- .../src/main/resources/application-local.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/wls-broadcast-service/src/main/resources/application-local.yml b/wls-broadcast-service/src/main/resources/application-local.yml index 382e3a29b..4697e01bc 100644 --- a/wls-broadcast-service/src/main/resources/application-local.yml +++ b/wls-broadcast-service/src/main/resources/application-local.yml @@ -1,7 +1,6 @@ server: port: 39146 spring: - # Spring data rest data: rest: @@ -12,21 +11,6 @@ spring: return-body-on-create: true # Spring JPA - h2.console.enabled: true - jpa: - database: H2 - hibernate: - # always drop and create the db should be the best - # configuration for local (development) mode. this - # is also the default, that spring offers by convention. - # but here explicite: - ddl-auto: create-drop - naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl - # Logging for database operation - show-sql: true - properties: - hibernate: - format_sql: true security: oauth2: resourceserver: From 068002bb94c80adaddde2dd84a6cfb0667d4bfc1 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:53:04 +0200 Subject: [PATCH 6/9] include db-oracle as part of local profile --- wls-broadcast-service/src/main/resources/application.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wls-broadcast-service/src/main/resources/application.yml b/wls-broadcast-service/src/main/resources/application.yml index 3297bfb39..a3b1108ef 100644 --- a/wls-broadcast-service/src/main/resources/application.yml +++ b/wls-broadcast-service/src/main/resources/application.yml @@ -1,6 +1,14 @@ spring: application.name: @project.artifactId@ banner.location: banner.txt + profiles: + group: + local: + - db-oracle + flyway: + locations: + - classpath:db/migrations/{vendor} + h2.console.enabled: false server: shutdown: "graceful" From 2faa45417dc3135c6975aa597ab1338d13a62f4c Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:53:44 +0200 Subject: [PATCH 7/9] add example requests for broadcast service --- .../resources/http_requests/theEntityExamples.http | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 wls-broadcast-service/src/test/resources/http_requests/theEntityExamples.http diff --git a/wls-broadcast-service/src/test/resources/http_requests/theEntityExamples.http b/wls-broadcast-service/src/test/resources/http_requests/theEntityExamples.http new file mode 100644 index 000000000..8ba3d32a8 --- /dev/null +++ b/wls-broadcast-service/src/test/resources/http_requests/theEntityExamples.http @@ -0,0 +1,10 @@ +### +POST http://localhost:39146/theEntities +Content-Type: application/json + +{ + "textAttribute": "my text" +} + +### +GET http://localhost:39146/theEntities \ No newline at end of file From c68505bfa83b4d6c9373dcea3ea0e42cf983fcda Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:38:54 +0200 Subject: [PATCH 8/9] improving filename --- ...add-user-wls-broadcast-service.sql => add-user-on-startup.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename stack/oracle-database/{1-add-user-wls-broadcast-service.sql => add-user-on-startup.sql} (100%) diff --git a/stack/oracle-database/1-add-user-wls-broadcast-service.sql b/stack/oracle-database/add-user-on-startup.sql similarity index 100% rename from stack/oracle-database/1-add-user-wls-broadcast-service.sql rename to stack/oracle-database/add-user-on-startup.sql From 2a2d0485d8028efea4d6731d360dd472220f1348 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:39:32 +0200 Subject: [PATCH 9/9] describing db in docker context --- docs/src/technik/development/index.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/src/technik/development/index.md b/docs/src/technik/development/index.md index 426499445..7ed661c76 100644 --- a/docs/src/technik/development/index.md +++ b/docs/src/technik/development/index.md @@ -14,23 +14,38 @@ flowchart LR keycloak[Keycloak] keycloakDB[db-postgres-keycloak] keycloakInit[init-keycloak] + oracleDB[Oracle DB] end wlsService ---|OAuth2| keycloak + wlsService --->|persisting|oracleDB keycloak-->|persisting| keycloakDB keycloakInit-->|setup of| keycloak end ``` -## Benutzer +## Keycloak + +### Benutzer | Name | Passwort | Beschreibung | | --- | --- | --- | | keycloak_test | test | Ein Benutzer ohne weitere Rechte | | wls_all | test | Ein Benutzer mit allen Rechten | -## Beispiel-Requests +### Beispiel-Requests Im Soap-UI-Projekt (`DockerTest-soapui-project`) und `docker.keycloak.http` sind Beispielrequests vorhanden. -Es kann für den jeweiligen Nutzer ein Token geholt werden. Außerdem ist die Anfrage an den UserInfo-Endpoint hinterlegt. \ No newline at end of file +Es kann für den jeweiligen Nutzer ein Token geholt werden. Außerdem ist die Anfrage an den UserInfo-Endpoint hinterlegt. + +## Datenbank + +Jeder Service bekommt einen eigenen Benutzer für die Datenbank. Die Zugriffs-URL ist für alle Services gleich: +`jdbc:oracle:thin:@//localhost:1521/XEPDB1` + +Neben dem Standardbenutzer der auf alles zugreifen kann (siehe `docker-compose.yml`) müssen alle weiteren Benutzer über `stack/add-user-on-startup.sql` erstellt werden. + +Dabei sollte auf folgendes Schema geachtet werden: +- Benutzername: \ +- Passwort: secret \ No newline at end of file