2023-12-27 09:36:49 +00:00
|
|
|
package permissions
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
2024-12-22 09:44:34 +00:00
|
|
|
"go.woodpecker-ci.org/woodpecker/v3/server/model"
|
2023-12-27 09:36:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestAdmins(t *testing.T) {
|
|
|
|
a := NewAdmins([]string{"woodpecker-ci"})
|
|
|
|
assert.True(t, a.IsAdmin(&model.User{Login: "woodpecker-ci"}))
|
|
|
|
assert.False(t, a.IsAdmin(&model.User{Login: "not-woodpecker-ci"}))
|
|
|
|
empty := NewAdmins([]string{})
|
|
|
|
assert.False(t, empty.IsAdmin(&model.User{Login: "woodpecker-ci"}))
|
|
|
|
assert.False(t, empty.IsAdmin(&model.User{Login: "not-woodpecker-ci"}))
|
|
|
|
}
|