@Test
public void automaticallyEnableRealmWhenCapabilityCreated()
throws Exception
{
// check that realm is added
Security security = serverConfiguration().security();
assertThat(security.settings().getRealms(), not(hasItem(RUTAUTH_REALM)));
configureRemoteHeader("REMOTE_USER");
assertThat(security.refresh().settings().getRealms(), hasItem(RUTAUTH_REALM));
// check that we do not add the realm once more when we update
List<String> realmsBeforeUpdate = security.refresh().settings().getRealms();
configureRemoteHeader("REMOTE_AUTH");
assertThat(
security.refresh().settings().getRealms(),
containsInAnyOrder(realmsBeforeUpdate.toArray(new String[realmsBeforeUpdate.size()]))
);
}