@AutoConfigureMockMvc has a secure attribute that's true by default. It is possible for the user to set that to false in which case security should not apply.
It is currently implemented using an @Import that is conditional on the property. This makes that a very unusual construct for importing auto-configurations. The side effect is that if you exclude the security auto-configuration in your app (via exclude on @SpringBootApplication) that exclude is ignored, even if #12586 is implemented.