This commit is contained in:
colin axnér 2022-06-27 18:42:05 +09:00 committed by GitHub
commit 21181d36f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -217,8 +217,14 @@ func TestViewOauthInit(t *testing.T) {
func TestViewOauthCallback(t *testing.T) {
t.Run("success", func(t *testing.T) {
app := &MockOAuthDatastoreProvider{}
// create a compatibile configuration for testing
config := app.Config()
config.App.SingleUser = false
config.App.OpenRegistration = true
h := oauthHandler{
Config: app.Config(),
Config: config,
DB: app.DB(),
Store: app.SessionStore(),
EmailKey: []byte{0xd, 0xe, 0xc, 0xa, 0xf, 0xf, 0xb, 0xa, 0xd},
@ -251,11 +257,13 @@ func TestViewOauthCallback(t *testing.T) {
},
},
}
InitTemplates(config)
req, err := http.NewRequest("GET", "/oauth/callback", nil)
assert.NoError(t, err)
rr := httptest.NewRecorder()
err = h.viewOauthCallback(&App{cfg: app.Config(), sessionStore: app.SessionStore()}, rr, req)
err = h.viewOauthCallback(&App{cfg: config, sessionStore: app.SessionStore()}, rr, req)
assert.NoError(t, err)
assert.Equal(t, http.StatusTemporaryRedirect, rr.Code)
assert.Equal(t, http.StatusOK, rr.Code)
})
}