-
Notifications
You must be signed in to change notification settings - Fork 18
feat: Tenant API & JWT authentication #7
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
Conversation
package api_test | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/google/uuid" | ||
"github.com/hookdeck/EventKit/internal/destination" | ||
"github.com/hookdeck/EventKit/internal/services/api" | ||
"github.com/hookdeck/EventKit/internal/tenant" | ||
"github.com/hookdeck/EventKit/internal/util/testutil" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRouterWithAPIKey(t *testing.T) { | ||
t.Parallel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you go over this test suite (this file)? I'm trying to test the router with a strong emphasis on the auth mechanism. Some questions:
- Can you follow the thought process / auth mechanism logic here? Is this the right approach? Any case I'm missing here?
- Do you feel this is too "auth-focused" and should be moved to
auth_middleware_test.go
instead? In that case, we can set up a smaller router vs this router with tenant & destination routes. Personally I'm fine with this and continue moving forward and we can consider that refactor after but curious if you share the sentiment.
Port int | ||
Hostname string | ||
APIKey string | ||
JWTSecret string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we would need to add a JWT_SECRET
env here, correct?
# Conflicts: # internal/config/config.go # internal/services/api/api.go # internal/services/api/auth_middleware.go # internal/services/api/router.go # internal/util/testutil/testutil.go
This is a fairly loaded PR. Here are everything it does:
Added tests for a lot of the new code here. Just a sidenote, I really do enjoy writing tests in Go and the workflow so far. Caught a bug in the auth middleware from writing a more semi-comprehensive test suite.