use of jakarta.ws.rs.core.Form in project minijax by minijax.
the class ResetPasswordTest method testResetPasswordTooShort.
@Test
void testResetPasswordTooShort() throws IOException {
final User user = new User();
user.setName("Example 3");
user.setEmail("reset-3@example.com");
user.setRoles("user");
String code = null;
try (MinijaxRequestContext ctx = createRequestContext()) {
ctx.getResource(Dao.class).create(user);
code = ctx.getResource(Security.class).forgotPassword(user);
}
final Form form = new Form();
form.param("newPassword", "foo");
form.param("confirmNewPassword", "foo");
final Response r = target("/resetpassword/" + code).request().post(Entity.form(form));
assertNotNull(r);
assertEquals(400, r.getStatus());
assertTrue(r.getCookies().isEmpty());
}
use of jakarta.ws.rs.core.Form in project minijax by minijax.
the class ResetPasswordTest method testResetPasswordMismatch.
@Test
void testResetPasswordMismatch() throws IOException {
final User user = new User();
user.setName("Example 2");
user.setEmail("reset-2@example.com");
user.setRoles("user");
String code = null;
try (MinijaxRequestContext ctx = createRequestContext()) {
ctx.getResource(Dao.class).create(user);
code = ctx.getResource(Security.class).forgotPassword(user);
}
final Form form = new Form();
form.param("newPassword", "my-new-password");
form.param("confirmNewPassword", "different-password");
final Response r = target("/resetpassword/" + code).request().post(Entity.form(form));
assertNotNull(r);
assertEquals(400, r.getStatus());
assertTrue(r.getCookies().isEmpty());
}
use of jakarta.ws.rs.core.Form in project minijax by minijax.
the class ResetPasswordTest method testResetPasswordNotFound.
@Test
void testResetPasswordNotFound() throws IOException {
final String code = "does-not-exist";
final Form form = new Form();
form.param("newPassword", "my-new-password");
form.param("confirmNewPassword", "my-new-password");
final Response r = target("/resetpassword/" + code).request().post(Entity.form(form));
assertNotNull(r);
assertEquals(404, r.getStatus());
assertTrue(r.getCookies().isEmpty());
}
use of jakarta.ws.rs.core.Form in project minijax by minijax.
the class CsrfFilterTest method testPrivateFormWithoutUser.
@Test
void testPrivateFormWithoutUser() {
final Form form = new Form();
final Response r = target("/private_form").request().post(Entity.form(form));
assertNotNull(r);
assertEquals(401, r.getStatus());
}
use of jakarta.ws.rs.core.Form in project minijax by minijax.
the class CsrfFilterTest method testPrivateFormWithoutCsrf.
@Test
void testPrivateFormWithoutCsrf() {
final Form form = new Form();
final Response r = target("/private_form").request().cookie(cookie).post(Entity.form(form));
assertNotNull(r);
assertEquals(400, r.getStatus());
}
Aggregations