[TESTS] coverage for SignInOAuthCallback
(cherry picked from commitf8e1619b99
) (cherry picked from commit46d8bc9bdf
) (cherry picked from commite0c7b7055f
) (cherry picked from commitfaab747f8e
) (cherry picked from commit46acb6a9a7
) (cherry picked from commit22d964e744
) (cherry picked from commit4c8a6031ac
)
This commit is contained in:
parent
3b39962033
commit
032e8c7a9a
2 changed files with 60 additions and 0 deletions
|
@ -39,6 +39,8 @@ import (
|
|||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/markbates/goth"
|
||||
"github.com/markbates/goth/gothic"
|
||||
goth_gitlab "github.com/markbates/goth/providers/gitlab"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/xeipuuv/gojsonschema"
|
||||
|
@ -232,6 +234,14 @@ func getUserToken(t testing.TB, userName string, scope ...auth.AccessTokenScope)
|
|||
return getTokenForLoggedInUser(t, loginUser(t, userName), scope...)
|
||||
}
|
||||
|
||||
func mockCompleteUserAuth(mock func(res http.ResponseWriter, req *http.Request) (goth.User, error)) func() {
|
||||
old := gothic.CompleteUserAuth
|
||||
gothic.CompleteUserAuth = mock
|
||||
return func() {
|
||||
gothic.CompleteUserAuth = old
|
||||
}
|
||||
}
|
||||
|
||||
func addAuthSource(t *testing.T, payload map[string]string) *auth.Source {
|
||||
session := loginUser(t, "user1")
|
||||
payload["_csrf"] = GetCSRF(t, session, "/admin/auths/new")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue