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

Sample tests will help new users effectively use authboss #40

Closed
kulpreet opened this issue Jan 30, 2020 · 1 comment
Closed

Sample tests will help new users effectively use authboss #40

kulpreet opened this issue Jan 30, 2020 · 1 comment

Comments

@kulpreet
Copy link

It is kind of hard for new Go programmers to figure out how to write tests.

In the case of authboss, it is not really clear how one could mock authboss for their tests.

If you need help, I can put some time into it. But would be nice to receive some suggestions how you best envision users of authboss to mock authboss for their tests.

@aarondl
Copy link
Member

aarondl commented Jan 30, 2020

Hi @kulpreet. This library isn't intended for new Go programmers. It's a complicated package because what it does is fairly complicated (abstract the entire HTTP stack to be able to generically provide authentication flows).

As stated elsewhere my ultimate goal with this project is simply to use it for myself. It's open source because it may help others. Personally it's a non-goal to attract a gigantic user base and as such I've left it to other contributors to work on the "making it accessible" part of the project.

As for mocking authboss for testing, it doesn't need mocking. Authboss only deals with the http stack that you define (its interfaces like Renderer, Redirector, etc. etc). So it would be those that you would want to mock. There's also a set of these mock objects already available here: https://godoc.org/github.com/volatiletech/authboss/mocks

It's also important to realize that for a run-of-the-mill endpoint in an API or a HTML web application you're not going to use authboss save for its ability to look up a user in the context using authboss.CurrentUser - and this can be mocked simply by shoving values into the context (See CTXKeyUser https://godoc.org/github.com/volatiletech/authboss#pkg-constants).

@aarondl aarondl closed this as completed Jan 30, 2020
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