Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not pass MVC tests with MockUser #1

Open
olegsinavski opened this issue Mar 25, 2015 · 0 comments
Open

Can not pass MVC tests with MockUser #1

olegsinavski opened this issue Mar 25, 2015 · 0 comments

Comments

@olegsinavski
Copy link

Hello,

I wanted to try new security MVC-based tests with WithMockUser annotation in my projects, but I couldn't make it work by following the examples from this repo (and the corresponding blog post). To disentangle my mistakes from spring security 4.0 code I tried to clone and run tests in this repo directly (using maven, gradle, using different versions of spring-security 4 etc) but I see kind of the same errors as I see in my project (but its hard to tell for sure).

Looks like that tests that involve MockMvcBuilders and WithMockUser do not bypass security. According to my understanding "WithMockUser" is supposed to put the Principal into the app so that login page is not even triggered. Is this correct?

For example, MockMvcHtmlUnitCreateMessageTest fails with
ElementNotFoundException at the line:
HtmlForm form = createMsgFormPage.getHtmlElementById("messageForm");

I see suspicious log messages during the tests
12:03:42.785 [main] DEBUG o.s.s.w.a.ExceptionTranslationFilter - Access is denied (user is anonymous); redirecting to authentication entry point
org.springframework.security.access.AccessDeniedException: Access is denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant