Migrate store methods to use request.Context instead of context.Context (#24836)

Этот коммит содержится в:
Ben Schumacher
2023-10-11 13:08:55 +02:00
коммит произвёл GitHub
родитель 0d5a8b8841
Коммит 13c05a571f
127 изменённых файлов: 1030 добавлений и 921 удалений

Просмотреть файл

@@ -49,26 +49,26 @@ func TestGetOAuthAccessTokenForImplicitFlow(t *testing.T) {
State: "123",
}
session, err := th.App.GetOAuthAccessTokenForImplicitFlow(th.BasicUser.Id, authRequest)
session, err := th.App.GetOAuthAccessTokenForImplicitFlow(th.Context, th.BasicUser.Id, authRequest)
assert.Nil(t, err)
assert.NotNil(t, session)
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = false })
session, err = th.App.GetOAuthAccessTokenForImplicitFlow(th.BasicUser.Id, authRequest)
session, err = th.App.GetOAuthAccessTokenForImplicitFlow(th.Context, th.BasicUser.Id, authRequest)
assert.NotNil(t, err, "should fail - oauth2 disabled")
assert.Nil(t, session)
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = true })
authRequest.ClientId = "junk"
session, err = th.App.GetOAuthAccessTokenForImplicitFlow(th.BasicUser.Id, authRequest)
session, err = th.App.GetOAuthAccessTokenForImplicitFlow(th.Context, th.BasicUser.Id, authRequest)
assert.NotNil(t, err, "should fail - bad client id")
assert.Nil(t, session)
authRequest.ClientId = oapp.Id
session, err = th.App.GetOAuthAccessTokenForImplicitFlow("junk", authRequest)
session, err = th.App.GetOAuthAccessTokenForImplicitFlow(th.Context, "junk", authRequest)
assert.NotNil(t, err, "should fail - bad user id")
assert.Nil(t, session)
}
@@ -85,9 +85,9 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
th.App.SetSessionExpireInHours(session, 24)
var err *model.AppError
session, err = th.App.CreateSession(session)
session, err = th.App.CreateSession(th.Context, session)
require.Nil(t, err)
err = th.App.RevokeAccessToken(session.Token)
err = th.App.RevokeAccessToken(th.Context, session.Token)
require.NotNil(t, err, "Should have failed does not have an access token")
require.Equal(t, http.StatusBadRequest, err.StatusCode)
}
@@ -116,7 +116,7 @@ func TestOAuthDeleteApp(t *testing.T) {
session.IsOAuth = true
th.App.ch.srv.platform.SetSessionExpireInHours(session, 24)
session, _ = th.App.CreateSession(session)
session, _ = th.App.CreateSession(th.Context, session)
accessData := &model.AccessData{}
accessData.Token = session.Token
@@ -619,7 +619,7 @@ func TestDeauthorizeOAuthApp(t *testing.T) {
redirectUrl, err := th.App.GetOAuthCodeRedirect(th.BasicUser.Id, authRequest)
assert.Nil(t, err)
dErr := th.App.DeauthorizeOAuthAppForUser(th.BasicUser.Id, oapp.Id)
dErr := th.App.DeauthorizeOAuthAppForUser(th.Context, th.BasicUser.Id, oapp.Id)
assert.Nil(t, dErr)
uri, uErr := url.Parse(redirectUrl)
@@ -670,7 +670,7 @@ func TestDeactivatedUserOAuthApp(t *testing.T) {
_, appErr := th.App.UpdateActive(th.Context, th.BasicUser, false)
require.Nil(t, appErr)
resp, accErr := th.App.GetOAuthAccessTokenForCodeFlow(oapp.Id, model.AccessTokenGrantType, oapp.CallbackUrls[0], code, oapp.ClientSecret, "")
resp, accErr := th.App.GetOAuthAccessTokenForCodeFlow(th.Context, oapp.Id, model.AccessTokenGrantType, oapp.CallbackUrls[0], code, oapp.ClientSecret, "")
assert.Nil(t, resp)
require.NotNil(t, accErr, "Should not get access token")
require.Equal(t, http.StatusBadRequest, accErr.StatusCode)