mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Error when generating invite codes for a confirmed remote cluster (#28337)
This commit is contained in:
parent
76021c76a0
commit
acc9093072
@ -115,6 +115,8 @@
|
|||||||
description: |
|
description: |
|
||||||
The password generated by the server if none was
|
The password generated by the server if none was
|
||||||
sent on the create request
|
sent on the create request
|
||||||
|
"400":
|
||||||
|
$ref: "#/components/responses/BadRequest"
|
||||||
"401":
|
"401":
|
||||||
$ref: "#/components/responses/Unauthorized"
|
$ref: "#/components/responses/Unauthorized"
|
||||||
"403":
|
"403":
|
||||||
|
@ -533,6 +533,11 @@ func generateRemoteClusterInvite(c *Context, w http.ResponseWriter, r *http.Requ
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rc.IsConfirmed() {
|
||||||
|
c.Err = model.NewAppError("generateRemoteClusterInvite", "api.remote_cluster.generate_invite_cluster_is_confirmed", nil, "", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
inviteCode, invErr := c.App.CreateRemoteClusterInvite(rc.RemoteId, url, rc.Token, password)
|
inviteCode, invErr := c.App.CreateRemoteClusterInvite(rc.RemoteId, url, rc.Token, password)
|
||||||
if invErr != nil {
|
if invErr != nil {
|
||||||
c.Err = invErr
|
c.Err = invErr
|
||||||
|
@ -358,7 +358,7 @@ func TestGenerateRemoteClusterInvite(t *testing.T) {
|
|||||||
|
|
||||||
newRC := &model.RemoteCluster{
|
newRC := &model.RemoteCluster{
|
||||||
Name: "remotecluster",
|
Name: "remotecluster",
|
||||||
SiteURL: "http://example.com",
|
SiteURL: model.SiteURLPending + model.NewId(),
|
||||||
Token: model.NewId(),
|
Token: model.NewId(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,6 +429,18 @@ func TestGenerateRemoteClusterInvite(t *testing.T) {
|
|||||||
require.Equal(t, rc.RemoteId, invite.RemoteId)
|
require.Equal(t, rc.RemoteId, invite.RemoteId)
|
||||||
require.Equal(t, rc.Token, invite.Token)
|
require.Equal(t, rc.Token, invite.Token)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("should return bad request if the cluster is already confirmed", func(t *testing.T) {
|
||||||
|
rc.SiteURL = "http://example.com"
|
||||||
|
savedRC, appErr := th.App.UpdateRemoteCluster(rc)
|
||||||
|
require.Nil(t, appErr)
|
||||||
|
require.Equal(t, rc.SiteURL, savedRC.SiteURL)
|
||||||
|
|
||||||
|
inviteCode, resp, err := th.SystemAdminClient.GenerateRemoteClusterInvite(context.Background(), rc.RemoteId, password)
|
||||||
|
CheckBadRequestStatus(t, resp)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Empty(t, inviteCode)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetRemoteCluster(t *testing.T) {
|
func TestGetRemoteCluster(t *testing.T) {
|
||||||
|
@ -2754,6 +2754,10 @@
|
|||||||
"id": "api.remote_cluster.encrypt_invite_error",
|
"id": "api.remote_cluster.encrypt_invite_error",
|
||||||
"translation": "Could not encrypt the remote cluster invite using the provided password"
|
"translation": "Could not encrypt the remote cluster invite using the provided password"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.remote_cluster.generate_invite_cluster_is_confirmed",
|
||||||
|
"translation": "Cannot generate invite code for a confirmed cluster"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.remote_cluster.get.app_error",
|
"id": "api.remote_cluster.get.app_error",
|
||||||
"translation": "We encountered an error retrieving a secure connection."
|
"translation": "We encountered an error retrieving a secure connection."
|
||||||
|
Loading…
Reference in New Issue
Block a user