api4/ldap: add test/sync/getgroups to local mode (#14842)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7bf6565ed2
Коммит
516ceaed8e
@@ -303,6 +303,7 @@ func InitLocal(configservice configservice.ConfigService, globalOptionsFunc app.
|
|||||||
|
|
||||||
api.BaseRoutes.Groups = api.BaseRoutes.ApiRoot.PathPrefix("/groups").Subrouter()
|
api.BaseRoutes.Groups = api.BaseRoutes.ApiRoot.PathPrefix("/groups").Subrouter()
|
||||||
|
|
||||||
|
api.BaseRoutes.LDAP = api.BaseRoutes.ApiRoot.PathPrefix("/ldap").Subrouter()
|
||||||
api.BaseRoutes.Posts = api.BaseRoutes.ApiRoot.PathPrefix("/posts").Subrouter()
|
api.BaseRoutes.Posts = api.BaseRoutes.ApiRoot.PathPrefix("/posts").Subrouter()
|
||||||
api.BaseRoutes.Post = api.BaseRoutes.Posts.PathPrefix("/{post_id:[A-Za-z0-9]+}").Subrouter()
|
api.BaseRoutes.Post = api.BaseRoutes.Posts.PathPrefix("/{post_id:[A-Za-z0-9]+}").Subrouter()
|
||||||
api.BaseRoutes.PostsForChannel = api.BaseRoutes.Channel.PathPrefix("/posts").Subrouter()
|
api.BaseRoutes.PostsForChannel = api.BaseRoutes.Channel.PathPrefix("/posts").Subrouter()
|
||||||
@@ -316,6 +317,7 @@ func InitLocal(configservice configservice.ConfigService, globalOptionsFunc app.
|
|||||||
api.InitLicenseLocal()
|
api.InitLicenseLocal()
|
||||||
api.InitBotLocal()
|
api.InitBotLocal()
|
||||||
api.InitGroupLocal()
|
api.InitGroupLocal()
|
||||||
|
api.InitLdapLocal()
|
||||||
api.InitSystemLocal()
|
api.InitSystemLocal()
|
||||||
api.InitPostLocal()
|
api.InitPostLocal()
|
||||||
|
|
||||||
|
|||||||
10
api4/ldap_local.go
Обычный файл
10
api4/ldap_local.go
Обычный файл
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
package api4
|
||||||
|
|
||||||
|
func (api *API) InitLdapLocal() {
|
||||||
|
api.BaseRoutes.LDAP.Handle("/sync", api.ApiLocal(syncLdap)).Methods("POST")
|
||||||
|
api.BaseRoutes.LDAP.Handle("/test", api.ApiLocal(testLdap)).Methods("POST")
|
||||||
|
api.BaseRoutes.LDAP.Handle("/groups", api.ApiLocal(getLdapGroups)).Methods("GET")
|
||||||
|
}
|
||||||
@@ -15,39 +15,46 @@ func TestTestLdap(t *testing.T) {
|
|||||||
th := Setup(t).InitBasic()
|
th := Setup(t).InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
_, resp := th.SystemAdminClient.TestLdap()
|
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||||
CheckNotImplementedStatus(t, resp)
|
_, resp := client.TestLdap()
|
||||||
require.NotNil(t, resp.Error)
|
CheckNotImplementedStatus(t, resp)
|
||||||
require.Equal(t, "api.ldap_groups.license_error", resp.Error.Id)
|
require.NotNil(t, resp.Error)
|
||||||
|
require.Equal(t, "api.ldap_groups.license_error", resp.Error.Id)
|
||||||
|
})
|
||||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap_groups"))
|
th.App.Srv().SetLicense(model.NewTestLicense("ldap_groups"))
|
||||||
|
|
||||||
_, resp = th.Client.TestLdap()
|
_, resp := th.Client.TestLdap()
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
require.NotNil(t, resp.Error)
|
require.NotNil(t, resp.Error)
|
||||||
require.Equal(t, "api.context.permissions.app_error", resp.Error.Id)
|
require.Equal(t, "api.context.permissions.app_error", resp.Error.Id)
|
||||||
|
|
||||||
_, resp = th.SystemAdminClient.TestLdap()
|
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||||
CheckNotImplementedStatus(t, resp)
|
_, resp = client.TestLdap()
|
||||||
require.NotNil(t, resp.Error)
|
CheckNotImplementedStatus(t, resp)
|
||||||
require.Equal(t, "ent.ldap.disabled.app_error", resp.Error.Id)
|
require.NotNil(t, resp.Error)
|
||||||
|
require.Equal(t, "ent.ldap.disabled.app_error", resp.Error.Id)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSyncLdap(t *testing.T) {
|
func TestSyncLdap(t *testing.T) {
|
||||||
th := Setup(t).InitBasic()
|
th := Setup(t).InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
_, resp := th.SystemAdminClient.SyncLdap()
|
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||||
CheckNotImplementedStatus(t, resp)
|
_, resp := client.TestLdap()
|
||||||
require.NotNil(t, resp.Error)
|
CheckNotImplementedStatus(t, resp)
|
||||||
require.Equal(t, "api.ldap_groups.license_error", resp.Error.Id)
|
require.NotNil(t, resp.Error)
|
||||||
|
require.Equal(t, "api.ldap_groups.license_error", resp.Error.Id)
|
||||||
|
})
|
||||||
|
|
||||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap_groups"))
|
th.App.Srv().SetLicense(model.NewTestLicense("ldap_groups"))
|
||||||
|
|
||||||
_, resp = th.SystemAdminClient.SyncLdap()
|
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||||
CheckNoError(t, resp)
|
_, resp := client.SyncLdap()
|
||||||
|
CheckNoError(t, resp)
|
||||||
|
})
|
||||||
|
|
||||||
_, resp = th.Client.SyncLdap()
|
_, resp := th.Client.SyncLdap()
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +65,10 @@ func TestGetLdapGroups(t *testing.T) {
|
|||||||
_, resp := th.Client.GetLdapGroups()
|
_, resp := th.Client.GetLdapGroups()
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
_, resp = th.SystemAdminClient.GetLdapGroups()
|
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||||
CheckNotImplementedStatus(t, resp)
|
_, resp := client.GetLdapGroups()
|
||||||
|
CheckNotImplementedStatus(t, resp)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkLdapGroup(t *testing.T) {
|
func TestLinkLdapGroup(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user