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

Passing auth in integration tests #46

Open
chrisgundersen opened this issue Jul 31, 2018 · 2 comments
Open

Passing auth in integration tests #46

chrisgundersen opened this issue Jul 31, 2018 · 2 comments

Comments

@chrisgundersen
Copy link
Contributor

I'm playing around and am curious how one would pass creds or a token in an integration test? Would it be more appropriate to do so in a test that invokes a authorized controller and goes through the traditional request pipeline? Is there a way I can pass along a user's context when testing specific commands and/or queries outside of that pipeline?

@adamhathcock
Copy link
Collaborator

You want to test invoking a Controller? I'm not sure what you mean.

One of the reasons to have a Controller that only calls MediatR and nothing else is to avoid having to worry about having ASP.NET Core in your testing. Testing your own code versus ASP.NET Core is more desirable.

If you're trying to assert that your configuration of ASP.NET Core is correct there is probably better ways to do that.

@chrisgundersen
Copy link
Contributor Author

I'm more trying to assert that the CurrentUserAccessor middleware is working as expected, so I'd like to be able to make a request and provide a user context to ensure that I'm able to get the correct information from the user issuing the command. Does that make sense?

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

2 participants