Search in sources :

Example 6 with AccessAnnotationChecker

use of com.vaadin.flow.server.auth.AccessAnnotationChecker in project flow by vaadin.

the class EndpointAccessCheckerTest method before.

@Before
public void before() {
    checker = new EndpointAccessChecker(new AccessAnnotationChecker());
    requestMock = mock(HttpServletRequest.class);
    when(requestMock.getUserPrincipal()).thenReturn(mock(Principal.class));
    when(requestMock.getHeader("X-CSRF-Token")).thenReturn("Vaadin Fusion");
    when(requestMock.getCookies()).thenReturn(new Cookie[] { new Cookie(ApplicationConstants.CSRF_TOKEN, "Vaadin Fusion") });
    when(requestMock.isUserInRole("ROLE_USER")).thenReturn(true);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Cookie(javax.servlet.http.Cookie) AccessAnnotationChecker(com.vaadin.flow.server.auth.AccessAnnotationChecker) Principal(java.security.Principal) Before(org.junit.Before)

Aggregations

AccessAnnotationChecker (com.vaadin.flow.server.auth.AccessAnnotationChecker)6 EndpointAccessChecker (dev.hilla.auth.EndpointAccessChecker)5 Test (org.junit.Test)5 VaadinRequest (com.vaadin.flow.server.VaadinRequest)1 Principal (java.security.Principal)1 Cookie (javax.servlet.http.Cookie)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Before (org.junit.Before)1