}
@Test
public void highProfileSelfRegisterTest() throws Exception {
ServiceContext svcCtx = createServiceContext();
Element params = createParams(Pair.write("surname", "john"),
Pair.write("name", "Doe"),
Pair.write("email", "root@localhost"),
Pair.write("profile", Profile.Administrator));
Element ret = sfController.exec(params, svcCtx);
assertTrue(ret.getAttribute("surname").getValue().equals("john"));
assertTrue(ret.getAttribute("name").getValue().equals("Doe"));
assertTrue(ret.getAttribute("email").getValue().equals("root@localhost"));
assertTrue(ret.getAttribute("username").getValue().equals("root@localhost"));
// Checks that the user has the expected requested profile
// TODO: I am not sure this is the expected behaviour: allowing people to create
// even temporary account as administrator, just noticing the admin catalogue
// might be a dangerous behaviour.
final UserRepository userRepository = svcCtx.getBean(UserRepository.class);
User newUsr = userRepository.findOneByEmail("root@localhost");
assertTrue (newUsr.getProfile() == Profile.Administrator);
}