This feature will make all the affected HTTP calls perform a redirect to its HTTPS counterpart before processing the call.
By default the redirection is a
301 Moved Permanently, but it can be configured to be a
302 Found redirect.
The code above installs the HttpsRedirect feature with the default configuration.
Applying this feature changes how testing works. After applying this feature, each
handleRequest you perform, results in a redirection response. And probably this is not what you want in most cases, since that behaviour is already tested.
As shown in this test, you can install the
XForwardedHeaderSupport feature and add a
addHeader(HttpHeaders.XForwardedProto, "https") header to the request.
Do not install the feature when testing or uninstall it
Prevent installation in the first place:
In this case, you can also have a separate test that calls
mymodule instead of
mymoduleForTesting to verify that the
HttpsRedirect feature is installed and other things that you are not doing in tests.
I get an infinite redirect when using this feature
Have you installed the
XForwardedHeaderSupport or the
ForwardedHeaderSupport feature? Check this FAQ entry for more details.