Remove deprecated *model.Client methods (#18042)
```release-note Removed CheckUserMfa Removed GetServerBusyExpires ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
249a0b9870
Коммит
2488b980e8
@@ -676,24 +676,6 @@ func TestGetServerBusy(t *testing.T) {
|
||||
}, "as system admin")
|
||||
}
|
||||
|
||||
func TestGetServerBusyExpires(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
|
||||
t.Run("as system user", func(t *testing.T) {
|
||||
_, resp := th.Client.GetServerBusyExpires()
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
|
||||
expires, resp := c.GetServerBusyExpires()
|
||||
CheckNoError(t, resp)
|
||||
require.Greater(t, expires.Unix(), time.Now().Unix())
|
||||
}, "as system admin")
|
||||
}
|
||||
|
||||
func TestServerBusy503(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2689,55 +2689,6 @@ func TestUpdateUserMfa(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// CheckUserMfa is deprecated and should not be used anymore, it will be disabled by default in version 6.0
|
||||
func TestCheckUserMfa(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(c *model.Config) {
|
||||
*c.ServiceSettings.DisableLegacyMFA = false
|
||||
})
|
||||
|
||||
required, resp := th.Client.CheckUserMfa(th.BasicUser.Email)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
require.False(t, required, "mfa not active")
|
||||
|
||||
_, resp = th.Client.CheckUserMfa("")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
th.Client.Logout()
|
||||
|
||||
required, resp = th.Client.CheckUserMfa(th.BasicUser.Email)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
require.False(t, required, "mfa not active")
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("mfa"))
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableMultifactorAuthentication = true })
|
||||
|
||||
th.LoginBasic()
|
||||
|
||||
required, resp = th.Client.CheckUserMfa(th.BasicUser.Email)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
require.False(t, required, "mfa not active")
|
||||
|
||||
th.Client.Logout()
|
||||
|
||||
required, resp = th.Client.CheckUserMfa(th.BasicUser.Email)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
require.False(t, required, "mfa not active")
|
||||
|
||||
th.App.UpdateConfig(func(c *model.Config) {
|
||||
*c.ServiceSettings.DisableLegacyMFA = true
|
||||
})
|
||||
|
||||
_, resp = th.Client.CheckUserMfa(th.BasicUser.Email)
|
||||
CheckNotFoundStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestUserLoginMFAFlow(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1240,26 +1240,6 @@ func (c *Client4) UpdateUserMfa(userId, code string, activate bool) (bool, *Resp
|
||||
return CheckStatusOK(r), BuildResponse(r)
|
||||
}
|
||||
|
||||
// CheckUserMfa checks whether a user has MFA active on their account or not based on the
|
||||
// provided login id.
|
||||
// Deprecated: Clients should use Login method and check for MFA Error
|
||||
func (c *Client4) CheckUserMfa(loginId string) (bool, *Response) {
|
||||
requestBody := make(map[string]interface{})
|
||||
requestBody["login_id"] = loginId
|
||||
r, err := c.DoApiPost(c.GetUsersRoute()+"/mfa", StringInterfaceToJson(requestBody))
|
||||
if err != nil {
|
||||
return false, BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
data := StringInterfaceFromJson(r.Body)
|
||||
mfaRequired, ok := data["mfa_required"].(bool)
|
||||
if !ok {
|
||||
return false, BuildResponse(r)
|
||||
}
|
||||
return mfaRequired, BuildResponse(r)
|
||||
}
|
||||
|
||||
// GenerateMfaSecret will generate a new MFA secret for a user and return it as a string and
|
||||
// as a base64 encoded image QR code.
|
||||
func (c *Client4) GenerateMfaSecret(userId string) (*MfaSecret, *Response) {
|
||||
@@ -6117,22 +6097,6 @@ func (c *Client4) GetServerBusy() (*ServerBusyState, *Response) {
|
||||
return sbs, BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetServerBusyExpires returns the time when a server marked busy
|
||||
// will automatically have the flag cleared.
|
||||
//
|
||||
// Deprecated: Use GetServerBusy instead.
|
||||
func (c *Client4) GetServerBusyExpires() (*time.Time, *Response) {
|
||||
r, err := c.DoApiGet(c.GetServerBusyRoute(), "")
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
sbs := ServerBusyStateFromJson(r.Body)
|
||||
expires := time.Unix(sbs.Expires, 0)
|
||||
return &expires, BuildResponse(r)
|
||||
}
|
||||
|
||||
// RegisterTermsOfServiceAction saves action performed by a user against a specific terms of service.
|
||||
func (c *Client4) RegisterTermsOfServiceAction(userId, termsOfServiceId string, accepted bool) (*bool, *Response) {
|
||||
url := c.GetUserTermsOfServiceRoute(userId)
|
||||
|
||||
Ссылка в новой задаче
Block a user