[MM-24604] Migrate get channel and get channel by name endpoints to local mode (#14547)

* add unix socket listener for mmctl local mode

* First working PoC

* Adds the channel list endpoint

* Add team list endpoint

* Add a LocalClient to the api test helper and start local mode

* Add helper to test with both SystemAdmin and Local clients

* Add some docs

* Adds TestForAllClients test helper

* Incorporating @ashishbhate's proposal for adding test names to the helpers

* [MM-24146] Add unix socket listener for mmctl local mode (#14296)

* add unix socket listener for mmctl local mode

* add a constant for local-mode socket path

* reflect review comments

* Fix init errors after merge

* Adds create channel tests

* Always init local mode to allow for enabling-disabling it via config

* Check the RemoteAddr of the request before marking session as local

* [MM-24604] Migrate get channel and get channel by name endpoints to local mode

* Remove local test conditional

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Этот коммит содержится в:
Miguel de la Cruz
2020-06-14 10:31:20 +02:00
коммит произвёл GitHub
родитель 81a87533a9
Коммит 4bc859433b
4 изменённых файлов: 22 добавлений и 20 удалений

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

@@ -655,14 +655,16 @@ func TestGetChannel(t *testing.T) {
_, resp = Client.GetChannel(th.BasicChannel.Id, "")
CheckForbiddenStatus(t, resp)
_, resp = th.SystemAdminClient.GetChannel(th.BasicChannel.Id, "")
CheckNoError(t, resp)
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
_, resp = client.GetChannel(th.BasicChannel.Id, "")
CheckNoError(t, resp)
_, resp = th.SystemAdminClient.GetChannel(th.BasicPrivateChannel.Id, "")
CheckNoError(t, resp)
_, resp = client.GetChannel(th.BasicPrivateChannel.Id, "")
CheckNoError(t, resp)
_, resp = th.SystemAdminClient.GetChannel(th.BasicUser.Id, "")
CheckNotFoundStatus(t, resp)
_, resp = client.GetChannel(th.BasicUser.Id, "")
CheckNotFoundStatus(t, resp)
})
}
func TestGetDeletedChannelsForTeam(t *testing.T) {
@@ -1612,8 +1614,10 @@ func TestGetChannelByName(t *testing.T) {
_, resp = Client.GetChannelByName(th.BasicChannel.Name, th.BasicTeam.Id, "")
CheckForbiddenStatus(t, resp)
_, resp = th.SystemAdminClient.GetChannelByName(th.BasicChannel.Name, th.BasicTeam.Id, "")
CheckNoError(t, resp)
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
_, resp = client.GetChannelByName(th.BasicChannel.Name, th.BasicTeam.Id, "")
CheckNoError(t, resp)
})
}
func TestGetChannelByNameForTeamName(t *testing.T) {
@@ -1676,12 +1680,8 @@ func TestGetChannelMembers(t *testing.T) {
CheckBadRequestStatus(t, resp)
_, resp = client.GetChannelMembers("", 0, 60, "")
// NOTE: for some reason, while using the LocalClient, the route /channels//members is not handled
if client == th.LocalClient {
CheckNotFoundStatus(t, resp)
} else {
CheckBadRequestStatus(t, resp)
}
CheckBadRequestStatus(t, resp)
_, resp = client.GetChannelMembers(th.BasicChannel.Id, 0, 60, "")
CheckNoError(t, resp)
})