2018-07-15 12:26:58 -05:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
// this file is not aim to be tested, just to check flow definitions
|
|
|
|
import Config from '../../../../src/lib/config';
|
|
|
|
import {generatePackageTemplate} from '../../../../src/lib/storage-utils';
|
|
|
|
import {readFile} from '../../../functional/lib/test.utils';
|
|
|
|
|
|
|
|
const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`);
|
|
|
|
|
|
|
|
import type {
|
|
|
|
Config as AppConfig,
|
|
|
|
IPluginMiddleware,
|
2018-07-15 16:23:14 -05:00
|
|
|
IStorageManager,
|
2018-07-16 12:53:26 -05:00
|
|
|
RemoteUser,
|
2018-07-15 12:26:58 -05:00
|
|
|
IBasicAuth,
|
|
|
|
} from '@verdaccio/types';
|
|
|
|
import type { IUploadTarball, IReadTarball } from '@verdaccio/streams';
|
|
|
|
|
|
|
|
export default class ExampleMiddlewarePlugin implements IPluginMiddleware {
|
2018-07-15 16:23:14 -05:00
|
|
|
register_middlewares(app: any, auth: IBasicAuth, storage: IStorageManager): void {
|
2018-07-16 12:53:26 -05:00
|
|
|
const remoteUser: RemoteUser = {
|
|
|
|
groups: [],
|
|
|
|
real_groups: [],
|
|
|
|
name: 'test'
|
|
|
|
};
|
2018-07-15 12:26:58 -05:00
|
|
|
auth.authenticate('user', 'password', () => {});
|
2019-01-14 08:23:25 -05:00
|
|
|
auth.allow_access({packageName: 'packageName'}, remoteUser, () => {});
|
2018-07-15 12:26:58 -05:00
|
|
|
auth.add_user('user', 'password', () => {});
|
|
|
|
auth.aesEncrypt(new Buffer('pass'));
|
|
|
|
// storage
|
|
|
|
storage.addPackage('name', generatePackageTemplate('test'), () => {});
|
|
|
|
storage.addVersion('name', 'version', readMetadata(), 'tag', () => {});
|
|
|
|
storage.mergeTags('name', {'latest': '1.0.0'}, () => {});
|
|
|
|
storage.changePackage('name', readMetadata(), 'revision', () => {});
|
|
|
|
storage.removePackage('name', () => {});
|
|
|
|
storage.mergeTags('name', {'latest': '1.0.0'}, () => {});
|
|
|
|
storage.removeTarball('name', 'filename', 'revision', () => {});
|
|
|
|
/* eslint no-unused-vars: 0 */
|
|
|
|
const config1: AppConfig = new Config({
|
|
|
|
storage: './storage',
|
|
|
|
self_path: '/home/sotrage'
|
|
|
|
});
|
|
|
|
const add: IUploadTarball = storage.addTarball('name', 'filename');
|
|
|
|
storage.getTarball('name', 'filename');
|
|
|
|
const read: IReadTarball = storage.getTarball('name', 'filename');
|
2018-07-15 16:23:14 -05:00
|
|
|
const search: IReadTarball = storage.search('test');
|
2018-07-15 12:26:58 -05:00
|
|
|
/* eslint no-unused-vars: 0 */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|