summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-05-16 13:43:22 -0400
committerGitHub <noreply@github.com>2018-05-16 13:43:22 -0400
commit1f6c271b3bedd6656ae7155714423b1b39a669c1 (patch)
tree9ce6390c237cc5f7c16d63addb4372033807cff8 /cmd
parent02f8c18f40cd0e973e4c75b751e8fcbbbd019728 (diff)
downloadchat-1f6c271b3bedd6656ae7155714423b1b39a669c1.tar.gz
chat-1f6c271b3bedd6656ae7155714423b1b39a669c1.tar.bz2
chat-1f6c271b3bedd6656ae7155714423b1b39a669c1.zip
MM-8708 Remove api package (#8784)
* Remove api package * Remove api dependency from cmd package * Remove EnableAPIv3 setting * Update web tests * Add more websocket tests * Move some ws and oauth tests to api4 package * Move command tests into api4 package * Test fixes * Fix msg command test * Add some app file tests
Diffstat (limited to 'cmd')
-rw-r--r--cmd/commands/channel_test.go29
-rw-r--r--cmd/commands/roles_test.go4
-rw-r--r--cmd/commands/sampledata_test.go4
-rw-r--r--cmd/commands/server.go6
-rw-r--r--cmd/commands/team_test.go18
-rw-r--r--cmd/commands/test.go7
-rw-r--r--cmd/commands/user_test.go18
7 files changed, 40 insertions, 46 deletions
diff --git a/cmd/commands/channel_test.go b/cmd/commands/channel_test.go
index bd19b020a..09747b10b 100644
--- a/cmd/commands/channel_test.go
+++ b/cmd/commands/channel_test.go
@@ -7,17 +7,17 @@ import (
"strings"
"testing"
- "github.com/mattermost/mattermost-server/api"
+ "github.com/mattermost/mattermost-server/api4"
"github.com/mattermost/mattermost-server/cmd"
"github.com/mattermost/mattermost-server/model"
"github.com/stretchr/testify/require"
)
func TestJoinChannel(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
- channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
+ channel := th.CreatePublicChannel()
cmd.CheckCommand(t, "channel", "add", th.BasicTeam.Name+":"+channel.Name, th.BasicUser2.Email)
@@ -29,10 +29,10 @@ func TestJoinChannel(t *testing.T) {
}
func TestRemoveChannel(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
- channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
+ channel := th.CreatePublicChannel()
cmd.CheckCommand(t, "channel", "add", th.BasicTeam.Name+":"+channel.Name, th.BasicUser2.Email)
@@ -46,12 +46,11 @@ func TestRemoveChannel(t *testing.T) {
}
func TestMoveChannel(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
- client := th.BasicClient
team1 := th.BasicTeam
- team2 := th.CreateTeam(client)
+ team2 := th.CreateTeam()
user1 := th.BasicUser
th.LinkUserToTeam(user1, team2)
channel := th.BasicChannel
@@ -73,11 +72,11 @@ func TestMoveChannel(t *testing.T) {
}
func TestListChannels(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
- channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
- th.BasicClient.Must(th.BasicClient.DeleteChannel(channel.Id))
+ channel := th.CreatePublicChannel()
+ th.Client.Must(th.Client.DeleteChannel(channel.Id))
output := cmd.CheckCommand(t, "channel", "list", th.BasicTeam.Name)
@@ -91,11 +90,11 @@ func TestListChannels(t *testing.T) {
}
func TestRestoreChannel(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
- channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
- th.BasicClient.Must(th.BasicClient.DeleteChannel(channel.Id))
+ channel := th.CreatePublicChannel()
+ th.Client.Must(th.Client.DeleteChannel(channel.Id))
cmd.CheckCommand(t, "channel", "restore", th.BasicTeam.Name+":"+channel.Name)
@@ -104,7 +103,7 @@ func TestRestoreChannel(t *testing.T) {
}
func TestCreateChannel(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
id := model.NewId()
diff --git a/cmd/commands/roles_test.go b/cmd/commands/roles_test.go
index 1e0a46a4e..b6b3ae10f 100644
--- a/cmd/commands/roles_test.go
+++ b/cmd/commands/roles_test.go
@@ -6,13 +6,13 @@ package commands
import (
"testing"
- "github.com/mattermost/mattermost-server/api"
+ "github.com/mattermost/mattermost-server/api4"
"github.com/mattermost/mattermost-server/cmd"
"github.com/mattermost/mattermost-server/model"
)
func TestAssignRole(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
cmd.CheckCommand(t, "roles", "system_admin", th.BasicUser.Email)
diff --git a/cmd/commands/sampledata_test.go b/cmd/commands/sampledata_test.go
index d71ac0575..183392f11 100644
--- a/cmd/commands/sampledata_test.go
+++ b/cmd/commands/sampledata_test.go
@@ -6,13 +6,13 @@ package commands
import (
"testing"
- "github.com/mattermost/mattermost-server/api"
+ "github.com/mattermost/mattermost-server/api4"
"github.com/mattermost/mattermost-server/cmd"
"github.com/stretchr/testify/require"
)
func TestSampledataBadParameters(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
// should fail because you need at least 1 worker
diff --git a/cmd/commands/server.go b/cmd/commands/server.go
index 441eb82bc..0d354f08e 100644
--- a/cmd/commands/server.go
+++ b/cmd/commands/server.go
@@ -11,7 +11,6 @@ import (
"syscall"
"time"
- "github.com/mattermost/mattermost-server/api"
"github.com/mattermost/mattermost-server/api4"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/cmd"
@@ -104,8 +103,7 @@ func runServer(configFileLocation string, disableConfigWatch bool, interruptChan
return serverErr
}
- api4.Init(a, a.Srv.Router, false)
- api3 := api.Init(a, a.Srv.Router)
+ api := api4.Init(a, a.Srv.Router)
wsapi.Init(a, a.Srv.WebSocketRouter)
web.NewWeb(a, a.Srv.Router)
@@ -135,7 +133,7 @@ func runServer(configFileLocation string, disableConfigWatch bool, interruptChan
// If we allow testing then listen for manual testing URL hits
if a.Config().ServiceSettings.EnableTesting {
- manualtesting.Init(api3)
+ manualtesting.Init(api)
}
a.EnsureDiagnosticId()
diff --git a/cmd/commands/team_test.go b/cmd/commands/team_test.go
index ac006dbe1..e6bc47a09 100644
--- a/cmd/commands/team_test.go
+++ b/cmd/commands/team_test.go
@@ -7,13 +7,13 @@ import (
"strings"
"testing"
- "github.com/mattermost/mattermost-server/api"
+ "github.com/mattermost/mattermost-server/api4"
"github.com/mattermost/mattermost-server/cmd"
"github.com/mattermost/mattermost-server/model"
)
func TestCreateTeam(t *testing.T) {
- th := api.Setup().InitSystemAdmin()
+ th := api4.Setup().InitSystemAdmin()
defer th.TearDown()
id := model.NewId()
@@ -22,7 +22,7 @@ func TestCreateTeam(t *testing.T) {
cmd.CheckCommand(t, "team", "create", "--name", name, "--display_name", displayName)
- found := th.SystemAdminClient.Must(th.SystemAdminClient.FindTeamByName(name)).Data.(bool)
+ found := th.SystemAdminClient.Must(th.SystemAdminClient.TeamExists(name, "")).(bool)
if !found {
t.Fatal("Failed to create Team")
@@ -30,12 +30,12 @@ func TestCreateTeam(t *testing.T) {
}
func TestJoinTeam(t *testing.T) {
- th := api.Setup().InitSystemAdmin().InitBasic()
+ th := api4.Setup().InitSystemAdmin().InitBasic()
defer th.TearDown()
- cmd.CheckCommand(t, "team", "add", th.SystemAdminTeam.Name, th.BasicUser.Email)
+ cmd.CheckCommand(t, "team", "add", th.BasicTeam.Name, th.BasicUser.Email)
- profiles := th.SystemAdminClient.Must(th.SystemAdminClient.GetProfilesInTeam(th.SystemAdminTeam.Id, 0, 1000, "")).Data.(map[string]*model.User)
+ profiles := th.SystemAdminClient.Must(th.SystemAdminClient.GetUsersInTeam(th.BasicTeam.Id, 0, 1000, "")).([]*model.User)
found := false
@@ -52,12 +52,12 @@ func TestJoinTeam(t *testing.T) {
}
func TestLeaveTeam(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
cmd.CheckCommand(t, "team", "remove", th.BasicTeam.Name, th.BasicUser.Email)
- profiles := th.BasicClient.Must(th.BasicClient.GetProfilesInTeam(th.BasicTeam.Id, 0, 1000, "")).Data.(map[string]*model.User)
+ profiles := th.Client.Must(th.Client.GetUsersInTeam(th.BasicTeam.Id, 0, 1000, "")).([]*model.User)
found := false
@@ -81,7 +81,7 @@ func TestLeaveTeam(t *testing.T) {
}
func TestListTeams(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
id := model.NewId()
diff --git a/cmd/commands/test.go b/cmd/commands/test.go
index 62df16438..837b988cc 100644
--- a/cmd/commands/test.go
+++ b/cmd/commands/test.go
@@ -12,7 +12,6 @@ import (
"os/signal"
"syscall"
- "github.com/mattermost/mattermost-server/api"
"github.com/mattermost/mattermost-server/api4"
"github.com/mattermost/mattermost-server/cmd"
"github.com/mattermost/mattermost-server/model"
@@ -60,8 +59,7 @@ func webClientTestsCmdF(command *cobra.Command, args []string) error {
return serverErr
}
- api4.Init(a, a.Srv.Router, false)
- api.Init(a, a.Srv.Router)
+ api4.Init(a, a.Srv.Router)
wsapi.Init(a, a.Srv.WebSocketRouter)
a.UpdateConfig(setupClientTests)
runWebClientTests()
@@ -82,8 +80,7 @@ func serverForWebClientTestsCmdF(command *cobra.Command, args []string) error {
return serverErr
}
- api4.Init(a, a.Srv.Router, false)
- api.Init(a, a.Srv.Router)
+ api4.Init(a, a.Srv.Router)
wsapi.Init(a, a.Srv.WebSocketRouter)
a.UpdateConfig(setupClientTests)
diff --git a/cmd/commands/user_test.go b/cmd/commands/user_test.go
index 8691ac803..e51a6150b 100644
--- a/cmd/commands/user_test.go
+++ b/cmd/commands/user_test.go
@@ -6,14 +6,14 @@ package commands
import (
"testing"
- "github.com/mattermost/mattermost-server/api"
+ "github.com/mattermost/mattermost-server/api4"
"github.com/mattermost/mattermost-server/cmd"
"github.com/mattermost/mattermost-server/model"
"github.com/stretchr/testify/require"
)
func TestCreateUserWithTeam(t *testing.T) {
- th := api.Setup().InitSystemAdmin()
+ th := api4.Setup().InitBasic().InitSystemAdmin()
defer th.TearDown()
id := model.NewId()
@@ -22,9 +22,9 @@ func TestCreateUserWithTeam(t *testing.T) {
cmd.CheckCommand(t, "user", "create", "--email", email, "--password", "mypassword1", "--username", username)
- cmd.CheckCommand(t, "team", "add", th.SystemAdminTeam.Id, email)
+ cmd.CheckCommand(t, "team", "add", th.BasicTeam.Id, email)
- profiles := th.SystemAdminClient.Must(th.SystemAdminClient.GetProfilesInTeam(th.SystemAdminTeam.Id, 0, 1000, "")).Data.(map[string]*model.User)
+ profiles := th.SystemAdminClient.Must(th.SystemAdminClient.GetUsersInTeam(th.BasicTeam.Id, 0, 1000, "")).([]*model.User)
found := false
@@ -41,7 +41,7 @@ func TestCreateUserWithTeam(t *testing.T) {
}
func TestCreateUserWithoutTeam(t *testing.T) {
- th := api.Setup()
+ th := api4.Setup()
defer th.TearDown()
id := model.NewId()
@@ -61,18 +61,18 @@ func TestCreateUserWithoutTeam(t *testing.T) {
}
func TestResetPassword(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
cmd.CheckCommand(t, "user", "password", th.BasicUser.Email, "password2")
- th.BasicClient.Logout()
+ th.Client.Logout()
th.BasicUser.Password = "password2"
th.LoginBasic()
}
func TestMakeUserActiveAndInactive(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
// first inactivate the user
@@ -83,7 +83,7 @@ func TestMakeUserActiveAndInactive(t *testing.T) {
}
func TestChangeUserEmail(t *testing.T) {
- th := api.Setup().InitBasic()
+ th := api4.Setup().InitBasic()
defer th.TearDown()
newEmail := model.NewId() + "@mattermost-test.com"