Files
zeekay 8feb24ea1f One name for this fork, and it is ours
The server module named github.com/hanzoai/team/server/v8 — a path that
resolves to the retired workspace's repository, not this one — while
server/public still published github.com/mattermost/mattermost/server/public.
Both are github.com/hanzoteam/server/... now, which is where this code
actually lives.

That second half is what made the binary unbootable. Upstream's public path
stayed claimed by upstream, mattermost-plugin-ai imported it, and the build
linked public/model twice; public/plugin's gob.Register then ran twice under
one name and panicked at init, before main. Reverting the rename traded the
brand for a working binary. Rebranding the plugin alongside it needs no such
trade: the agents fork is github.com/hanzoteam/agents/v2 against our public
module, so no module named mattermost/mattermost is in the graph at all.

Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and
it is ours.
2026-08-28 23:35:36 -07:00

81 lines
2.0 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package api4
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/require"
"github.com/hanzoteam/server/server/public/model"
"github.com/hanzoteam/server/server/public/shared/request"
"github.com/hanzoteam/server/server/v8/einterfaces/mocks"
)
func TestGetSamlMetadata(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
client := th.Client
_, resp, err := client.GetSamlMetadata(context.Background())
require.Error(t, err)
CheckNotImplementedStatus(t, resp)
// Rest is tested by enterprise tests
}
func TestSamlCompleteCSRFPass(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic(t)
url := th.Client.URL + "/login/sso/saml"
req, err := http.NewRequest("POST", url, nil)
if err != nil {
return
}
cookie1 := &http.Cookie{
Name: model.SessionCookieUser,
Value: th.BasicUser.Username,
}
cookie2 := &http.Cookie{
Name: model.SessionCookieToken,
Value: th.Client.AuthToken,
}
req.AddCookie(cookie1)
req.AddCookie(cookie2)
client := &http.Client{}
resp, err := client.Do(req)
require.NoError(t, err)
require.NotEqual(t, http.StatusUnauthorized, resp.StatusCode)
defer resp.Body.Close()
}
func TestSamlResetId(t *testing.T) {
mainHelper.Parallel(t)
th := SetupEnterprise(t).InitBasic(t)
th.App.Channels().Saml = &mocks.SamlInterface{}
user := th.BasicUser
_, appErr := th.App.UpdateUserAuth(request.TestContext(t), user.Id, &model.UserAuth{
AuthData: new(model.NewId()),
AuthService: model.UserAuthServiceSaml,
})
require.Nil(t, appErr)
_, resp, err := th.Client.ResetSamlAuthDataToEmail(context.Background(), false, false, nil)
require.Error(t, err)
// UpdateUserAuth revoked all user's sessions, so this is now unauthorized
CheckUnauthorizedStatus(t, resp)
numAffected, resp, err := th.SystemAdminClient.ResetSamlAuthDataToEmail(context.Background(), false, false, nil)
require.NoError(t, err)
CheckOKStatus(t, resp)
require.Equal(t, int64(1), numAffected)
}