Browse Source

add check-params test for user list

fixes #2918
Rigel Kent 3 years ago
parent
commit
ea7337cfde

+ 2 - 2
client/src/app/+admin/admin.component.ts

@@ -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'),

+ 1 - 1
client/src/app/+admin/follows/following-list/following-list.component.html

@@ -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>

+ 1 - 1
client/src/app/+admin/users/user-list/user-list.component.html

@@ -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>

+ 2 - 0
client/src/app/shared/shared-icons/global-icon.component.ts

@@ -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,

+ 2 - 2
client/src/app/shared/shared-main/buttons/edit-button.component.html

@@ -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>

+ 1 - 1
client/src/app/shared/shared-video-miniature/abstract-video-list.html

@@ -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>

+ 1 - 0
client/src/assets/images/misc/account-arrow-left.svg

@@ -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>

+ 1 - 0
client/src/assets/images/misc/account-arrow-right.svg

@@ -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>

+ 1 - 1
server/controllers/api/users/index.ts

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

+ 1 - 2
server/middlewares/validators/users.ts

@@ -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

+ 12 - 0
server/tests/api/check-params/users.ts

@@ -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,