fix registry config setter

* default registry provider is noop
* when testing config, skip noop provider
This commit is contained in:
Girish Ramakrishnan
2021-03-02 18:21:35 -08:00
parent cccdf68cec
commit 53cb9b1f7a
3 changed files with 22 additions and 16 deletions

View File

@@ -194,11 +194,13 @@ function getRegistryConfig(req, res, next) {
function setRegistryConfig(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
if (typeof req.body.provider !== 'string') return next(new HttpError(400, 'provider is required'));
if (typeof req.body.serverAddress !== 'string') return next(new HttpError(400, 'serverAddress is required'));
if ('username' in req.body && typeof req.body.username !== 'string') return next(new HttpError(400, 'username is required'));
if ('email' in req.body && typeof req.body.email !== 'string') return next(new HttpError(400, 'email is required'));
if ('password' in req.body && typeof req.body.password !== 'string') return next(new HttpError(400, 'password is required'));
if (!req.body.provider || typeof req.body.provider !== 'string') return next(new HttpError(400, 'provider is required'));
if (req.body.provider !== 'noop') {
if (typeof req.body.serverAddress !== 'string') return next(new HttpError(400, 'serverAddress is required'));
if ('username' in req.body && typeof req.body.username !== 'string') return next(new HttpError(400, 'username is required'));
if ('email' in req.body && typeof req.body.email !== 'string') return next(new HttpError(400, 'email is required'));
if ('password' in req.body && typeof req.body.password !== 'string') return next(new HttpError(400, 'password is required'));
}
settings.setRegistryConfig(req.body, function (error) {
if (error) return next(BoxError.toHttpError(error));