Some checks failed
Pipeline: Test, Lint, Build / Get version info (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test JS code (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint i18n files (push) Has been cancelled
Pipeline: Test, Lint, Build / Check Docker configuration (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to GHCR (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Has been cancelled
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Has been cancelled
Pipeline: Test, Lint, Build / Build Windows installers (push) Has been cancelled
Pipeline: Test, Lint, Build / Package/Release (push) Has been cancelled
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
POEditor import / update-translations (push) Has been cancelled
79 lines
2.3 KiB
Go
79 lines
2.3 KiB
Go
//go:build wasip1
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/navidrome/navidrome/plugins/api"
|
|
"github.com/navidrome/navidrome/plugins/host/http"
|
|
)
|
|
|
|
type UnauthorizedPlugin struct{}
|
|
|
|
var ErrNotFound = api.ErrNotFound
|
|
|
|
func (UnauthorizedPlugin) GetAlbumInfo(ctx context.Context, req *api.AlbumInfoRequest) (*api.AlbumInfoResponse, error) {
|
|
// This plugin attempts to make an HTTP call without having HTTP permission
|
|
// This should fail since the plugin has no permissions in its manifest
|
|
httpClient := http.NewHttpService()
|
|
|
|
request := &http.HttpRequest{
|
|
Url: "https://example.com/test",
|
|
Headers: map[string]string{
|
|
"Accept": "application/json",
|
|
},
|
|
TimeoutMs: 5000,
|
|
}
|
|
|
|
_, err := httpClient.Get(ctx, request)
|
|
if err != nil {
|
|
// Expected to fail due to missing permission
|
|
return nil, err
|
|
}
|
|
|
|
return &api.AlbumInfoResponse{
|
|
Info: &api.AlbumInfo{
|
|
Name: req.Name,
|
|
Mbid: "unauthorized-test",
|
|
Description: "This should not work",
|
|
Url: "https://example.com/unauthorized",
|
|
},
|
|
}, nil
|
|
}
|
|
|
|
func (UnauthorizedPlugin) GetAlbumImages(ctx context.Context, req *api.AlbumImagesRequest) (*api.AlbumImagesResponse, error) {
|
|
return nil, api.ErrNotImplemented
|
|
}
|
|
|
|
func (UnauthorizedPlugin) GetArtistMBID(ctx context.Context, req *api.ArtistMBIDRequest) (*api.ArtistMBIDResponse, error) {
|
|
return nil, api.ErrNotImplemented
|
|
}
|
|
|
|
func (UnauthorizedPlugin) GetArtistURL(ctx context.Context, req *api.ArtistURLRequest) (*api.ArtistURLResponse, error) {
|
|
return nil, api.ErrNotImplemented
|
|
}
|
|
|
|
func (UnauthorizedPlugin) GetArtistBiography(ctx context.Context, req *api.ArtistBiographyRequest) (*api.ArtistBiographyResponse, error) {
|
|
return nil, api.ErrNotImplemented
|
|
}
|
|
|
|
func (UnauthorizedPlugin) GetSimilarArtists(ctx context.Context, req *api.ArtistSimilarRequest) (*api.ArtistSimilarResponse, error) {
|
|
return nil, api.ErrNotImplemented
|
|
}
|
|
|
|
func (UnauthorizedPlugin) GetArtistImages(ctx context.Context, req *api.ArtistImageRequest) (*api.ArtistImageResponse, error) {
|
|
return nil, api.ErrNotImplemented
|
|
}
|
|
|
|
func (UnauthorizedPlugin) GetArtistTopSongs(ctx context.Context, req *api.ArtistTopSongsRequest) (*api.ArtistTopSongsResponse, error) {
|
|
return nil, api.ErrNotImplemented
|
|
}
|
|
|
|
func main() {}
|
|
|
|
// Register the plugin implementation
|
|
func init() {
|
|
api.RegisterMetadataAgent(UnauthorizedPlugin{})
|
|
}
|