diff --git a/README.md b/README.md index 5f5dc931..68b89766 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,17 @@ Java 17 and Maven 3.8 required. mvn clean install ``` -This will produce an executabler jar `pass-core-main/target/pass-core-main.jar` and a docker image `ghcr.io/eclipse-pass/pass-core-main`. +This will produce an executabler jar `pass-core-main/target/pass-core-main--exec.jar` and a docker image `ghcr.io/eclipse-pass/pass-core-main`. # Running local build +After you have run `mvn clean install`, execute the following command from the `pass-core-main` directory: + ``` -java -jar pass-core-main.jar +java -Dspring.config.import=file:./src/test/resources/application-test.yml -jar target/pass-core-main--exec.jar ``` -By default an in memory database is used. +This command will use the configuration defined in the `pass-core-main/src/test/resources/application-test.yml` file. **This configuration should not be used in production, it is only meant for testing purposes.** Look at http://localhost:8080/swagger/ to see the auto-created documentation and a UI for testing out the api. @@ -26,62 +28,59 @@ You can directly make request with the UI and see what happens. Note when doing ## Running with Docker -This uses Postgres. - -In pass-core-main run: -``` -docker-compose up -d -``` +Run `mvn clean install`. Then go to the [pass-docker](https://github.com/eclipse-pass/pass-docker) repository and following the instructions for starting a local environment. # Configuration The application is configured by its application.yaml which in turn references a number of environment variables. -By default, pass-core-main, will run with an in memory database. In order to use Postgres, switch to the production profile and set the database environment variables as below. +By default, pass-core-main will run with a typical production configuration. In order to run the default configuration, the environment variables below must be set with appropriate values for your environment. + +Environment variables: +| Environment Variable | Default Value | Description | +|--------------------------------------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------| +| `PASS_CORE_APP_LOCATION` | classpath:app/ | IP address or host name of the server running the SWORD protocol version 2 endpoint | +| `PASS_CORE_APP_CSP` | | TCP port exposing the SWORD protocol version 2 endpoint | +| `PASS_CORE_DATABASE_URL` | | Connection URL to database | +| `PASS_CORE_DATABASE_USERNAME` | | Username for database login | +| `PASS_CORE_DATABASE_PASSWORD` | | Password for database login | +| `PASS_CORE_PORT` | | The port to expose for pass-core API | +| `PASS_CORE_LOG_DIR` | ${java.io.tmpdir}/pass-core | Path to log directory | +| `PASS_CORE_USER` | | Default user name for pass-core | +| `PASS_CORE_PASSWORD` | true | Default user password for pass-core | +| `PASS_CORE_USE_SQS` | true | Flag to use AWS SQS for messaging | +| `PASS_CORE_EMBED_JMS_BROKER` | false | Flag to use Embedded ActiveMQ for messaging | +| `PASS_CORE_SUBMISSION_QUEUE` | pass-submission | Name of submission queue | +| `PASS_CORE_DEPOSIT_QUEUE` | pass-deposit | Name of deposit queue | +| `PASS_CORE_SUBMISSION_EVENT_QUEUE` | pass-submission-event | Name of submission event queue | +| `PASS_CORE_SP_ID` | | SAML SP ID [SAML configuration](#saml-configuration) | +| `PASS_CORE_SP_ACS` | | SAML SP ACS [SAML configuration](#saml-configuration) | +| `PASS_CORE_SP_KEY` | | Location of SAML SP private key pem file [SAML configuration](#saml-configuration) | +| `PASS_CORE_SP_CERT` | | Location of SAML SP public certificate pem file [SAML configuration](#saml-configuration) | +| `PASS_CORE_IDP_METADATA` | | Location of SAML IDM Metadata file [SAML configuration](#saml-configuration) | +| `PASS_CORE_DEAULT_LOGIN_SUCCESS` | | Path to redirect to after login success [SAML configuration](#saml-configuration) | +| `PASS_CORE_LOGIN_PROCESSING_PATH` | | Path to handle login from SAML IDP [SAML configuration](#saml-configuration) | +| `PASS_CORE_LOGOUT_SUCCESS` | | Path to redirect to after SAML logout [SAML configuration](#saml-configuration) | +| `PASS_CORE_LOGOUT_DELETE_COOKIES` | | Name of cookies to delete as part of SAML logout [SAML configuration](#saml-configuration) | +| `PASS_CORE_USERTOKEN_KEY` | | If not present, one is generated. See the [user service](pass-core-user-service/README.md) for how to create manually. | +| `PASS_CORE_JAVA_OPTS` | | Used by the Docker image to pass arguments to Java. | +| `PASS_CORE_BASE_URL` | | Used when services send URLs to the client such as relationship links. | +| `PASS_CORE_FILE_SERVICE_TYPE` | FILE_SYSTEM | The port to expose for pass-core API | +| `PASS_CORE_FILE_SERVICE_ROOT_DIR` | | Path to log directory | +| `PASS_CORE_S3_BUCKET_NAME` | pass-core-file | Default user name for pass-core | +| `PASS_CORE_S3_REPO_PREFIX` | pass-core-file | Default user password for pass-core | +| `PASS_CORE_POLICY_INSTITUTION` | | Name of the institution | +| `PASS_CORE_POLICY_INSTITUTIONAL_POLICY_TITLE` | | Title of the institutional policy | +| `PASS_CORE_POLICY_INSTITUTIONAL_REPOSITORY_NAME` | | Name of institutional repository | + The liquibase changelog located `pass-core-main/src/main/resources/db/changelog/changelog.yaml` will create the pass-core database schema if needed. -If `PASS_CORE_USE_SQS` is `true`, then pass-core will attempt to connect to Amazon SQS. The connection must be configured with `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`. -The AWS credentials are also needed if the file service S3 backend is used. +If `PASS_CORE_USE_SQS` is `true`, then pass-core will attempt to connect to Amazon SQS. For testing purposes, you can set `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY` for connecting to AWS resources. In production, AWS IAM Service Roles should be used. -Otherwise a connection to an ActiveMQ broker can be configured by setting `SPRING_ACTIVEMQ_BROKER_URL`. If 'PASS_CORE_EMBED_JMS_BROKER` is true, then an embedded ActiveMQ broker will be started +Otherwise, a connection to an ActiveMQ broker can be configured by setting `SPRING_ACTIVEMQ_BROKER_URL`. If `PASS_CORE_EMBED_JMS_BROKER` is true, then an embedded ActiveMQ broker will be started using that url. This can be useful to set tcp transport for connecting containers in a docker environment. The default is an embedded broker using vm transport. -Environment variables: -* spring_profiles_active=production -* AWS_REGION=us-east-1 -* AWS_ACCESS_KEY_ID=xxx -* AWS_SECRET_ACCESS_KEY=xxx -* PASS_CORE_APP_LOCATION=classpath:app -* PASS_CORE_APP_CSP=default-src 'self'; -* PASS_CORE_DATABASE_URL=jdbc:postgresql://postgres:5432/pass -* PASS_CORE_DATABASE_USERNAME=pass -* PASS_CORE_DATABASE_PASSWORD=moo -* PASS_CORE_PORT=8080 -* PASS_CORE_LOG_DIR=${java.io.tmpdir}/pass-core -* PASS_CORE_USER=backend -* PASS_CORE_PASSWORD=moo -* PASS_CORE_USE_SQS=false -* PASS_CORE_EMBED_JMS_BROKER=true -* PASS_CORE_SUBMISSION_QUEUE=pass-submission -* PASS_CORE_DEPOSIT_QUEUE=pass-deposit -* PASS_CORE_IDP_METADATA=classpath:saml2/idp-metadata.xml -* PASS_CORE_DEAULT_LOGIN_SUCCESS=/app/ -* PASS_CORE_LOGOUT_SUCCESS=/app/ -* PASS_CORE_LOGOUT_DELETE_COOKIES="JSESSIONID /" -* PASS_CORE_SP_ID=https://sp.pass/shibboleth -* PASS_CORE_SP_ACS=http://localhost:8080/login/saml2/sso/pass -* PASS_CORE_LOGIN_PROCESSING_PATH=/login/saml2/sso/pass -* PASS_CORE_SP_KEY=classpath:saml2/sp-key.pem -* PASS_CORE_SP_CERT=classpath:saml2/sp-cert.pem -* PASS_CORE_SUBMISSION_EVENT_QUEUE=pass-submission-event -* PASS_CORE_USERTOKEN_KEY=xxx - * If not present, one is generated. See the [user service](pass-core-user-service/README.md) for how to create manually. -* PASS_CORE_JAVA_OPTS="" - * Used by the Docker image to pass arguments to Java -* PASS_CORE_BASE_URL=http://localhost:8080 - * Used when services send URLs to the client such as relationship links. - -The environment variables in `pass-core-main/.env` are intended to be used for local testing of pass-core in isolation. +**Note you can quickly start pass-core locally for testing purposes following the instructions in [Running local build](#running-local-build) section.** # Access control @@ -102,11 +101,11 @@ Use `PASS_CORE_SP_ID` to set the identifier of the pass-core SP, `PASS_CORE_IDP_ `PASS_CORE_SP_ACS` for the Assertion Consumer Service of the SP and `PASS_CORE_LOGIN_PROCESSING_PATH` to set the path for handling login from the IDP. Note that `PASS_CORE_SP_ACS` is a URL which must match the path specified in `PASS_CORE_LOGIN_PROCESSING_PATH`. -The defaults are set such that the integration tests can run against a [SimpleSAMLphp based IDP](https://github.com/kenchan0130/docker-simplesamlphp/) using resources included in `saml2/`. These defaults should not be used in production. +The `application-test.yml` configuration is set such that the integration tests can run against a [SimpleSAMLphp based IDP](https://github.com/kenchan0130/docker-simplesamlphp/) using resources included in `saml2/`. These defaults should not be used in production. The image can be run with: ``` -docker run --name=idp -p 8090:8080 -e SIMPLESAMLPHP_SP_ENTITY_ID=https://sp.pass/shibboleth -e SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE=http://localhost:8080/login/saml2/sso/pass -e SIMPLESAMLPHP_IDP_BASE_URL=http://localhost:8090/ -v ./pass-core/pass-core/main/src/main/resources/saml2/authsources.php:/var/www/simplesamlphp/config/authsources.php -d kenchan0130/simplesamlphp +docker run --name=idp -p 8090:8080 -e SIMPLESAMLPHP_SP_ENTITY_ID=https://sp.pass/shibboleth -e SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE=http://localhost:8080/login/saml2/sso/pass -e SIMPLESAMLPHP_IDP_BASE_URL=http://localhost:8090/ -v ./pass-core/pass-core/main/src/test/resources/saml2/authsources.php:/var/www/simplesamlphp/config/authsources.php -d kenchan0130/simplesamlphp ``` Note the volume mount which is set the user information appropriately for PASS. diff --git a/pass-core-main/.env b/pass-core-main/.env deleted file mode 100644 index 0e5deae4..00000000 --- a/pass-core-main/.env +++ /dev/null @@ -1,44 +0,0 @@ -spring_profiles_active=production - -# Postgres configuration - -POSTGRES_USER=postgres -POSTGRES_PASSWORD=postgres - -# AWS configuration - -# AWS_REGION=us-east-1 -# AWS_ACCESS_KEY_ID=xxx -# AWS_SECRET_ACCESS_KEY=xxx - -# PASS core configuration - -PASS_CORE_USE_SQS=false -PASS_CORE_EMBED_JMS_BROKER=true - -PASS_CORE_SUBMISSION_QUEUE=pass-submission -PASS_CORE_DEPOSIT_QUEUE=pass-deposit -PASS_CORE_SUBMISSION_EVENT_QUEUE=pass-submission-event - -PASS_CORE_DATABASE_URL=jdbc:postgresql://postgres:5432/pass -PASS_CORE_DATABASE_USERNAME=pass -PASS_CORE_DATABASE_PASSWORD=moo - -PASS_CORE_USER=backend -PASS_CORE_PASSWORD=moo - -PASS_CORE_PORT=8080 -PASS_CORE_BASE_URL=http://localhost:8080 - -PASS_CORE_FILE_SERVICE_TYPE=FILE_SYSTEM -PASS_CORE_FILE_SERVICE_ROOT_DIR= -PASS_CORE_S3_BUCKET_NAME=bucket-test-name -PASS_CORE_S3_REPO_PREFIX=s3-repo-prefix -PASS_CORE_S3_ENDPOINT=http://localhost:9090 - -PASS_CORE_POLICY_INSTITUTION=johnshopkins.edu -PASS_CORE_POLICY_INSTITUTIONAL_POLICY_TITLE=Johns Hopkins University (JHU) Open Access Policy -PASS_CORE_POLICY_INSTITUTIONAL_REPOSITORY_NAME=JScholarship - -# Automatically create database tables -PASS_CORE_JAVA_OPTS="" diff --git a/pass-core-main/docker-compose.yml b/pass-core-main/docker-compose.yml deleted file mode 100644 index 343036c3..00000000 --- a/pass-core-main/docker-compose.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: '3.8' -services: - postgres: - image: postgres:14-alpine - restart: always - env_file: .env - ports: - - '5432:5432' - volumes: - - db:/var/lib/postgresql/data - - ./init_postgres.sh:/docker-entrypoint-initdb.d/init_postgres.sh - core: - image: ghcr.io/eclipse-pass/pass-core-main:0.6.0-SNAPSHOT - build: - context: . - env_file: .env - ports: - - '8080:8080' -volumes: - db: - driver: local diff --git a/pass-core-main/src/main/resources/application.yaml b/pass-core-main/src/main/resources/application.yaml index 7aa77e49..853a69cc 100644 --- a/pass-core-main/src/main/resources/application.yaml +++ b/pass-core-main/src/main/resources/application.yaml @@ -5,7 +5,7 @@ ################################################ elide: - baseUrl: ${PASS_CORE_BASE_URL:http://localhost:8080} + baseUrl: ${PASS_CORE_BASE_URL} json-api: path: /data enabled: true @@ -20,15 +20,11 @@ elide: async: enabled: false aggregation-store: - enabled: false + default-dialect: Postgres spring: application: name: pass-core - artemis: - embedded: - enabled: ${PASS_CORE_EMBED_JMS_BROKER:true} - queues: pass-submission,pass-deposit,pass-submission-event jpa: properties: hibernate: @@ -37,14 +33,14 @@ spring: show_sql: true naming: physical-strategy: 'org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl' - dialect: 'org.hibernate.dialect.H2Dialect' + dialect: 'org.hibernate.dialect.PostgreSQLDialect' jdbc: use_scrollable_resultset: true datasource: - url: 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE' - username: 'sa' - password: '' - driver-class-name: 'org.h2.Driver' + url: ${PASS_CORE_DATABASE_URL} + username: ${PASS_CORE_DATABASE_USERNAME} + password: ${PASS_CORE_DATABASE_PASSWORD} + driver-class-name: 'org.postgresql.Driver' liquibase: change-log: 'classpath:db/changelog/core-changelog.yaml' parameters: @@ -54,22 +50,22 @@ spring: relyingparty: registration: pass: - entity-id: ${PASS_CORE_SP_ID:https://sp.pass/shibboleth} + entity-id: ${PASS_CORE_SP_ID} signing: credentials: - - private-key-location: ${PASS_CORE_SP_KEY:classpath:saml2/sp-key.pem} - certificate-location: ${PASS_CORE_SP_CERT:classpath:saml2/sp-cert.pem} + - private-key-location: ${PASS_CORE_SP_KEY} + certificate-location: ${PASS_CORE_SP_CERT} decryption: credentials: - - private-key-location: ${PASS_CORE_SP_KEY:classpath:saml2/sp-key.pem} - certificate-location: ${PASS_CORE_SP_CERT:classpath:saml2/sp-cert.pem} + - private-key-location: ${PASS_CORE_SP_KEY} + certificate-location: ${PASS_CORE_SP_CERT} acs: - location: ${PASS_CORE_SP_ACS:{baseUrl}/login/saml2/sso/{registrationId}} + location: ${PASS_CORE_SP_ACS} assertingparty: - metadata-uri: ${PASS_CORE_IDP_METADATA:classpath:saml2/idp-metadata.xml} + metadata-uri: ${PASS_CORE_IDP_METADATA} user: - name: ${PASS_CORE_USER:backend} - password: ${PASS_CORE_PASSWORD:moo} + name: ${PASS_CORE_USER} + password: ${PASS_CORE_PASSWORD} roles: BACKEND servlet: multipart: @@ -77,7 +73,7 @@ spring: max-request-size: 100MB server: - port: 8080 + port: ${PASS_CORE_PORT} shutdown: graceful logging: @@ -86,8 +82,6 @@ logging: aws: region: us-east-1 - sqs: - endpoint-override: ${AWS_SQS_ENDPOINT_OVERRIDE:} pass: app-location: ${PASS_CORE_APP_LOCATION:classpath:app/} @@ -101,64 +95,26 @@ pass: SURNAME: 'urn:oid:2.5.4.4' EMPLOYEE_ID: 'urn:oid:2.16.840.1.113730.3.1.3' UNIQUE_ID: 'urn:oid:1.3.6.1.4.1.5923.1.1.1.13' - csp: ${PASS_CORE_APP_CSP:default-src 'self';} + csp: ${PASS_CORE_APP_CSP} file-service: - storage-type: 'FILE_SYSTEM' + storage-type: ${PASS_CORE_FILE_SERVICE_TYPE:FILE_SYSTEM} + root-dir: ${PASS_CORE_FILE_SERVICE_ROOT_DIR:} + s3-bucket-name: ${PASS_CORE_S3_BUCKET_NAME:pass-core-file} + s3-repo-prefix: ${PASS_CORE_S3_REPO_PREFIX:pass-core-file} jms: queue: submission: ${PASS_CORE_SUBMISSION_QUEUE:pass-submission} deposit: ${PASS_CORE_DEPOSIT_QUEUE:pass-deposit} submission-event: ${PASS_CORE_SUBMISSION_EVENT_QUEUE:pass-submission-event} - sqs: ${PASS_CORE_USE_SQS:false} - embed: ${PASS_CORE_EMBED_JMS_BROKER:true} - default-login-success-url: ${PASS_CORE_DEFAULT_LOGIN_SUCCESS:/app/} - login-processing-path: ${PASS_CORE_LOGIN_PROCESSING_PATH:/login/saml2/sso/{registrationId}} - logout-delete-cookies: ${PASS_CORE_LOGOUT_DELETE_COOKIES:JSESSIONID /} - logout-success-url: ${PASS_CORE_LOGOUT_SUCCESS:/login} + sqs: ${PASS_CORE_USE_SQS:true} + embed: ${PASS_CORE_EMBED_JMS_BROKER:false} + default-login-success-url: ${PASS_CORE_DEFAULT_LOGIN_SUCCESS} + login-processing-path: ${PASS_CORE_LOGIN_PROCESSING_PATH} + logout-delete-cookies: ${PASS_CORE_LOGOUT_DELETE_COOKIES} + logout-success-url: ${PASS_CORE_LOGOUT_SUCCESS} policy: - institution: ${PASS_CORE_POLICY_INSTITUTION:johnshopkins.edu} - institutional_policy_title: ${PASS_CORE_POLICY_INSTITUTIONAL_POLICY_TITLE:Johns Hopkins University (JHU) Open Access Policy} - institutional_repository_name: ${PASS_CORE_POLICY_INSTITUTIONAL_REPOSITORY_NAME:JScholarship} + institution: ${PASS_CORE_POLICY_INSTITUTION} + institutional_policy_title: ${PASS_CORE_POLICY_INSTITUTIONAL_POLICY_TITLE} + institutional_repository_name: ${PASS_CORE_POLICY_INSTITUTIONAL_REPOSITORY_NAME} usertoken: - key: ${PASS_CORE_USERTOKEN_KEY:} - ---- -elide: - aggregation-store: - default-dialect: Postgres - -spring: - config: - activate: - on-profile: "production" - jpa: - hibernate: - show_sql: true - naming: - physical-strategy: 'org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl' - dialect: 'org.hibernate.dialect.PostgreSQLDialect' - jdbc: - use_scrollable_resultset: true - datasource: - url: ${PASS_CORE_DATABASE_URL} - username: ${PASS_CORE_DATABASE_USERNAME} - password: ${PASS_CORE_DATABASE_PASSWORD} - driver-class-name: 'org.postgresql.Driver' - security: - user: - name: ${PASS_CORE_USER} - password: ${PASS_CORE_PASSWORD} - roles: BACKEND - -server: - port: ${PASS_CORE_PORT} - -pass: - jms: - sqs: ${PASS_CORE_USE_SQS:true} - file-service: - storage-type: ${PASS_CORE_FILE_SERVICE_TYPE:FILE_SYSTEM} - root-dir: ${PASS_CORE_FILE_SERVICE_ROOT_DIR:} - s3-bucket-name: ${PASS_CORE_S3_BUCKET_NAME:pass-core-file} - s3-repo-prefix: ${PASS_CORE_S3_REPO_PREFIX:pass-core-file} - s3-endpoint: ${PASS_CORE_S3_ENDPOINT:} + key: ${PASS_CORE_USERTOKEN_KEY} diff --git a/pass-core-main/src/test/java/org/eclipse/pass/file/service/storage/StorageConfigurationTest.java b/pass-core-main/src/test/java/org/eclipse/pass/file/service/storage/StorageConfigurationTest.java index 05388a83..c5eba72d 100644 --- a/pass-core-main/src/test/java/org/eclipse/pass/file/service/storage/StorageConfigurationTest.java +++ b/pass-core-main/src/test/java/org/eclipse/pass/file/service/storage/StorageConfigurationTest.java @@ -25,7 +25,7 @@ /** * @author Russ Poetker (rpoetke1@jh.edu) */ -@ActiveProfiles("default-test") +@ActiveProfiles("test") public class StorageConfigurationTest extends SimpleIntegrationTest { @Autowired private StorageProperties storageProperties; diff --git a/pass-core-main/src/test/java/org/eclipse/pass/main/AwsParamStoreConfigTest.java b/pass-core-main/src/test/java/org/eclipse/pass/main/AwsParamStoreConfigTest.java index ebb725af..fe414a1e 100644 --- a/pass-core-main/src/test/java/org/eclipse/pass/main/AwsParamStoreConfigTest.java +++ b/pass-core-main/src/test/java/org/eclipse/pass/main/AwsParamStoreConfigTest.java @@ -26,6 +26,7 @@ import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.core.env.Environment; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; @@ -38,9 +39,13 @@ properties = { "spring.cloud.aws.credentials.access-key=noop", "spring.cloud.aws.credentials.secret-key=noop", - "spring.cloud.aws.region.static=us-east-1" + "spring.cloud.aws.region.static=us-east-1", + "spring.security.user.name=${PASS_CORE_USER:test-user}", + "spring.security.user.password=${PASS_CORE_PASSWORD:test-user-pw}", + "pass.app-location=${PASS_CORE_APP_LOCATION:classpath:app/}" }) @ContextConfiguration(initializers = ConfigDataApplicationContextInitializer.class) +@ActiveProfiles("test") @Testcontainers class AwsParamStoreConfigTest { private static final DockerImageName LOCALSTACK_IMG = @@ -68,19 +73,19 @@ static void beforeAll() throws IOException, InterruptedException { "--value", "aws-param-store-pw", "--type", "SecureString"); localStack.execInContainer("awslocal", "ssm", "put-parameter", - "--name", "/config/pass-core/PASS_CORE_INSTN_CHG_LOG", - "--value", "test-chg-log", + "--name", "/config/pass-core/PASS_CORE_APP_LOCATION", + "--value", "aws-param-test-app-loc", "--type", "SecureString"); } @Test public void testLoadPropFromParamStore() { String userNameProp = environment.getProperty("spring.security.user.name"); - assertEquals("backend", userNameProp); + assertEquals("test-user", userNameProp); String userPwProp = environment.getProperty("spring.security.user.password"); assertEquals("aws-param-store-pw", userPwProp); - String changeLogProp = environment.getProperty("spring.liquibase.parameters.institution-changelog-file"); - assertEquals("test-chg-log", changeLogProp); + String changeLogProp = environment.getProperty("pass.app-location"); + assertEquals("aws-param-test-app-loc", changeLogProp); } } \ No newline at end of file diff --git a/pass-core-main/src/test/java/org/eclipse/pass/main/SamlIntegrationTest.java b/pass-core-main/src/test/java/org/eclipse/pass/main/SamlIntegrationTest.java index 4e311b68..ddb696b8 100644 --- a/pass-core-main/src/test/java/org/eclipse/pass/main/SamlIntegrationTest.java +++ b/pass-core-main/src/test/java/org/eclipse/pass/main/SamlIntegrationTest.java @@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.test.context.ActiveProfiles; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; @@ -37,6 +38,7 @@ */ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = Main.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) +@ActiveProfiles("test") @Testcontainers public class SamlIntegrationTest extends IntegrationTestBase { private static final String IDP_IMAGE = "kenchan0130/simplesamlphp:1.19.8"; diff --git a/pass-core-main/src/test/java/org/eclipse/pass/main/SimpleIntegrationTest.java b/pass-core-main/src/test/java/org/eclipse/pass/main/SimpleIntegrationTest.java index eb77d27a..188b2f12 100644 --- a/pass-core-main/src/test/java/org/eclipse/pass/main/SimpleIntegrationTest.java +++ b/pass-core-main/src/test/java/org/eclipse/pass/main/SimpleIntegrationTest.java @@ -20,12 +20,14 @@ import org.junit.jupiter.api.TestInstance; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.test.context.ActiveProfiles; /** * Run with in memory database. */ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Main.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) +@ActiveProfiles("test") public abstract class SimpleIntegrationTest extends IntegrationTestBase { @LocalServerPort diff --git a/pass-core-main/src/test/resources/application-default-test.yml b/pass-core-main/src/test/resources/application-default-test.yml deleted file mode 100644 index ca39a0a7..00000000 --- a/pass-core-main/src/test/resources/application-default-test.yml +++ /dev/null @@ -1,9 +0,0 @@ -aws: - region: us-east-1 - -pass: - jms: - embed: false - file-service: - storage-type: FILE_SYSTEM - root-dir: ${PASS_CORE_FILE_SERVICE_ROOT_DIR:} \ No newline at end of file diff --git a/pass-core-main/src/test/resources/application-test.yml b/pass-core-main/src/test/resources/application-test.yml new file mode 100644 index 00000000..2bbce084 --- /dev/null +++ b/pass-core-main/src/test/resources/application-test.yml @@ -0,0 +1,75 @@ +elide: + baseUrl: http://localhost:8080 + aggregation-store: + enabled: false + +PASS_TEST_RESC_PATH: ${user.dir}/src/test/resources + +spring: + application: + name: pass-core + artemis: + embedded: + enabled: true + queues: pass-submission,pass-deposit,pass-submission-event + jpa: + hibernate: + dialect: 'org.hibernate.dialect.H2Dialect' + datasource: + url: 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE' + username: 'sa' + password: '' + driver-class-name: 'org.h2.Driver' + security: + saml2: + relyingparty: + registration: + pass: + entity-id: https://sp.pass/shibboleth + signing: + credentials: + - private-key-location: file:${PASS_TEST_RESC_PATH}/saml2/sp-key.pem + certificate-location: file:${PASS_TEST_RESC_PATH}/saml2/sp-cert.pem + decryption: + credentials: + - private-key-location: file:${PASS_TEST_RESC_PATH}/saml2/sp-key.pem + certificate-location: file:${PASS_TEST_RESC_PATH}/saml2/sp-cert.pem + acs: + location: "{baseUrl}/login/saml2/sso/{registrationId}" + assertingparty: + metadata-uri: file:${PASS_TEST_RESC_PATH}/saml2/idp-metadata.xml + user: + name: backend + password: moo + +server: + port: 8080 + shutdown: graceful + +logging: + file: + path: ${java.io.tmpdir}/pass-core + +aws: + sqs: + endpoint-override: ${AWS_SQS_ENDPOINT_OVERRIDE:} + +pass: + csp: ${PASS_CORE_APP_CSP:default-src 'self';} + jms: + queue: + submission: pass-submission + deposit: pass-deposit + submission-event: pass-submission-event + sqs: false + embed: true + default-login-success-url: /app/ + login-processing-path: /login/saml2/sso/pass + logout-delete-cookies: JSESSIONID / + logout-success-url: /login + policy: + institution: johnshopkins.edu + institutional_policy_title: "Johns Hopkins University (JHU) Open Access Policy" + institutional_repository_name: JScholarship + usertoken: + key: diff --git a/pass-core-main/src/main/resources/saml2/authsources.php b/pass-core-main/src/test/resources/saml2/authsources.php similarity index 100% rename from pass-core-main/src/main/resources/saml2/authsources.php rename to pass-core-main/src/test/resources/saml2/authsources.php diff --git a/pass-core-main/src/main/resources/saml2/idp-metadata.xml b/pass-core-main/src/test/resources/saml2/idp-metadata.xml similarity index 100% rename from pass-core-main/src/main/resources/saml2/idp-metadata.xml rename to pass-core-main/src/test/resources/saml2/idp-metadata.xml diff --git a/pass-core-main/src/main/resources/saml2/sp-cert.pem b/pass-core-main/src/test/resources/saml2/sp-cert.pem similarity index 100% rename from pass-core-main/src/main/resources/saml2/sp-cert.pem rename to pass-core-main/src/test/resources/saml2/sp-cert.pem diff --git a/pass-core-main/src/main/resources/saml2/sp-key.pem b/pass-core-main/src/test/resources/saml2/sp-key.pem similarity index 100% rename from pass-core-main/src/main/resources/saml2/sp-key.pem rename to pass-core-main/src/test/resources/saml2/sp-key.pem