mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-7025: Fix Slack Import API. (#6905)
This commit is contained in:
committed by
Saturnino Abril
parent
e975b84a12
commit
2bf64b54c2
@@ -5,7 +5,7 @@ package api4
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -657,12 +657,12 @@ func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Disposition", "attachment; filename=MattermostImportLog.txt")
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
data := map[string]string{}
|
||||
data["results"] = base64.StdEncoding.EncodeToString([]byte(log.Bytes()))
|
||||
if c.Err != nil {
|
||||
w.WriteHeader(c.Err.StatusCode)
|
||||
}
|
||||
io.Copy(w, bytes.NewReader(log.Bytes()))
|
||||
w.Write([]byte(model.MapToJson(data)))
|
||||
}
|
||||
|
||||
func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/mattermost/platform/app"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/utils"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
func TestCreateTeam(t *testing.T) {
|
||||
@@ -1345,7 +1346,12 @@ func TestImportTeam(t *testing.T) {
|
||||
fileResp, resp := th.SystemAdminClient.ImportTeam(data, binary.Size(data), "slack", "Fake_Team_Import.zip", th.BasicTeam.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
fileReturned := fmt.Sprintf("%s", fileResp)
|
||||
fileData, err := base64.StdEncoding.DecodeString(fileResp["results"])
|
||||
if err != nil {
|
||||
t.Fatal("failed to decode base64 results data")
|
||||
}
|
||||
|
||||
fileReturned := fmt.Sprintf("%s", fileData)
|
||||
if !strings.Contains(fileReturned, "darth.vader@stardeath.com") {
|
||||
t.Log(fileReturned)
|
||||
t.Fatal("failed to report the user was imported")
|
||||
|
||||
Reference in New Issue
Block a user