mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Using Joi.object when configuring route validation (#24596)
* Using Joi.object when configuring route validation * Adding forgotten API * Fixing test
This commit is contained in:
parent
157477a2d7
commit
70f1a4094e
7 changed files with 18 additions and 18 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
import Joi from 'joi';
|
||||
|
||||
export const userSchema = {
|
||||
export const userSchema = Joi.object({
|
||||
username: Joi.string().required(),
|
||||
password: Joi.string(),
|
||||
roles: Joi.array().items(Joi.string()),
|
||||
|
@ -14,4 +14,4 @@ export const userSchema = {
|
|||
email: Joi.string().allow(null, ''),
|
||||
metadata: Joi.object(),
|
||||
enabled: Joi.boolean().default(true)
|
||||
};
|
||||
});
|
||||
|
|
|
@ -62,10 +62,10 @@ describe('Authentication routes', () => {
|
|||
expect(loginRoute.config).to.eql({
|
||||
auth: false,
|
||||
validate: {
|
||||
payload: {
|
||||
payload: Joi.object({
|
||||
username: Joi.string().required(),
|
||||
password: Joi.string().required()
|
||||
}
|
||||
})
|
||||
},
|
||||
response: {
|
||||
emptyStatusCode: 204,
|
||||
|
@ -304,10 +304,10 @@ describe('Authentication routes', () => {
|
|||
expect(samlAcsRoute.config).to.eql({
|
||||
auth: false,
|
||||
validate: {
|
||||
payload: {
|
||||
payload: Joi.object({
|
||||
SAMLResponse: Joi.string().required(),
|
||||
RelayState: Joi.string().allow('')
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -60,10 +60,10 @@ describe('User routes', () => {
|
|||
expect(changePasswordRoute.config).to.have.property('pre');
|
||||
expect(changePasswordRoute.config.pre).to.have.length(1);
|
||||
expect(changePasswordRoute.config.validate).to.eql({
|
||||
payload: {
|
||||
payload: Joi.object({
|
||||
password: Joi.string(),
|
||||
newPassword: Joi.string().required()
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ export function initAuthenticateApi(server) {
|
|||
config: {
|
||||
auth: false,
|
||||
validate: {
|
||||
payload: {
|
||||
payload: Joi.object({
|
||||
username: Joi.string().required(),
|
||||
password: Joi.string().required()
|
||||
}
|
||||
})
|
||||
},
|
||||
response: {
|
||||
emptyStatusCode: 204,
|
||||
|
@ -58,10 +58,10 @@ export function initAuthenticateApi(server) {
|
|||
config: {
|
||||
auth: false,
|
||||
validate: {
|
||||
payload: {
|
||||
payload: Joi.object({
|
||||
SAMLResponse: Joi.string().required(),
|
||||
RelayState: Joi.string().allow('')
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
async handler(request, h) {
|
||||
|
|
|
@ -121,10 +121,10 @@ export function initUsersApi(server) {
|
|||
},
|
||||
config: {
|
||||
validate: {
|
||||
payload: {
|
||||
payload: Joi.object({
|
||||
password: Joi.string(),
|
||||
newPassword: Joi.string().required()
|
||||
}
|
||||
})
|
||||
},
|
||||
pre: [routePreCheckLicenseFn]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue