environment scripting for import-office-tables

This commit is contained in:
Michael Hoennig 2024-01-15 16:31:29 +01:00
parent 5fb21c7b66
commit 4516e842da

View File

@ -58,35 +58,42 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* When run on a Hostsharing database, it needs the following settings (hsh99_... just examples).
*
* In a real hostsharing environment, these are created via (the old) hsadmin:
*
* CREATE USER hsh99_admin WITH PASSWORD 'password';
* CREATE DATABASE hsh99_hsadminng ENCODING 'UTF8' TEMPLATE template0;
* REVOKE ALL ON DATABASE hsh99_hsadminng FROM public; -- why does hsadmin do that?
* ALTER DATABASE hsh99_hsadminng OWNER TO hsh99_admin;
*
* CREATE USER hsh99_restricted WITH PASSWORD 'password';
* GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public to hsh99_restricted;
* In a real Hostsharing environment, these are created via (the old) hsadmin:
* Additionally we need these settings (because the Hostsharing DB-Admin has no CREATE right):
CREATE USER hsh99_admin WITH PASSWORD 'password';
CREATE DATABASE hsh99_hsadminng ENCODING 'UTF8' TEMPLATE template0;
REVOKE ALL ON DATABASE hsh99_hsadminng FROM public; -- why does hsadmin do that?
ALTER DATABASE hsh99_hsadminng OWNER TO hsh99_admin;
CREATE USER hsh99_restricted WITH PASSWORD 'password';
\c hsh99_hsadminng
GRANT ALL PRIVILEGES ON SCHEMA public to hsh99_admin;
* Additionally, we need these settings (because the Hostsharing DB-Admin has no CREATE right):
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- maybe something like that is needed for the 2nd user
-- GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public to hsh99_restricted;
* Then copy this to a file named .environment (excluded from git):
export HSADMINNG_POSTGRES_JDBC_URL=jdbc:postgresql://localhost:6432/hsh99_hsadminng
export HSADMINNG_POSTGRES_ADMIN_USERNAME=hsh99_admin
export HSADMINNG_POSTGRES_ADMIN_PASSWORD=password
export HSADMINNG_POSTGRES_RESTRICTED_USERNAME=hsh99_restricted
* Then, import the office data, uncomment the @Diabled and then run:
*
* CREATE EXTENSION IF EXISTS "uuid-ossp";
*
* Then these environment variables need to be set for Liquibase:
* export HSADMIN_POSTGRES_JDBC=jdbc:postgresql://localhost:6432/hsh99_hsadminng
* export HSADMIN_POSTGRES_ADMIN_USERNAME=hsh99_admin
* export HSADMIN_POSTGRES_ADMIN_PASSWORD=password
* export HSADMIN_POSTGRES_RESTRICTED_USERNAME=hsh99_restricted
*
* Then, to run the import, uncomment the @Diabled and then run:
*
* gw test -tests ImportOfficeTables -x check
* import-office-tables # comes from .aliases file
*/
//@Disabled
@Disabled
@DataJpaTest(properties = {
"spring.datasource.url=${HSADMIN_POSTGRES_JDBC:jdbc:tc:postgresql:15.5-bookworm:///spring_boot_testcontainers}",
"spring.datasource.username=${HSADMIN_POSTGRES_ADMIN_USERNAME:admin}",
"spring.datasource.password=${HSADMIN_POSTGRES_ADMIN_PASSWORD:password}"
"spring.datasource.url=${HSADMINNG_POSTGRES_JDBC_URL:jdbc:tc:postgresql:15.5-bookworm:///spring_boot_testcontainers}",
"spring.datasource.username=${HSADMINNG_POSTGRES_ADMIN_USERNAME:admin}",
"spring.datasource.password=${HSADMINNG_POSTGRES_ADMIN_PASSWORD:password}"
})
@Import({ Context.class, JpaAttempt.class })
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@ -120,6 +127,12 @@ public class ImportOfficeTables extends ContextBasedTest {
@MockBean
HttpServletRequest request;
@Test
@Order(0)
void preconditions() {
assertThat(jdbcUrl).isEqualTo("jdbc:postgresql://localhost:5432/postgres");
}
@Test
@Order(1)
void importBusinessPartners() {