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

Enable local response templating by default in standalone #2386

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ public class CommandLineOptions implements Options {
private static final String ROOT_DIR = "root-dir";
private static final String CONTAINER_THREADS = "container-threads";
private static final String GLOBAL_RESPONSE_TEMPLATING = "global-response-templating";
public static final String FILENAME_TEMPLATE = "filename-template";
private static final String LOCAL_RESPONSE_TEMPLATING = "local-response-templating";
private static final String DISABLE_RESPONSE_TEMPLATING = "disable-response-templating";
public static final String FILENAME_TEMPLATE = "filename-template";
private static final String ADMIN_API_BASIC_AUTH = "admin-api-basic-auth";
private static final String ADMIN_API_REQUIRE_HTTPS = "admin-api-require-https";
private static final String ASYNCHRONOUS_RESPONSE_ENABLED = "async-response-enabled";
Expand Down Expand Up @@ -265,6 +266,8 @@ public CommandLineOptions(String... args) {
optionParser.accepts(FILENAME_TEMPLATE, "Add filename template").withRequiredArg();
optionParser.accepts(
LOCAL_RESPONSE_TEMPLATING, "Preprocess selected responses with Handlebars templates");
optionParser.accepts(
DISABLE_RESPONSE_TEMPLATING, "Disable processing of responses with Handlebars templates");
optionParser
.accepts(
ADMIN_API_BASIC_AUTH,
Expand Down Expand Up @@ -926,7 +929,7 @@ public int proxyTimeout() {

@Override
public boolean getResponseTemplatingEnabled() {
return optionSet.has(GLOBAL_RESPONSE_TEMPLATING) || optionSet.has(LOCAL_RESPONSE_TEMPLATING);
return !optionSet.has(DISABLE_RESPONSE_TEMPLATING);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,18 @@ public void enablesGlobalResponseTemplating() {
}

@Test
public void enablesLocalResponseTemplating() {
CommandLineOptions options = new CommandLineOptions("--local-response-templating");
public void enablesLocalResponseTemplatingByDefault() {
CommandLineOptions options = new CommandLineOptions();
assertThat(options.getResponseTemplatingEnabled(), is(true));
assertThat(options.getResponseTemplatingGlobal(), is(false));
}

@Test
public void canDisableTemplating() {
CommandLineOptions options = new CommandLineOptions("--disable-response-templating");
assertThat(options.getResponseTemplatingEnabled(), is(false));
}

@Test
public void configuresMaxTemplateCacheEntriesIfSpecified() {
CommandLineOptions options =
Expand Down
Loading