-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handling of form requests is now configurable
- Loading branch information
Willi Schönborn
committed
Nov 10, 2017
1 parent
df5855c
commit 5d69f8d
Showing
6 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
logbook-servlet/src/main/java/org/zalando/logbook/servlet/FormRequestMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.zalando.logbook.servlet; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import static java.util.Locale.ROOT; | ||
|
||
enum FormRequestMode { | ||
|
||
BODY, PARAMETER, OFF; | ||
|
||
static FormRequestMode fromProperties() { | ||
@Nullable final String property = System.getProperty("logbook.servlet.form-request"); | ||
|
||
if (property == null) { | ||
return BODY; | ||
} | ||
|
||
return FormRequestMode.valueOf(property.toUpperCase(ROOT)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
logbook-servlet/src/test/java/org/zalando/logbook/servlet/junit/RestoreSystemProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.zalando.logbook.servlet.junit; | ||
|
||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@ExtendWith(SystemPropertiesExtension.class) | ||
public @interface RestoreSystemProperties { | ||
} |
27 changes: 27 additions & 0 deletions
27
...ok-servlet/src/test/java/org/zalando/logbook/servlet/junit/SystemPropertiesExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.zalando.logbook.servlet.junit; | ||
|
||
import org.junit.jupiter.api.extension.AfterEachCallback; | ||
import org.junit.jupiter.api.extension.BeforeEachCallback; | ||
import org.junit.jupiter.api.extension.Extension; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
|
||
import java.util.Properties; | ||
|
||
public final class SystemPropertiesExtension | ||
implements Extension, BeforeEachCallback, AfterEachCallback { | ||
|
||
private final Properties original = new Properties(); | ||
|
||
@Override | ||
public void beforeEach(final ExtensionContext context) throws Exception { | ||
original.putAll(System.getProperties()); | ||
} | ||
|
||
@Override | ||
public void afterEach(final ExtensionContext context) throws Exception { | ||
final Properties properties = System.getProperties(); | ||
properties.clear(); | ||
properties.putAll(original); | ||
} | ||
|
||
} |