HttpsRedirect plugin (previously known as 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 plugin with the default configuration.
Applying this plugin changes how testing works. After applying this plugin, 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 plugin and add a
addHeader(HttpHeaders.XForwardedProto, "https") header to the request.
Do not install the plugin 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 plugin is installed and other things that you are not doing in tests.
I get an infinite redirect when using this plugin
Have you installed the
XForwardedHeaderSupport or the
ForwardedHeaderSupport plugin? Check this FAQ entry for more details.