mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
parent
187798262e
commit
c500128f07
@ -3,29 +3,33 @@
|
||||
const joi = require('joi');
|
||||
const { nameType } = require('../routes/admin-api/util');
|
||||
|
||||
const strategySchema = joi.object().keys({
|
||||
name: nameType,
|
||||
editable: joi.boolean().default(true),
|
||||
description: joi
|
||||
.string()
|
||||
.allow(null)
|
||||
.allow('')
|
||||
.optional(),
|
||||
parameters: joi
|
||||
.array()
|
||||
.required()
|
||||
.items(
|
||||
joi.object().keys({
|
||||
name: joi.string().required(),
|
||||
type: joi.string().required(),
|
||||
description: joi
|
||||
.string()
|
||||
.allow(null)
|
||||
.allow('')
|
||||
.optional(),
|
||||
required: joi.boolean(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
const strategySchema = joi
|
||||
.object()
|
||||
.keys({
|
||||
name: nameType,
|
||||
editable: joi.boolean().default(true),
|
||||
deprecated: joi.boolean().default(false),
|
||||
description: joi
|
||||
.string()
|
||||
.allow(null)
|
||||
.allow('')
|
||||
.optional(),
|
||||
parameters: joi
|
||||
.array()
|
||||
.required()
|
||||
.items(
|
||||
joi.object().keys({
|
||||
name: joi.string().required(),
|
||||
type: joi.string().required(),
|
||||
description: joi
|
||||
.string()
|
||||
.allow(null)
|
||||
.allow('')
|
||||
.optional(),
|
||||
required: joi.boolean(),
|
||||
}),
|
||||
),
|
||||
})
|
||||
.options({ allowUnknown: false, stripUnknown: true, abortEarly: false });
|
||||
|
||||
module.exports = strategySchema;
|
||||
|
@ -172,3 +172,30 @@ test.serial('cannot deprecate default strategy', async t => {
|
||||
const request = await setupApp(stores);
|
||||
await request.post('/api/admin/strategies/default/deprecate').expect(403);
|
||||
});
|
||||
|
||||
test.serial('can update a exiting strategy with deprecated', async t => {
|
||||
t.plan(0);
|
||||
const request = await setupApp(stores);
|
||||
|
||||
await request
|
||||
.post('/api/admin/strategies')
|
||||
.send({
|
||||
name: 'myCustomStrategyDepreacted',
|
||||
description: 'Best strategy ever.',
|
||||
parameters: [],
|
||||
deprecated: true,
|
||||
})
|
||||
.set('Content-Type', 'application/json');
|
||||
|
||||
const { body: strategy } = await request.get(
|
||||
'/api/admin/strategies/myCustomStrategyDepreacted',
|
||||
);
|
||||
|
||||
strategy.description = 'A new desc';
|
||||
|
||||
return request
|
||||
.put('/api/admin/strategies/default')
|
||||
.send(strategy)
|
||||
.set('Content-Type', 'application/json')
|
||||
.expect(200);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user