Skip to content

"Invalid session" exception when clicking the logout button of the app during Browserless testing #115

Closed

Description

@RichMacDonald

I am encountering an "invalid session" exception when clicking the logout button of my app during Browserless testing.

Setup is as suggested:

app = SpringBrowserlessApplicationContext.createSecured(appContext, MainLayout.class);
user = secureApp.newUser("user", "password", "USER");
window = newUser.newWindow();

This bypasses the Login page. I run some tests then click the logout button. That triggers the logout code:

SecurityContextLogoutHandler logoutHandler = new SecurityContextLogoutHandler();
	logoutHandler.logout(
			VaadinServletRequest.getCurrent().getHttpServletRequest(),
			VaadinServletResponse.getCurrent().getHttpServletResponse(),
			null);

This code invalidates the HttpSession. It then calls:

this.securityContextRepository.saveContext(emptyContext, request, response);

This is a HttpSessionSecurityContextRepository. That method has a null responseWrapper and calls saveContextInHttpSession, which calls removeContextFromSession. That method calls session.setAttribute(this.springSecurityContextKey, context), which fails because we just invalidated the HttpSession.

So I can step through to the error, but I don't know why the error.

SpringSecurity is not my strength, so apologies. I don't even know if I am dealing with a Spring test or a Vaadin test issue.

I am not using @WithMockUser. The @Configuration class includes @EnableWebSecurity.

I am not seeing any logout tests in the Browserless unit test suite.

Note: I believe I can try-catch-ignore the Exception and continue without problems.

Rich MacDonald

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions