Here are the examples of the java api play.api.test.CSRFTokenHelper.addCSRFToken() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
16
Source : UnitTest.java
with Creative Commons Zero v1.0 Universal
from playframework
with Creative Commons Zero v1.0 Universal
from playframework
@Test
public void checkTemplate() {
Http.RequestBuilder request = CSRFTokenHelper.addCSRFToken(Helpers.fakeRequest("GET", "/"));
Content html = views.html.index.render(request.build());
replacedertThat(html.contentType()).isEqualTo("text/html");
replacedertThat(contentreplacedtring(html)).contains("Add Person");
}
16
Source : IntegrationTest.java
with Creative Commons Zero v1.0 Universal
from playframework
with Creative Commons Zero v1.0 Universal
from playframework
@Test
public void testInServerThroughApp() throws Exception {
// Tests using the internal application available in the server.
Http.RequestBuilder request = Helpers.fakeRequest().method(GET).uri("/");
// XXX This should be play.test.CSRFTokenHelper
Http.RequestBuilder tokenRequest = CSRFTokenHelper.addCSRFToken(request);
Result result = route(app, tokenRequest);
final String body = contentreplacedtring(result);
replacedertThat(body, containsString("Add Person"));
}
10
Source : UnitTest.java
with Creative Commons Zero v1.0 Universal
from playframework
with Creative Commons Zero v1.0 Universal
from playframework
@Test
public void checkIndex() {
Http.RequestBuilder request = CSRFTokenHelper.addCSRFToken(Helpers.fakeRequest("GET", "/"));
PersonRepository repository = mock(PersonRepository.clreplaced);
FormFactory formFactory = mock(FormFactory.clreplaced);
HttpExecutionContext ec = new HttpExecutionContext(ForkJoinPool.commonPool());
final PersonController controller = new PersonController(formFactory, repository, ec);
final Result result = controller.index(request.build());
replacedertThat(result.status()).isEqualTo(OK);
}