feat: Security
This commit is contained in:
@@ -63,6 +63,7 @@ describe('PluginStoreService', () => {
|
||||
|
||||
const service = createService(registerLocalManifest, unregister);
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await service.addSourceUrl('https://plugins.example.test/index.json#latest');
|
||||
|
||||
expect(service.sourceUrls()).toEqual([OFFICIAL_PLUGIN_SOURCE_URL, 'https://plugins.example.test/index.json']);
|
||||
@@ -81,9 +82,11 @@ describe('PluginStoreService', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
it('seeds the official plugin repository for new users', () => {
|
||||
it('seeds the official plugin repository for new users', async () => {
|
||||
const service = createService(registerLocalManifest, unregister);
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
expect(service.sourceUrls()).toEqual([OFFICIAL_PLUGIN_SOURCE_URL]);
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
OFFICIAL_PLUGIN_SOURCE_URL,
|
||||
@@ -132,12 +135,15 @@ describe('PluginStoreService', () => {
|
||||
],
|
||||
title: 'Local Plugins'
|
||||
};
|
||||
const grantPluginReadRoot = vi.fn(async () => true);
|
||||
const readFile = vi.fn(async () => toBase64(JSON.stringify(localSourceManifest)));
|
||||
const service = createService(registerLocalManifest, unregister, { readFile });
|
||||
const service = createService(registerLocalManifest, unregister, { grantPluginReadRoot, readFile });
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await service.addSourceUrl('/home/ludde/Desktop/TestPlugin/plugin-source.json');
|
||||
|
||||
expect(fetchMock).not.toHaveBeenCalledWith('/home/ludde/Desktop/TestPlugin/plugin-source.json', expect.anything());
|
||||
expect(grantPluginReadRoot).toHaveBeenCalledWith('/home/ludde/Desktop/TestPlugin');
|
||||
expect(readFile).toHaveBeenCalledWith('/home/ludde/Desktop/TestPlugin/plugin-source.json');
|
||||
expect(service.sourceUrls()).toEqual([OFFICIAL_PLUGIN_SOURCE_URL, 'file:///home/ludde/Desktop/TestPlugin/plugin-source.json']);
|
||||
|
||||
@@ -255,7 +261,8 @@ function createService(
|
||||
electronApi: {
|
||||
ensureDir?: (dirPath: string) => Promise<boolean>;
|
||||
getAppDataPath?: () => Promise<string>;
|
||||
readFile?: (filePath: string) => Promise<string>;
|
||||
grantPluginReadRoot?: (rootPath: string) => Promise<boolean>;
|
||||
readFile?: (filePath: string) => Promise<string | null>;
|
||||
writeFile?: (filePath: string, data: string) => Promise<boolean>;
|
||||
} | null = null
|
||||
): PluginStoreService {
|
||||
|
||||
Reference in New Issue
Block a user