OAuth: Able to skip auto login (#28357)

* OAuth: able to skip auto login

* OAuth: tests for internal login param

* OAuth: rename internal -> disableAutoLogin

* OAuth: update log message

* OAuth: fix tests
This commit is contained in:
Alexander Zobnin
2020-10-20 14:51:06 +03:00
committed by GitHub
parent af17f9fd9b
commit d13c6b4c5a
2 changed files with 42 additions and 0 deletions

View File

@@ -500,6 +500,41 @@ func TestLoginOAuthRedirect(t *testing.T) {
assert.Equal(t, location[0], "/login/github")
}
func TestLoginInternal(t *testing.T) {
mockSetIndexViewData()
defer resetSetIndexViewData()
mockViewIndex()
defer resetViewIndex()
sc := setupScenarioContext("/login")
hs := &HTTPServer{
Cfg: setting.NewCfg(),
License: &licensing.OSSLicensingService{},
log: log.New("test"),
}
sc.defaultHandler = Wrap(func(c *models.ReqContext) {
c.Req.URL.RawQuery = "disableAutoLogin=true"
hs.LoginView(c)
})
setting.OAuthService = &setting.OAuther{}
setting.OAuthService.OAuthInfos = make(map[string]*setting.OAuthInfo)
setting.OAuthService.OAuthInfos["github"] = &setting.OAuthInfo{
ClientId: "fake",
ClientSecret: "fakefake",
Enabled: true,
AllowSignup: true,
Name: "github",
}
setting.OAuthAutoLogin = true
sc.m.Get(sc.url, sc.defaultHandler)
sc.fakeReqNoAssertions("GET", sc.url).exec()
// Shouldn't redirect to the OAuth login URL
assert.Equal(t, sc.resp.Code, 200)
}
func TestAuthProxyLoginEnableLoginTokenDisabled(t *testing.T) {
sc := setupAuthProxyLoginTest(false)