quintodrome/plugins/manager_plugin_test.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1.1 KiB
Go
Raw Normal View History

package plugins
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("plugin", func() {
Describe("hasLibraryFilesystemAccess", func() {
fsManifest := &Manifest{
Permissions: &Permissions{
Library: &LibraryPermission{Filesystem: true},
},
}
It("returns false when the manifest does not grant filesystem permission", func() {
p := &plugin{manifest: &Manifest{}, libraries: newLibraryAccess(nil, true)}
Expect(p.hasLibraryFilesystemAccess(1)).To(BeFalse())
})
It("returns true for any library when allLibraries is set", func() {
p := &plugin{manifest: fsManifest, libraries: newLibraryAccess(nil, true)}
Expect(p.hasLibraryFilesystemAccess(1)).To(BeTrue())
Expect(p.hasLibraryFilesystemAccess(42)).To(BeTrue())
})
It("returns true only for libraries in the allowed list", func() {
p := &plugin{manifest: fsManifest, libraries: newLibraryAccess([]int{1, 3}, false)}
Expect(p.hasLibraryFilesystemAccess(1)).To(BeTrue())
Expect(p.hasLibraryFilesystemAccess(3)).To(BeTrue())
Expect(p.hasLibraryFilesystemAccess(2)).To(BeFalse())
})
})
})