Files
portainer/api/http/handler/auth/authenticate_test.go
T
2021-08-12 11:30:50 +12:00

35 lines
833 B
Go

package auth
import (
"testing"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/internal/testhelpers"
"github.com/stretchr/testify/assert"
)
func TestIsLDAPAdmin_Match(t *testing.T) {
ldapService := testhelpers.NewLDAPService()
mockLDAPSettings := &portainer.LDAPSettings{
AdminGroups: []string{"manager", "stuff"},
}
isLDAPAdmin, err := isLDAPAdmin("username", ldapService, mockLDAPSettings)
assert.NoError(t, err)
assert.Equal(t, true, isLDAPAdmin)
}
func TestIsLDAPAdmin_NotMatch(t *testing.T) {
ldapService := testhelpers.NewLDAPService()
mockLDAPSettings := &portainer.LDAPSettings{
AdminGroups: []string{"admin", "manager"},
}
isLDAPAdmin, err := isLDAPAdmin("username", ldapService, mockLDAPSettings)
assert.NoError(t, err)
assert.Equal(t, false, isLDAPAdmin)
}