SecurityFraction extends Security<SecurityFraction> implements Fraction<SecurityFraction> { securityDomain("jaspitest", (domain) -> { domain.cacheType(SecurityDomain.CacheType.DEFAULT); domain.jaspiAuthentication((auth) -> { auth.loginModuleStack("dummy", (stack) -> { stack.loginModule(DUMMY, (module) -> { module.code(DUMMY); module.flag(Flag.OPTIONAL); }); }); auth.authModule(DUMMY, (module) -> { module.code(DUMMY); } securityDomain("jaspitest", (domain); static SecurityFraction defaultSecurityFraction(); SecurityFraction applyDefaults();  }
@Test public void testCorrectOrderingOfAuthModules() throws Exception { SecurityFraction fraction = new SecurityFraction(); fraction.securityDomain("jaspioauth", (domain) -> { domain.jaspiAuthentication((authn) -> { authn.authModule("2-OAuth", (module) -> { }); authn.authModule("1-JWT", (module) -> { }); }); }); List<AuthModule> modules = fraction.subresources().securityDomain("jaspioauth").subresources().jaspiAuthentication().subresources().authModules(); assertThat(modules).hasSize(2); assertThat(modules.get(0).getKey()).isEqualTo("2-OAuth"); assertThat(modules.get(1).getKey()).isEqualTo("1-JWT"); List<ModelNode> result = Marshaller.marshal(fraction); PathAddress baseAddr = PathAddress.pathAddress("subsystem", "security") .append("security-domain", "jaspioauth") .append("authentication", "jaspi"); List<PathAddress> addresses = result.stream() .map(e -> PathAddress.pathAddress(e.get("address"))) .filter(e -> e.getParent().equals(baseAddr)) .collect(Collectors.toList()); assertThat( addresses.get(0).getLastElement().getValue()).isEqualTo("2-OAuth"); assertThat( addresses.get(1).getLastElement().getValue()).isEqualTo("1-JWT"); }