mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-06 22:40:26 -05:00
66f4197236
* chore: test * chore: add * chore: more progress * chore: progress in migration, fix prettier parser * chore: reduce tsc errors * chore: refactor storage utils types * chore: refactor utils types * chore: refactor local storage types * chore: refactor config utils types * chore: refactor tsc types * refactor: apply eslint fix, tabs etc * chore: fix lint errors * test: update unit test conf to typescript setup few test refactored to typescript * chore: enable more unit test migrate to typescript * chore: migrate storage test to tsc * chore: migrate up storage test to tsc * refactor: enable plugin and auth test * chore: migrate plugin loader test * chore: update dependencies * chore: migrate functional test to typescript * chore: add codecove * chore: update express * chore: downgrade puppeteer The latest version does not seems to work properly fine. * chore: update dependencies
101 lines
2.6 KiB
JavaScript
101 lines
2.6 KiB
JavaScript
/**
|
|
* @prettier
|
|
*/
|
|
|
|
// @flow
|
|
|
|
// this file is not aim to be tested, just to check flow definitions
|
|
|
|
import Config from '../../../../src/lib/config';
|
|
import LoggerApi from '../../../../src/lib/logger';
|
|
|
|
import { Config as AppConfig, PackageAccess, IPluginAuth, RemoteUser, Logger, PluginOptions } from '@verdaccio/types';
|
|
|
|
class ExampleAuthPlugin implements IPluginAuth {
|
|
config: AppConfig;
|
|
logger: Logger;
|
|
|
|
constructor(config: AppConfig, options: PluginOptions) {
|
|
this.config = config;
|
|
this.logger = options.logger;
|
|
}
|
|
|
|
adduser(user: string, password: string, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
|
|
changePassword(username, password, newPassword, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
|
|
authenticate(user: string, password: string, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
|
|
allow_access(user: RemoteUser, pkg: PackageAccess, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
|
|
allow_publish(user: RemoteUser, pkg: PackageAccess, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
}
|
|
|
|
type SubTypePackageAccess = PackageAccess & {
|
|
sub?: boolean;
|
|
};
|
|
|
|
class ExampleAuthCustomPlugin implements IPluginAuth {
|
|
config: AppConfig;
|
|
logger: Logger;
|
|
|
|
constructor(config: AppConfig, options: PluginOptions) {
|
|
this.config = config;
|
|
this.logger = options.logger;
|
|
}
|
|
|
|
adduser(user: string, password: string, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
|
|
changePassword(username, password, newPassword, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
|
|
authenticate(user: string, password: string, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
|
|
allow_access(user: RemoteUser, pkg: SubTypePackageAccess, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
|
|
allow_publish(user: RemoteUser, pkg: SubTypePackageAccess, cb: verdaccio$Callback): void {
|
|
cb();
|
|
}
|
|
}
|
|
|
|
const config1: AppConfig = new Config({
|
|
storage: './storage',
|
|
self_path: '/home/sotrage',
|
|
});
|
|
|
|
const options: PluginOptions = {
|
|
config: config1,
|
|
logger: LoggerApi.logger.child(),
|
|
};
|
|
|
|
const auth = new ExampleAuthPlugin(config1, options);
|
|
const authSub = new ExampleAuthCustomPlugin(config1, options);
|
|
const remoteUser: RemoteUser = {
|
|
groups: [],
|
|
real_groups: [],
|
|
name: 'test',
|
|
};
|
|
|
|
auth.authenticate('user', 'pass', () => {});
|
|
auth.allow_access(remoteUser, { access: [], publish: [], proxy: [] }, () => {});
|
|
auth.allow_publish(remoteUser, { access: [], publish: [], proxy: [] }, () => {});
|
|
authSub.authenticate('user', 'pass', () => {});
|
|
authSub.allow_access(remoteUser, { access: [], publish: [], proxy: [], sub: true }, () => {});
|
|
authSub.allow_publish(remoteUser, { access: [], publish: [], proxy: [], sub: true }, () => {});
|