mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-22 01:16:07 +02:00
parent
187798262e
commit
c500128f07
@ -3,29 +3,33 @@
|
|||||||
const joi = require('joi');
|
const joi = require('joi');
|
||||||
const { nameType } = require('../routes/admin-api/util');
|
const { nameType } = require('../routes/admin-api/util');
|
||||||
|
|
||||||
const strategySchema = joi.object().keys({
|
const strategySchema = joi
|
||||||
name: nameType,
|
.object()
|
||||||
editable: joi.boolean().default(true),
|
.keys({
|
||||||
description: joi
|
name: nameType,
|
||||||
.string()
|
editable: joi.boolean().default(true),
|
||||||
.allow(null)
|
deprecated: joi.boolean().default(false),
|
||||||
.allow('')
|
description: joi
|
||||||
.optional(),
|
.string()
|
||||||
parameters: joi
|
.allow(null)
|
||||||
.array()
|
.allow('')
|
||||||
.required()
|
.optional(),
|
||||||
.items(
|
parameters: joi
|
||||||
joi.object().keys({
|
.array()
|
||||||
name: joi.string().required(),
|
.required()
|
||||||
type: joi.string().required(),
|
.items(
|
||||||
description: joi
|
joi.object().keys({
|
||||||
.string()
|
name: joi.string().required(),
|
||||||
.allow(null)
|
type: joi.string().required(),
|
||||||
.allow('')
|
description: joi
|
||||||
.optional(),
|
.string()
|
||||||
required: joi.boolean(),
|
.allow(null)
|
||||||
}),
|
.allow('')
|
||||||
),
|
.optional(),
|
||||||
});
|
required: joi.boolean(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
})
|
||||||
|
.options({ allowUnknown: false, stripUnknown: true, abortEarly: false });
|
||||||
|
|
||||||
module.exports = strategySchema;
|
module.exports = strategySchema;
|
||||||
|
@ -172,3 +172,30 @@ test.serial('cannot deprecate default strategy', async t => {
|
|||||||
const request = await setupApp(stores);
|
const request = await setupApp(stores);
|
||||||
await request.post('/api/admin/strategies/default/deprecate').expect(403);
|
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