summaryrefslogtreecommitdiff
path: root/internal/api/client/auth/auth_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-06-11 10:39:39 +0200
committerLibravatar GitHub <noreply@github.com>2022-06-11 10:39:39 +0200
commit694a49058951de31cca4ea061e2c08d44e712612 (patch)
tree8509cb95f41faaf15d4352707617bff17300978d /internal/api/client/auth/auth_test.go
parent[bugfix] Make accounts media_only query also work with pg (#643) (diff)
downloadgotosocial-694a49058951de31cca4ea061e2c08d44e712612.tar.xz
[feature] Add `created_at` and `error_description` to `/oauth/token` endpoint (#645)
* start fiddling about with oauth server * start returning more helpful errors from oauth * test helpful(ish) token errors * add missing license header
Diffstat (limited to 'internal/api/client/auth/auth_test.go')
-rw-r--r--internal/api/client/auth/auth_test.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/api/client/auth/auth_test.go b/internal/api/client/auth/auth_test.go
index f222f714f..6a7c6ab99 100644
--- a/internal/api/client/auth/auth_test.go
+++ b/internal/api/client/auth/auth_test.go
@@ -19,6 +19,7 @@
package auth_test
import (
+ "bytes"
"context"
"fmt"
"net/http/httptest"
@@ -99,7 +100,7 @@ func (suite *AuthStandardTestSuite) SetupTest() {
if err != nil {
panic(err)
}
- suite.authModule = auth.New(suite.db, suite.oauthServer, suite.idp, suite.processor).(*auth.Module)
+ suite.authModule = auth.New(suite.db, suite.idp, suite.processor).(*auth.Module)
testrig.StandardDBSetup(suite.db, suite.testAccounts)
}
@@ -107,7 +108,7 @@ func (suite *AuthStandardTestSuite) TearDownTest() {
testrig.StandardDBTeardown(suite.db)
}
-func (suite *AuthStandardTestSuite) newContext(requestMethod string, requestPath string) (*gin.Context, *httptest.ResponseRecorder) {
+func (suite *AuthStandardTestSuite) newContext(requestMethod string, requestPath string, requestBody []byte, bodyContentType string) (*gin.Context, *httptest.ResponseRecorder) {
// create the recorder and gin test context
recorder := httptest.NewRecorder()
ctx, engine := gin.CreateTestContext(recorder)
@@ -120,9 +121,14 @@ func (suite *AuthStandardTestSuite) newContext(requestMethod string, requestPath
host := config.GetHost()
baseURI := fmt.Sprintf("%s://%s", protocol, host)
requestURI := fmt.Sprintf("%s/%s", baseURI, requestPath)
- ctx.Request = httptest.NewRequest(requestMethod, requestURI, nil) // the endpoint we're hitting
+
+ ctx.Request = httptest.NewRequest(requestMethod, requestURI, bytes.NewReader(requestBody)) // the endpoint we're hitting
ctx.Request.Header.Set("accept", "text/html")
+ if bodyContentType != "" {
+ ctx.Request.Header.Set("Content-Type", bodyContentType)
+ }
+
// trigger the session middleware on the context
store := memstore.NewStore(make([]byte, 32), make([]byte, 32))
store.Options(router.SessionOptions())