Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(TenantConfigExternalization): Fix retrieval of boolean env variable #132

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rootProject.name=configuration
profile=dev
version=2.0.48
version=2.0.49

# Build properties
node_version=12.13.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ private Object getEnv(String path) {
return envVariable;
}

if (isBoolean(envVariable)) {
return Boolean.valueOf(envVariable);
}

if (!isNumber(envVariable)) {
return envVariable;
}
Expand All @@ -145,4 +149,7 @@ private boolean isNumber(String envVariable) {
return envVariable.matches("-?\\d+(\\.\\d+)?");
}

private static boolean isBoolean(String envVariable) {
return envVariable.toLowerCase().matches("true|false");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ public void overrideIntegerNumbers() {
assertEquals(123, actual);
}

@Test
public void overrideBoolean() {
String value = "false";
environmentVariables.set("XM_integrateWith3rdParty", value);
Object actual = overrideParameterAndReturnResult(asList("integrateWith3rdParty"));
assertEquals(false, actual);
}

@Test
public void overrideLongNumbers() {
String value = "" + 1236484563242346716L;
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/tenant-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ valueForReplace: VALUE_FOR_REPLACE

clientCabinetBaseUrl: someclientCabinetBaseUrlValue

integrateWith3rdParty: true

payment:
liqpay:
public_key: VVVVVVVVVALUE
Expand Down