FINERACT-2081: Integration test configuration
This commit is contained in:
committed by
Arnold Gálovics
parent
a6b69ec029
commit
d502dfa437
@@ -0,0 +1,17 @@
|
|||||||
|
# Run integration tests
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
- A running Fineract instance is required
|
||||||
|
|
||||||
|
## Default configuration
|
||||||
|
- `BACKEND_PROTOCOL=https`
|
||||||
|
- `BACKEND_HOST=localhost`
|
||||||
|
- `BACKEND_PORT=8443`
|
||||||
|
- `BACKEND_USERNAME=mifos`
|
||||||
|
- `BACKEND_PASSWORD=password`
|
||||||
|
- `BACKEND_TENANT=default`
|
||||||
|
|
||||||
|
## To override default values
|
||||||
|
- To override any of the default value, just add new value with the same key as environment variable
|
||||||
|
- Example:
|
||||||
|
- `BACKEND_PROTOCOL=http`
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
public class ConfigProperties {
|
||||||
|
|
||||||
|
public static class Backend {
|
||||||
|
|
||||||
|
public static final String PROTOCOL = getValueFromEnvOrDefault("BACKEND_PROTOCOL", "https");
|
||||||
|
public static final String HOST = getValueFromEnvOrDefault("BACKEND_HOST", "localhost");
|
||||||
|
public static final Integer PORT = Integer.parseInt(getValueFromEnvOrDefault("BACKEND_PORT", "8443"));
|
||||||
|
public static final String USERNAME = getValueFromEnvOrDefault("BACKEND_USERNAME", "mifos");
|
||||||
|
public static final String PASSWORD = getValueFromEnvOrDefault("BACKEND_PASSWORD", "password");
|
||||||
|
public static final String TENANT = getValueFromEnvOrDefault("BACKEND_TENANT", "default");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getValueFromEnvOrDefault(final String key, final String defaultValue) {
|
||||||
|
return System.getenv(key) == null ? defaultValue : System.getenv(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-3
@@ -38,6 +38,7 @@ import java.util.Optional;
|
|||||||
import okhttp3.logging.HttpLoggingInterceptor.Level;
|
import okhttp3.logging.HttpLoggingInterceptor.Level;
|
||||||
import org.apache.fineract.client.util.Calls;
|
import org.apache.fineract.client.util.Calls;
|
||||||
import org.apache.fineract.client.util.FineractClient;
|
import org.apache.fineract.client.util.FineractClient;
|
||||||
|
import org.apache.fineract.integrationtests.ConfigProperties;
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
import org.junit.jupiter.api.MethodOrderer;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
@@ -62,15 +63,20 @@ public abstract class IntegrationTest {
|
|||||||
|
|
||||||
protected FineractClient fineract() {
|
protected FineractClient fineract() {
|
||||||
if (fineract == null) {
|
if (fineract == null) {
|
||||||
fineract = newFineract("mifos", "password");
|
fineract = newFineract(ConfigProperties.Backend.USERNAME, ConfigProperties.Backend.PASSWORD);
|
||||||
}
|
}
|
||||||
return fineract;
|
return fineract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildURI() {
|
||||||
|
return ConfigProperties.Backend.PROTOCOL + "://" + ConfigProperties.Backend.HOST + ":" + ConfigProperties.Backend.PORT
|
||||||
|
+ "/fineract-provider/api/";
|
||||||
|
}
|
||||||
|
|
||||||
protected FineractClient newFineract(String username, String password) {
|
protected FineractClient newFineract(String username, String password) {
|
||||||
String url = System.getProperty("fineract.it.url", "https://localhost:8443/fineract-provider/api/");
|
String url = System.getProperty("fineract.it.url", buildURI());
|
||||||
// insecure(true) should *ONLY* ever be used for https://localhost:8443, NOT in real clients!!
|
// insecure(true) should *ONLY* ever be used for https://localhost:8443, NOT in real clients!!
|
||||||
FineractClient.Builder builder = FineractClient.builder().insecure(true).baseURL(url).tenant("default")
|
FineractClient.Builder builder = FineractClient.builder().insecure(true).baseURL(url).tenant(ConfigProperties.Backend.TENANT)
|
||||||
.basicAuth(username, password).logging(Level.NONE);
|
.basicAuth(username, password).logging(Level.NONE);
|
||||||
customizeFineractClient(builder);
|
customizeFineractClient(builder);
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|||||||
+5
-4
@@ -66,6 +66,7 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
|
import org.apache.fineract.integrationtests.ConfigProperties;
|
||||||
import org.apache.http.conn.HttpHostConnectException;
|
import org.apache.http.conn.HttpHostConnectException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -79,7 +80,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
public final class Utils {
|
public final class Utils {
|
||||||
|
|
||||||
public static final String TENANT_PARAM_NAME = "tenantIdentifier";
|
public static final String TENANT_PARAM_NAME = "tenantIdentifier";
|
||||||
public static final String DEFAULT_TENANT = "default";
|
public static final String DEFAULT_TENANT = ConfigProperties.Backend.TENANT;
|
||||||
public static final String TENANT_IDENTIFIER = TENANT_PARAM_NAME + '=' + DEFAULT_TENANT;
|
public static final String TENANT_IDENTIFIER = TENANT_PARAM_NAME + '=' + DEFAULT_TENANT;
|
||||||
private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?" + TENANT_IDENTIFIER;
|
private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?" + TENANT_IDENTIFIER;
|
||||||
public static final String TENANT_TIME_ZONE = "Asia/Kolkata";
|
public static final String TENANT_TIME_ZONE = "Asia/Kolkata";
|
||||||
@@ -101,8 +102,8 @@ public final class Utils {
|
|||||||
private Utils() {}
|
private Utils() {}
|
||||||
|
|
||||||
public static void initializeRESTAssured() {
|
public static void initializeRESTAssured() {
|
||||||
RestAssured.baseURI = "https://localhost";
|
RestAssured.baseURI = ConfigProperties.Backend.PROTOCOL + "://" + ConfigProperties.Backend.HOST;
|
||||||
RestAssured.port = 8443;
|
RestAssured.port = ConfigProperties.Backend.PORT;
|
||||||
RestAssured.keyStore("src/main/resources/keystore.jks", "openmf");
|
RestAssured.keyStore("src/main/resources/keystore.jks", "openmf");
|
||||||
RestAssured.useRelaxedHTTPSValidation();
|
RestAssured.useRelaxedHTTPSValidation();
|
||||||
}
|
}
|
||||||
@@ -176,7 +177,7 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
|
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
|
||||||
return loginIntoServerAndGetBase64EncodedAuthenticationKey("mifos", "password");
|
return loginIntoServerAndGetBase64EncodedAuthenticationKey(ConfigProperties.Backend.USERNAME, ConfigProperties.Backend.PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey(String username, String password) {
|
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey(String username, String password) {
|
||||||
|
|||||||
+3
-1
@@ -22,12 +22,14 @@ import io.restassured.specification.RequestSpecification;
|
|||||||
import io.restassured.specification.ResponseSpecification;
|
import io.restassured.specification.ResponseSpecification;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.apache.fineract.integrationtests.ConfigProperties;
|
||||||
import org.apache.fineract.integrationtests.common.Utils;
|
import org.apache.fineract.integrationtests.common.Utils;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class VariableIntallmentsTransactionHelper {
|
public class VariableIntallmentsTransactionHelper {
|
||||||
|
|
||||||
private static final String URL = "https://localhost:8443/fineract-provider/api/v1/loans/";
|
private static final String URL = ConfigProperties.Backend.PROTOCOL + "://" + ConfigProperties.Backend.HOST + ":"
|
||||||
|
+ ConfigProperties.Backend.PORT + "/fineract-provider/api/v1/loans/";
|
||||||
|
|
||||||
private final RequestSpecification requestSpec;
|
private final RequestSpecification requestSpec;
|
||||||
private final ResponseSpecification responseSpec;
|
private final ResponseSpecification responseSpec;
|
||||||
|
|||||||
Reference in New Issue
Block a user