This is an automated email from the ASF dual-hosted git repository. arnold pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/fineract.git
commit a8af5f60f772f113a247a7926b26dc717b948511 Author: Arnold Galovics <[email protected]> AuthorDate: Tue Jun 6 14:52:27 2023 +0200 FINERACT-1724: Removed unused instancemode-tests folder --- instancemode-tests/build.gradle | 113 ------------ instancemode-tests/dependencies.gradle | 43 ----- .../integrationtests/BatchInstanceModeTest.java | 199 --------------------- .../src/test/resources/cucumber.properties | 21 --- .../src/test/resources/junit-platform.properties | 20 --- .../test/resources/michael.vorburger-crepes.jpg | Bin 2080155 -> 0 bytes 6 files changed, 396 deletions(-) diff --git a/instancemode-tests/build.gradle b/instancemode-tests/build.gradle deleted file mode 100644 index ae9b5f719..000000000 --- a/instancemode-tests/build.gradle +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -description = 'Fineract Instance Type Tests' - -apply plugin: 'com.bmuschko.cargo' - -// Configuration for the Gradle Cargo plugin -// https://github.com/bmuschko/gradle-cargo-plugin -configurations { - tomcat -} - -apply from: 'dependencies.gradle' - -// enable when all tests are migrated -tasks.cucumber.onlyIf {false} - -// Allow external drivers to be used for the tests without packaging it -// mainly due to license incompatibilities -configurations { - driver -} -dependencies { - driver 'mysql:mysql-connector-java:8.0.32' -} - -cargo { - containerId "tomcat9x" - - // looks like Cargo doesn't detect the WAR file automatically in the multi-module setup - deployable { - file = file("$rootDir/fineract-war/build/libs/fineract-provider.war") - context = 'fineract-provider' - } - - local { - logLevel = 'high' - outputFile = file('build/output.log') - installer { - installConfiguration = configurations.tomcat - downloadDir = file("$buildDir/download") - extractDir = file("$buildDir/tomcat") - } - startStopTimeout = 960000 - sharedClasspath = configurations.driver - containerProperties { - def jvmArgs = '--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAMED ' - if (project.hasProperty('localDebug')) { - jvmArgs += ' -agentlib:jdwp=transport=dt_socket,server=y,address=*:9000,suspend=n -Xmx2G -Duser.timezone=Asia/Kolkata ' - } - if (project.hasProperty('dbType')) { - if ('postgresql'.equalsIgnoreCase(dbType)) { - jvmArgs += '-Dspring.datasource.hikari.driverClassName=org.postgresql.Driver -Dspring.datasource.hikari.jdbcUrl=jdbc:postgresql://localhost:5432/fineract_tenants -Dspring.datasource.hikari.username=root -Dspring.datasource.hikari.password=postgres -Dfineract.tenant.host=localhost -Dfineract.tenant.port=5432 -Dfineract.tenant.username=root -Dfineract.tenant.password=postgres' - } else if ('mysql'.equalsIgnoreCase(dbType)) { - jvmArgs += '-Dspring.datasource.hikari.driverClassName=com.mysql.cj.jdbc.Driver -Dspring.datasource.hikari.jdbcUrl=jdbc:mysql://localhost:3306/fineract_tenants -Dspring.datasource.hikari.username=root -Dspring.datasource.hikari.password=mysql -Dfineract.tenant.host=localhost -Dfineract.tenant.port=3306 -Dfineract.tenant.username=root -Dfineract.tenant.password=mysql' - } else { - throw new GradleException('Provided dbType is not supported') - } - } else { - jvmArgs += '-Dspring.datasource.hikari.driverClassName=org.mariadb.jdbc.Driver -Dspring.datasource.hikari.jdbcUrl=jdbc:mariadb://localhost:3306/fineract_tenants -Dspring.datasource.hikari.username=root -Dspring.datasource.hikari.password=mysql -Dfineract.tenant.host=localhost -Dfineract.tenant.port=3306 -Dfineract.tenant.username=root -Dfineract.tenant.password=mysql' - } - if (project.hasProperty('instanceMode')) { - if ('readOnly'.equalsIgnoreCase(instanceMode)) { - jvmArgs += ' -Dfineract.mode.write-enabled=false -Dfineract.mode.batch-enabled=false' - } else if ('batchOnly'.equalsIgnoreCase(instanceMode)) { - jvmArgs += ' -Dfineract.mode.write-enabled=false -Dfineract.mode.read-enabled=false' - } else { - jvmArgs += ' -Dfineract.mode.read-enabled=false -Dfineract.mode.batch-enabled=false' - } - } else { - jvmArgs += ' -Dfineract.mode.read-enabled=false -Dfineract.mode.batch-enabled=false' - } - - property 'cargo.start.jvmargs', jvmArgs - property 'cargo.tomcat.connector.keystoreFile', file("$rootDir/fineract-provider/src/main/resources/keystore.jks") - property 'cargo.tomcat.connector.keystorePass', 'openmf' - property 'cargo.tomcat.httpSecure', true - property 'cargo.tomcat.connector.sslProtocol', 'TLS' - property 'cargo.tomcat.connector.clientAuth', false - property 'cargo.protocol', 'https' - property 'cargo.servlet.port', 8443 - } - } -} - -cargoRunLocal.dependsOn ':fineract-war:war' -cargoStartLocal.dependsOn ':fineract-war:war' -cargoStartLocal.mustRunAfter 'testClasses' - -test { - dependsOn (cargoStartLocal) - finalizedBy cargoStopLocal -} - -// NOTE: Gradle suggested these dependencies -compileTestJava.dependsOn(':fineract-provider:generateGitProperties', ':fineract-provider:processResources', ':fineract-provider:resolve') -spotbugsTest.dependsOn(':fineract-provider:generateGitProperties', ':fineract-provider:processResources', ':fineract-provider:resolve') diff --git a/instancemode-tests/dependencies.gradle b/instancemode-tests/dependencies.gradle deleted file mode 100644 index 7cff69752..000000000 --- a/instancemode-tests/dependencies.gradle +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -dependencies { - // testCompile dependencies are ONLY used in src/test, not src/main. - // Do NOT repeat dependencies which are ALREADY in implementation or runtimeOnly! - // - tomcat 'org.apache.tomcat:tomcat:9.0.69@zip' - testImplementation( files("$rootDir/fineract-provider/build/classes/java/main/"), - project(path: ':fineract-provider', configuration: 'runtimeElements'), - 'io.cucumber:cucumber-spring', - 'com.intuit.karate:karate-junit5', - // 'com.google.code.gson:gson', - ) - testImplementation ('org.mock-server:mockserver-junit-jupiter') { - exclude group: 'com.sun.mail', module: 'mailapi' - exclude group: 'javax.servlet', module: 'javax.servlet-api' - exclude group: 'javax.validation' - } - testImplementation ('io.rest-assured:rest-assured') { - exclude group: 'commons-logging' - exclude group: 'org.apache.sling' - exclude group: 'com.sun.xml.bind' - } - - testCompileOnly 'org.projectlombok:lombok' - testAnnotationProcessor 'org.projectlombok:lombok' -} diff --git a/instancemode-tests/src/test/java/org/apache/fineract/integrationtests/BatchInstanceModeTest.java b/instancemode-tests/src/test/java/org/apache/fineract/integrationtests/BatchInstanceModeTest.java deleted file mode 100644 index 47f044e46..000000000 --- a/instancemode-tests/src/test/java/org/apache/fineract/integrationtests/BatchInstanceModeTest.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.integrationtests; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.fail; - -import com.google.gson.Gson; -import io.restassured.RestAssured; -import io.restassured.builder.RequestSpecBuilder; -import io.restassured.builder.ResponseSpecBuilder; -import io.restassured.http.ContentType; -import io.restassured.path.json.JsonPath; -import io.restassured.response.Response; -import io.restassured.specification.RequestSpecification; -import io.restassured.specification.ResponseSpecification; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpStatus; -import org.apache.http.conn.HttpHostConnectException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -public class BatchInstanceModeTest { - - private ResponseSpecification responseSpec200; - private ResponseSpecification responseSpec405; - private RequestSpecification requestSpec; - - private static final String TENANT_PARAM_NAME = "tenantIdentifier"; - private static final String DEFAULT_TENANT = "default"; - private static final String TENANT_IDENTIFIER = TENANT_PARAM_NAME + '=' + DEFAULT_TENANT; - - private static final String HEALTH_URL = "/fineract-provider/actuator/health"; - private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?" + TENANT_IDENTIFIER; - private static final String JOBS_URL = "/fineract-provider/api/v1/jobs"; - private static final String OFFICES_URL = "/fineract-provider/api/v1/offices"; - - @BeforeEach - public void setup() throws InterruptedException { - initializeRestAssured(); - - this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); - - // Login with basic authentication - awaitSpringBootActuatorHealthyUp(); - this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); - this.responseSpec200 = new ResponseSpecBuilder().expectStatusCode(200).build(); - this.responseSpec405 = new ResponseSpecBuilder().expectStatusCode(405).build(); - } - - @Test - public void acceptWriteRequestWhenIsWriteOnly() { - loginIntoServerAndGetBase64EncodedAuthenticationKey(requestSpec, responseSpec200); - } - - @Test - public void acceptReadRequestWhenIsWriteOnly() { - this.requestSpec.header("Authorization", - "Basic " + loginIntoServerAndGetBase64EncodedAuthenticationKey(requestSpec, responseSpec200)); - final int statusCode = getHeadOffice(requestSpec, responseSpec200); - assertEquals(HttpStatus.SC_OK, statusCode); - } - - @Test - public void rejectBatchJobRequestWhenIsWriteOnly() { - this.requestSpec.header("Authorization", - "Basic " + loginIntoServerAndGetBase64EncodedAuthenticationKey(requestSpec, responseSpec200)); - - final String GET_ALL_SCHEDULER_JOBS_URL = JOBS_URL + "?" + TENANT_IDENTIFIER; - List<Map<String, Object>> allSchedulerJobsData = getAllSchedulerJobs(requestSpec, responseSpec200, GET_ALL_SCHEDULER_JOBS_URL); - assertNotNull(allSchedulerJobsData); - final String jobName = "Add Accrual Transactions"; - final int jobId = this.getSchedulerJobIdByName(allSchedulerJobsData, jobName); - final int statusCode = runSchedulerJob(requestSpec, responseSpec405, jobId); - assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, statusCode); - } - - private static void initializeRestAssured() { - RestAssured.baseURI = "https://localhost"; - RestAssured.port = 8443; - RestAssured.keyStore("src/main/resources/keystore.jks", "openmf"); - RestAssured.useRelaxedHTTPSValidation(); - } - - private static void awaitSpringBootActuatorHealthyUp() throws InterruptedException { - int attempt = 0; - final int max_attempts = 10; - Response response = null; - - do { - try { - response = RestAssured.get(HEALTH_URL); - - if (response.statusCode() == 200) { - return; - } - - Thread.sleep(3000); - } catch (Exception e) { - Thread.sleep(3000); - } - } while (attempt < max_attempts); - - fail(HEALTH_URL + " returned " + response.prettyPrint()); - } - - private static String loginIntoServerAndGetBase64EncodedAuthenticationKey(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec) { - try { - String json = given().spec(requestSpec).body("{\"username\":\"mifos\", \"password\":\"password\"}").expect().spec(responseSpec) - .log().ifError().when().post(LOGIN_URL).asString(); - assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false)); - String key = JsonPath.with(json).get("base64EncodedAuthenticationKey"); - assertThat("Failed to obtain key: " + json, StringUtils.isBlank(key), is(false)); - return key; - } catch (final Exception e) { - if (e instanceof HttpHostConnectException) { - final HttpHostConnectException hh = (HttpHostConnectException) e; - fail("Failed to connect to fineract platform:" + hh.getMessage()); - } - - throw new RuntimeException(e); - } - } - - private int getHeadOffice(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - return performServerGet(requestSpec, responseSpec, OFFICES_URL + "/1?" + TENANT_IDENTIFIER); - } - - private List<Map<String, Object>> getAllSchedulerJobs(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String getURL) { - List<Map<String, Object>> response = performServerGet(requestSpec, responseSpec, getURL, ""); - assertNotNull(response); - return response; - } - - private int getSchedulerJobIdByName(List<Map<String, Object>> allSchedulerJobsData, String jobName) { - for (Integer jobIndex = 0; jobIndex < allSchedulerJobsData.size(); jobIndex++) { - if (allSchedulerJobsData.get(jobIndex).get("displayName").equals(jobName)) { - return (Integer) allSchedulerJobsData.get(jobIndex).get("jobId"); - } - } - throw new IllegalArgumentException( - "No such named Job (see org.apache.fineract.infrastructure.jobs.service.JobName enum):" + jobName); - } - - private static String runSchedulerJobAsJSON() { - final Map<String, String> map = new HashMap<>(); - String runSchedulerJob = new Gson().toJson(map); - return runSchedulerJob; - } - - private int runSchedulerJob(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final int jobId) { - final String RUN_SCHEDULER_JOB_URL = JOBS_URL + "/" + jobId + "?command=executeJob&" + TENANT_IDENTIFIER; - return performServerPost(requestSpec, responseSpec, RUN_SCHEDULER_JOB_URL, runSchedulerJobAsJSON()); - } - - @SuppressWarnings("unchecked") - private static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String getURL, final String jsonAttributeToGetBack) { - final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString(); - if (jsonAttributeToGetBack == null) { - return (T) json; - } - return (T) JsonPath.from(json).get(jsonAttributeToGetBack); - } - - private int performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String getURL) { - return given().spec(requestSpec).expect().spec(responseSpec).when().get(getURL).getStatusCode(); - } - - private int performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String postURL, - final String jsonBodyToSend) { - return given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).when().post(postURL).getStatusCode(); - } -} diff --git a/instancemode-tests/src/test/resources/cucumber.properties b/instancemode-tests/src/test/resources/cucumber.properties deleted file mode 100644 index a745f7440..000000000 --- a/instancemode-tests/src/test/resources/cucumber.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -cucumber.publish.quiet=true -cucumber.glue=org.apache.fineract diff --git a/instancemode-tests/src/test/resources/junit-platform.properties b/instancemode-tests/src/test/resources/junit-platform.properties deleted file mode 100644 index 781baf184..000000000 --- a/instancemode-tests/src/test/resources/junit-platform.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -junit.jupiter.testclass.order.default = org.junit.jupiter.api.ClassOrderer$OrderAnnotation diff --git a/instancemode-tests/src/test/resources/michael.vorburger-crepes.jpg b/instancemode-tests/src/test/resources/michael.vorburger-crepes.jpg deleted file mode 100644 index c5f4bb6c5..000000000 Binary files a/instancemode-tests/src/test/resources/michael.vorburger-crepes.jpg and /dev/null differ
