mirror of
https://github.com/navidrome/navidrome.git
synced 2026-04-17 04:59:37 -04:00
* feat: add Path to TrackInfo struct * refactor: improve naming to follow the rest of the code * test: add tests * fix: actually check for filesystem permission * refactor: remove library logic from specific plugins * refactor: move hasFilesystemPermission to a Manifest method * test(plugins): add unit tests for hasLibraryFilesystemAccess method Signed-off-by: Deluan <deluan@navidrome.org> * refactor(plugins): remove hasFilesystemPerm field and use manifest for filesystem permission checks Signed-off-by: Deluan <deluan@navidrome.org> * refactor(plugins): streamline library filesystem access checks in lyrics and scrobbler adapters Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org> Co-authored-by: Deluan <deluan@navidrome.org>
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
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())
|
|
})
|
|
})
|
|
})
|