1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

Add repo owner test (#2857)

from #2855
This commit is contained in:
qwerty287 2023-11-23 00:57:29 +01:00 committed by GitHub
parent ac009d9b0b
commit f2071e3999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,17 @@
package permissions
import (
"testing"
"github.com/stretchr/testify/assert"
"go.woodpecker-ci.org/woodpecker/server/model"
)
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"}))
}