Files
mattermost/api4/saml_test.go
Agniva De Sarker e89b26e8f3 goimports (#16640)
* format using `goimports -local github.com/mattermost/mattermost-server/v5 -w`

* added goimports lint check to .golangci.yml

* format using `goimports -local github.com/mattermost/mattermost-server/v5 -w` for a corner case

* make app-layers, *-mocks and store-layers for ci check

Co-authored-by: Mahmudul Haque <mahmudulhaque@protonmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-07 22:42:43 +05:30

53 lines
1.1 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package api4
import (
"net/http"
"testing"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v5/model"
)
func TestGetSamlMetadata(t *testing.T) {
th := Setup(t)
defer th.TearDown()
Client := th.Client
_, resp := Client.GetSamlMetadata()
CheckNotImplementedStatus(t, resp)
// Rest is tested by enterprise tests
}
func TestSamlCompleteCSRFPass(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
url := th.Client.Url + "/login/sso/saml"
req, err := http.NewRequest("POST", url, nil)
if err != nil {
return
}
cookie1 := &http.Cookie{
Name: model.SESSION_COOKIE_USER,
Value: th.BasicUser.Username,
}
cookie2 := &http.Cookie{
Name: model.SESSION_COOKIE_TOKEN,
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()
}