1
0
Fork 0

add check-params test for user list

fixes #2918
This commit is contained in:
Rigel Kent 2020-07-03 10:28:19 +02:00
parent 8491293b02
commit ea7337cfde
No known key found for this signature in database
GPG Key ID: 5E53E96A494E452F
11 changed files with 25 additions and 10 deletions

View File

@ -25,12 +25,12 @@ export class AdminComponent implements OnInit {
{
label: this.i18n('Instances you follow'),
routerLink: '/admin/follows/following-list',
iconName: 'sign-out'
iconName: 'following'
},
{
label: this.i18n('Instances following you'),
routerLink: '/admin/follows/followers-list',
iconName: 'sign-in'
iconName: 'follower'
},
{
label: this.i18n('Video redundancies'),

View File

@ -15,7 +15,7 @@
<span class="sr-only" i18n>Clear filters</span>
</div>
<a class="ml-2 follow-button" (click)="addDomainsToFollow()" (key.enter)="addDomainsToFollow()">
<my-global-icon iconName="add" aria-hidden="true"></my-global-icon>
<my-global-icon iconName="following" aria-hidden="true"></my-global-icon>
<ng-container i18n>Follow domain</ng-container>
</a>
</div>

View File

@ -38,7 +38,7 @@
</div>
<a class="ml-2 add-button" routerLink="/admin/users/create">
<my-global-icon iconName="add" aria-hidden="true"></my-global-icon>
<my-global-icon iconName="user-add" aria-hidden="true"></my-global-icon>
<ng-container i18n>Create user</ng-container>
</a>
</div>

View File

@ -12,6 +12,8 @@ const icons = {
'history': require('!!raw-loader?!../../../assets/images/misc/history.svg').default, // material ui
'subscriptions': require('!!raw-loader?!../../../assets/images/misc/subscriptions.svg').default, // material ui
'playlist-add': require('!!raw-loader?!../../../assets/images/misc/playlist-add.svg').default, // material ui
'follower': require('!!raw-loader?!../../../assets/images/misc/account-arrow-left.svg').default, // material ui
'following': require('!!raw-loader?!../../../assets/images/misc/account-arrow-right.svg').default, // material ui
// feather icons
'flag': require('!!raw-loader?!../../../assets/images/feather/flag.svg').default,

View File

@ -1,6 +1,6 @@
<a class="action-button action-button-edit grey-button" [routerLink]="routerLink" i18n-title title="Edit">
<a class="action-button action-button-edit grey-button" [routerLink]="routerLink" i18n-title title="Update">
<my-global-icon iconName="edit" aria-hidden="true"></my-global-icon>
<span class="button-label" *ngIf="label">{{ label }}</span>
<span i18n class="button-label" *ngIf="!label">Edit</span>
<span i18n class="button-label" *ngIf="!label">Update</span>
</a>

View File

@ -14,7 +14,7 @@
</div>
<div class="moderation-block" *ngIf="displayModerationBlock">
<div class="c-hand" ngbDropdown container="body" placement="bottom-right auto">
<div class="c-hand" ngbDropdown placement="bottom-right auto">
<my-global-icon iconName="cog" ngbDropdownToggle></my-global-icon>
<div role="menu" class="dropdown-menu" ngbDropdownMenu>

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1em" height="1em" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path d="M18 21l-3-3l3-3v2h4v2h-4v2M10 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c1.15 0 2.25.12 3.24.34A5.964 5.964 0 0 0 12 18c0 .7.12 1.37.34 2H2v-2c0-2.21 3.58-4 8-4z" fill="currentColor" class="material"/></svg>

After

Width:  |  Height:  |  Size: 539 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1em" height="1em" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path d="M19 21v-2h-4v-2h4v-2l3 3l-3 3M10 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c1.15 0 2.25.12 3.24.34A5.964 5.964 0 0 0 12 18c0 .7.12 1.37.34 2H2v-2c0-2.21 3.58-4 8-4z" fill="currentColor" class="material"/></svg>

After

Width:  |  Height:  |  Size: 542 B

View File

@ -86,7 +86,7 @@ usersRouter.get('/',
usersSortValidator,
setDefaultSort,
setDefaultPagination,
asyncMiddleware(usersListValidator),
usersListValidator,
asyncMiddleware(listUsers)
)

View File

@ -41,10 +41,9 @@ import { Hooks } from '@server/lib/plugins/hooks'
const usersListValidator = [
query('blocked')
.optional()
.customSanitizer(toBooleanOrNull)
.isBoolean().withMessage('Should be a valid boolean banned state'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersList parameters', { parameters: req.query })
if (areValidationErrors(req, res)) return

View File

@ -155,6 +155,18 @@ describe('Test users API validators', function () {
await checkBadSortPagination(server.url, path, server.accessToken)
})
it('Should fail with a bad blocked/banned user filter', async function () {
await makeGetRequest({
url: server.url,
path,
query: {
blocked: 42
},
token: server.accessToken,
statusCodeExpected: 400
})
})
it('Should fail with a non authenticated user', async function () {
await makeGetRequest({
url: server.url,