Skip to content

Commit 72cf50d

Browse files
authored
Enabled local response templating by default in standalone (wiremock#2386)
1 parent 74e0bf2 commit 72cf50d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/main/java/com/github/tomakehurst/wiremock/standalone/CommandLineOptions.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ public class CommandLineOptions implements Options {
9292
private static final String ROOT_DIR = "root-dir";
9393
private static final String CONTAINER_THREADS = "container-threads";
9494
private static final String GLOBAL_RESPONSE_TEMPLATING = "global-response-templating";
95-
public static final String FILENAME_TEMPLATE = "filename-template";
9695
private static final String LOCAL_RESPONSE_TEMPLATING = "local-response-templating";
96+
private static final String DISABLE_RESPONSE_TEMPLATING = "disable-response-templating";
97+
public static final String FILENAME_TEMPLATE = "filename-template";
9798
private static final String ADMIN_API_BASIC_AUTH = "admin-api-basic-auth";
9899
private static final String ADMIN_API_REQUIRE_HTTPS = "admin-api-require-https";
99100
private static final String ASYNCHRONOUS_RESPONSE_ENABLED = "async-response-enabled";
@@ -265,6 +266,8 @@ public CommandLineOptions(String... args) {
265266
optionParser.accepts(FILENAME_TEMPLATE, "Add filename template").withRequiredArg();
266267
optionParser.accepts(
267268
LOCAL_RESPONSE_TEMPLATING, "Preprocess selected responses with Handlebars templates");
269+
optionParser.accepts(
270+
DISABLE_RESPONSE_TEMPLATING, "Disable processing of responses with Handlebars templates");
268271
optionParser
269272
.accepts(
270273
ADMIN_API_BASIC_AUTH,
@@ -926,7 +929,7 @@ public int proxyTimeout() {
926929

927930
@Override
928931
public boolean getResponseTemplatingEnabled() {
929-
return optionSet.has(GLOBAL_RESPONSE_TEMPLATING) || optionSet.has(LOCAL_RESPONSE_TEMPLATING);
932+
return !optionSet.has(DISABLE_RESPONSE_TEMPLATING);
930933
}
931934

932935
@Override

src/test/java/com/github/tomakehurst/wiremock/standalone/CommandLineOptionsTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,18 @@ public void enablesGlobalResponseTemplating() {
418418
}
419419

420420
@Test
421-
public void enablesLocalResponseTemplating() {
422-
CommandLineOptions options = new CommandLineOptions("--local-response-templating");
421+
public void enablesLocalResponseTemplatingByDefault() {
422+
CommandLineOptions options = new CommandLineOptions();
423423
assertThat(options.getResponseTemplatingEnabled(), is(true));
424424
assertThat(options.getResponseTemplatingGlobal(), is(false));
425425
}
426426

427+
@Test
428+
public void canDisableTemplating() {
429+
CommandLineOptions options = new CommandLineOptions("--disable-response-templating");
430+
assertThat(options.getResponseTemplatingEnabled(), is(false));
431+
}
432+
427433
@Test
428434
public void configuresMaxTemplateCacheEntriesIfSpecified() {
429435
CommandLineOptions options =

0 commit comments

Comments
 (0)