2023-11-22 23:57:29 +00:00
|
|
|
package permissions
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2023-12-08 07:15:08 +00:00
|
|
|
"go.woodpecker-ci.org/woodpecker/v2/server/model"
|
2023-11-22 23:57:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestOwnersAllowlist(t *testing.T) {
|
|
|
|
ol := NewOwnersAllowlist([]string{"woodpecker-ci"})
|
|
|
|
assert.True(t, ol.IsAllowed(&model.Repo{Owner: "woodpecker-ci"}))
|
|
|
|
assert.False(t, ol.IsAllowed(&model.Repo{Owner: "not-woodpecker-ci"}))
|
|
|
|
empty := NewOwnersAllowlist([]string{})
|
|
|
|
assert.True(t, empty.IsAllowed(&model.Repo{Owner: "woodpecker-ci"}))
|
|
|
|
assert.True(t, empty.IsAllowed(&model.Repo{Owner: "not-woodpecker-ci"}))
|
|
|
|
}
|