actix-extras icon indicating copy to clipboard operation
actix-extras copied to clipboard

Feature request: implement Default or add a constructor to Session for testing

Open kingledion opened this issue 2 years ago • 0 comments

In my project, I created a trait and implemented it for the Session struct that added some basic functionality customized to my use case (in this case, validating a user id and expiration time against the SessionStore, for authentication purposes).

I wanted to package this trait as a library to use in multiple microservices, and build unit tests for it. But I am getting stuck in that I cannot see a way to create an instance of Session for my tests. There is no constructor, the Session{...} syntax does not work due to private fields, and I can't seem to get a way to create one via an HttpRequest (which also does not appear to have a constructor) within a unit test.

I'm going to propose a PR to do this shortly, but I wanted to add an issue explaining what I was doing.

kingledion avatar Jun 10 '22 23:06 kingledion