Skip to content

Commit

Permalink
added ability to switch database backends
Browse files Browse the repository at this point in the history
Former-commit-id: d5595768a00fe18cb7df74399cafb0ee307a9eaf
  • Loading branch information
sporth committed Aug 8, 2022
1 parent 90d0570 commit fb95938
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 23 deletions.
19 changes: 19 additions & 0 deletions testbed/smoke-test/db_configs/mariadb.docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
database:
image: mariadb
environment:
MYSQL_DATABASE: shibui
MYSQL_USER: shibui
MYSQL_PASSWORD: shibui
MYSQL_ROOT_PASSWORD: root
healthcheck:
test: mysql -u shibui --password=shibui shibui -e "select 1"
interval: 5s
retries: 5
start_period: 5s
timeout: 10s
shib-idp-ui:
depends_on:
database:
condition: service_healthy

13 changes: 13 additions & 0 deletions testbed/smoke-test/db_configs/mariadb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
spring:
profiles:
include:
datasource:
platform: mysql
driver-class-name: com.mariadb.jdbc.Driver
url: jdbc:mariadb://database:3306/shibui
username: shibui
password: shibui
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MariaDB103Dialect
19 changes: 19 additions & 0 deletions testbed/smoke-test/db_configs/mysql.docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
database:
image: mysql
environment:
MYSQL_DATABASE: shibui
MYSQL_USER: shibui
MYSQL_PASSWORD: shibui
MYSQL_ROOT_PASSWORD: root
healthcheck:
test: mysql -u shibui --password=shibui shibui -e "select 1"
interval: 5s
retries: 5
start_period: 5s
timeout: 10s
shib-idp-ui:
depends_on:
database:
condition: service_healthy

13 changes: 13 additions & 0 deletions testbed/smoke-test/db_configs/mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
spring:
profiles:
include:
datasource:
platform: mysql
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://database:3306/shibui
username: shibui
password: shibui
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
13 changes: 13 additions & 0 deletions testbed/smoke-test/db_configs/postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
spring:
profiles:
include:
datasource:
platform: postgres
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://database:5432/shibui
username: shibui
password: shibui
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
database:
build:
context: ../sqlServer
dockerfile: ../sqlServer/docker/Dockerfile
image: smoke-test_database
# healthcheck:
# test: mysql -u shibui --password=shibui shibui -e "select 1"
# interval: 5s
# retries: 5
# start_period: 5s
# timeout: 10s
# shib-idp-ui:
# depends_on:
# database:
# condition: service_healthy

13 changes: 13 additions & 0 deletions testbed/smoke-test/db_configs/sqlServer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
spring:
profiles:
include:
datasource:
platform: sqlserver
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://database:1433
username: sa
password: Password1
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.SQLServerDialect
22 changes: 12 additions & 10 deletions testbed/smoke-test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ services:
LDAP_DOMAIN: "unicon.local"
HOSTNAME: "directory"
LDAP_TLS_VERIFY_CLIENT: "try"
database:
image: postgres:14-alpine
networks:
- backend
environment:
POSTGRES_PASSWORD: shibui
POSTGRES_USER: shibui
POSTGRES_DB: shibui
idp:
build: ../integration/shibboleth-idp
labels:
Expand Down Expand Up @@ -70,6 +78,9 @@ services:
- "traefik.http.routers.shibui.tls=true"
- "traefik.docker.network=smoke-test_reverse-proxy"
- "traefik.enable=true"
depends_on:
database:
condition: service_started
networks:
- reverse-proxy
- backend
Expand All @@ -81,16 +92,7 @@ services:
- ../integration/shibboleth-idp/credentials/shib-idp/inc-md-cert-mdq.pem:/opt/shibboleth-idp/credentials/inc-md-cert-mdq.pem
environment:
- "IDP_HOME=/opt/shibboleth-idp"
database:
image: postgres:14-alpine
environment:
POSTGRES_PASSWORD: shibui
POSTGRES_USER: shibui
POSTGRES_DB: shibui
networks:
- backend
volumes:
- database_data:/var/lib/postgresql/data

networks:
reverse-proxy:
idp:
Expand Down
22 changes: 22 additions & 0 deletions testbed/smoke-test/setdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

DB=$1

if [[ ! "$DB" =~ ^(postgres|mariadb|mysql|sqlServer)$ ]];
then
echo "argument mst be one of: postgres mariadb mysql sqlServer"
exit 0;
fi

if [[ $DB == "postgres" ]];
then
rm -f docker-compose.override.yml
else
rm -f docker-compose.override.yml
ln -s db_configs/$DB.docker-compose.override.yml docker-compose.override.yml
fi

rm -f shibui/application.yml
cat shibui/application.yml.nodb db_configs/$DB.yml >> shibui/application.yml

echo "shibui will now use the $DB container"
26 changes: 13 additions & 13 deletions testbed/smoke-test/shibui/application.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
server:
forward-headers-strategy: NATIVE
spring:
profiles:
include:
datasource:
platform: postgres
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://database:5432/shibui
username: shibui
password: shibui
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
shibui:
default-password: "{noop}letmein7"
metadata-dir: /var/shibboleth/dynamic_metadata
Expand All @@ -38,3 +25,16 @@ shibui:
email: urn:oid:0.9.2342.19200300.100.1.3
groups: urn:oid:2.5.4.15 # businessCategory
roles: urn:oid:1.3.6.1.4.1.5923.1.1.1.7 # eduPersonEntitlement
spring:
profiles:
include:
datasource:
platform: postgres
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://database:5432/shibui
username: shibui
password: shibui
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
27 changes: 27 additions & 0 deletions testbed/smoke-test/shibui/application.yml.nodb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
server:
forward-headers-strategy: NATIVE
shibui:
default-password: "{noop}letmein7"
metadata-dir: /var/shibboleth/dynamic_metadata
metadataProviders:
target: file:/var/shibboleth/dynamic_config/metadata-providers.xml
user-bootstrap-resource: file:/conf/users.csv
roles: ROLE_ADMIN,ROLE_NONE,ROLE_USER,ROLE_ENABLE,ROLE_PONY
pac4j-enabled: true
pac4j:
keystorePath: "/conf/samlKeystore.jks"
keystorePassword: "changeit"
privateKeyPassword: "changeit"
serviceProviderEntityId: "https://unicon.net/test/shibui"
serviceProviderMetadataPath: "/conf/sp-metadata.xml"
identityProviderMetadataPath: "/conf/idp-metadata.xml"
forceServiceProviderMetadataGeneration: true
callbackUrl: "https://shibui.unicon.local/callback"
maximumAuthenticationLifetime: 3600000
simpleProfileMapping:
username: urn:oid:0.9.2342.19200300.100.1.1
firstName: urn:oid:2.5.4.42
lastName: urn:oid:2.5.4.4
email: urn:oid:0.9.2342.19200300.100.1.3
groups: urn:oid:2.5.4.15 # businessCategory
roles: urn:oid:1.3.6.1.4.1.5923.1.1.1.7 # eduPersonEntitlement

0 comments on commit fb95938

Please sign in to comment.