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

Multi-factor authentication: The second factor can be skipped #143

Open
SentretC opened this issue Aug 21, 2023 · 0 comments
Open

Multi-factor authentication: The second factor can be skipped #143

SentretC opened this issue Aug 21, 2023 · 0 comments

Comments

@SentretC
Copy link

Simply remove the second factor part from mfaWhenWrongCodeThenRedirects and the test fails:

@Test
void mfaWhenSecondFactorSkippedThenRedirects() throws Exception {
	// @formatter:off
	MvcResult result = this.mockMvc.perform(formLogin()
					.user("user@example.com")
					.password("password"))
			.andExpect(redirectedUrl("/second-factor"))
			.andReturn();

	HttpSession session = result.getRequest().getSession();

	// skip the second factor

	this.mockMvc.perform(post("/third-factor")
					.session((MockHttpSession) session)
					.param("answer", "smith")
					.with(csrf()))
			.andExpect(redirectedUrl("/login?error"));
	// @formatter:on
}

Test output:

Redirected URL expected:</login?error> but was:</>
Expected :/login?error
Actual   :/
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