From 2488b980e81a73e77d5d9fca0243576e13b182b2 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Tue, 3 Aug 2021 20:38:15 +0530 Subject: [PATCH] Remove deprecated *model.Client methods (#18042) ```release-note Removed CheckUserMfa Removed GetServerBusyExpires ``` --- api4/system_test.go | 18 ----------------- api4/user_test.go | 49 --------------------------------------------- model/client4.go | 36 --------------------------------- 3 files changed, 103 deletions(-) diff --git a/api4/system_test.go b/api4/system_test.go index a8c9b38808..3db5f3187e 100644 --- a/api4/system_test.go +++ b/api4/system_test.go @@ -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() diff --git a/api4/user_test.go b/api4/user_test.go index 0087addb87..0c20bd6751 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -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() diff --git a/model/client4.go b/model/client4.go index aff056e8cb..50d1c2c016 100644 --- a/model/client4.go +++ b/model/client4.go @@ -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)