diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-07-03 10:28:19 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2020-07-03 10:29:03 +0200 |
commit | ea7337cfdee00894792762660fa3c3412aeccccb (patch) | |
tree | 24f2b062b2d21753070e574a6e0fb4f3a531c439 | |
parent | 8491293b02ed2ec53eb0fa128161ea0b08d3def9 (diff) | |
download | PeerTube-ea7337cfdee00894792762660fa3c3412aeccccb.tar.gz PeerTube-ea7337cfdee00894792762660fa3c3412aeccccb.tar.zst PeerTube-ea7337cfdee00894792762660fa3c3412aeccccb.zip |
add check-params test for user list
fixes #2918
11 files changed, 25 insertions, 10 deletions
diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts index 51c64694f..6f340884f 100644 --- a/client/src/app/+admin/admin.component.ts +++ b/client/src/app/+admin/admin.component.ts | |||
@@ -25,12 +25,12 @@ export class AdminComponent implements OnInit { | |||
25 | { | 25 | { |
26 | label: this.i18n('Instances you follow'), | 26 | label: this.i18n('Instances you follow'), |
27 | routerLink: '/admin/follows/following-list', | 27 | routerLink: '/admin/follows/following-list', |
28 | iconName: 'sign-out' | 28 | iconName: 'following' |
29 | }, | 29 | }, |
30 | { | 30 | { |
31 | label: this.i18n('Instances following you'), | 31 | label: this.i18n('Instances following you'), |
32 | routerLink: '/admin/follows/followers-list', | 32 | routerLink: '/admin/follows/followers-list', |
33 | iconName: 'sign-in' | 33 | iconName: 'follower' |
34 | }, | 34 | }, |
35 | { | 35 | { |
36 | label: this.i18n('Video redundancies'), | 36 | label: this.i18n('Video redundancies'), |
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.html b/client/src/app/+admin/follows/following-list/following-list.component.html index a8fbf65d4..500ab13fd 100644 --- a/client/src/app/+admin/follows/following-list/following-list.component.html +++ b/client/src/app/+admin/follows/following-list/following-list.component.html | |||
@@ -15,7 +15,7 @@ | |||
15 | <span class="sr-only" i18n>Clear filters</span> | 15 | <span class="sr-only" i18n>Clear filters</span> |
16 | </div> | 16 | </div> |
17 | <a class="ml-2 follow-button" (click)="addDomainsToFollow()" (key.enter)="addDomainsToFollow()"> | 17 | <a class="ml-2 follow-button" (click)="addDomainsToFollow()" (key.enter)="addDomainsToFollow()"> |
18 | <my-global-icon iconName="add" aria-hidden="true"></my-global-icon> | 18 | <my-global-icon iconName="following" aria-hidden="true"></my-global-icon> |
19 | <ng-container i18n>Follow domain</ng-container> | 19 | <ng-container i18n>Follow domain</ng-container> |
20 | </a> | 20 | </a> |
21 | </div> | 21 | </div> |
diff --git a/client/src/app/+admin/users/user-list/user-list.component.html b/client/src/app/+admin/users/user-list/user-list.component.html index 9580a3c8a..b022331db 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.html +++ b/client/src/app/+admin/users/user-list/user-list.component.html | |||
@@ -38,7 +38,7 @@ | |||
38 | </div> | 38 | </div> |
39 | 39 | ||
40 | <a class="ml-2 add-button" routerLink="/admin/users/create"> | 40 | <a class="ml-2 add-button" routerLink="/admin/users/create"> |
41 | <my-global-icon iconName="add" aria-hidden="true"></my-global-icon> | 41 | <my-global-icon iconName="user-add" aria-hidden="true"></my-global-icon> |
42 | <ng-container i18n>Create user</ng-container> | 42 | <ng-container i18n>Create user</ng-container> |
43 | </a> | 43 | </a> |
44 | </div> | 44 | </div> |
diff --git a/client/src/app/shared/shared-icons/global-icon.component.ts b/client/src/app/shared/shared-icons/global-icon.component.ts index 7f7315f06..6527c27a6 100644 --- a/client/src/app/shared/shared-icons/global-icon.component.ts +++ b/client/src/app/shared/shared-icons/global-icon.component.ts | |||
@@ -12,6 +12,8 @@ const icons = { | |||
12 | 'history': require('!!raw-loader?!../../../assets/images/misc/history.svg').default, // material ui | 12 | 'history': require('!!raw-loader?!../../../assets/images/misc/history.svg').default, // material ui |
13 | 'subscriptions': require('!!raw-loader?!../../../assets/images/misc/subscriptions.svg').default, // material ui | 13 | 'subscriptions': require('!!raw-loader?!../../../assets/images/misc/subscriptions.svg').default, // material ui |
14 | 'playlist-add': require('!!raw-loader?!../../../assets/images/misc/playlist-add.svg').default, // material ui | 14 | 'playlist-add': require('!!raw-loader?!../../../assets/images/misc/playlist-add.svg').default, // material ui |
15 | 'follower': require('!!raw-loader?!../../../assets/images/misc/account-arrow-left.svg').default, // material ui | ||
16 | 'following': require('!!raw-loader?!../../../assets/images/misc/account-arrow-right.svg').default, // material ui | ||
15 | 17 | ||
16 | // feather icons | 18 | // feather icons |
17 | 'flag': require('!!raw-loader?!../../../assets/images/feather/flag.svg').default, | 19 | 'flag': require('!!raw-loader?!../../../assets/images/feather/flag.svg').default, |
diff --git a/client/src/app/shared/shared-main/buttons/edit-button.component.html b/client/src/app/shared/shared-main/buttons/edit-button.component.html index b852bb38a..8a97c6c1e 100644 --- a/client/src/app/shared/shared-main/buttons/edit-button.component.html +++ b/client/src/app/shared/shared-main/buttons/edit-button.component.html | |||
@@ -1,6 +1,6 @@ | |||
1 | <a class="action-button action-button-edit grey-button" [routerLink]="routerLink" i18n-title title="Edit"> | 1 | <a class="action-button action-button-edit grey-button" [routerLink]="routerLink" i18n-title title="Update"> |
2 | <my-global-icon iconName="edit" aria-hidden="true"></my-global-icon> | 2 | <my-global-icon iconName="edit" aria-hidden="true"></my-global-icon> |
3 | 3 | ||
4 | <span class="button-label" *ngIf="label">{{ label }}</span> | 4 | <span class="button-label" *ngIf="label">{{ label }}</span> |
5 | <span i18n class="button-label" *ngIf="!label">Edit</span> | 5 | <span i18n class="button-label" *ngIf="!label">Update</span> |
6 | </a> | 6 | </a> |
diff --git a/client/src/app/shared/shared-video-miniature/abstract-video-list.html b/client/src/app/shared/shared-video-miniature/abstract-video-list.html index 6df589c38..08962dff8 100644 --- a/client/src/app/shared/shared-video-miniature/abstract-video-list.html +++ b/client/src/app/shared/shared-video-miniature/abstract-video-list.html | |||
@@ -14,7 +14,7 @@ | |||
14 | </div> | 14 | </div> |
15 | 15 | ||
16 | <div class="moderation-block" *ngIf="displayModerationBlock"> | 16 | <div class="moderation-block" *ngIf="displayModerationBlock"> |
17 | <div class="c-hand" ngbDropdown container="body" placement="bottom-right auto"> | 17 | <div class="c-hand" ngbDropdown placement="bottom-right auto"> |
18 | <my-global-icon iconName="cog" ngbDropdownToggle></my-global-icon> | 18 | <my-global-icon iconName="cog" ngbDropdownToggle></my-global-icon> |
19 | 19 | ||
20 | <div role="menu" class="dropdown-menu" ngbDropdownMenu> | 20 | <div role="menu" class="dropdown-menu" ngbDropdownMenu> |
diff --git a/client/src/assets/images/misc/account-arrow-left.svg b/client/src/assets/images/misc/account-arrow-left.svg new file mode 100644 index 000000000..154bce0e9 --- /dev/null +++ b/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> | |||
diff --git a/client/src/assets/images/misc/account-arrow-right.svg b/client/src/assets/images/misc/account-arrow-right.svg new file mode 100644 index 000000000..50de9686b --- /dev/null +++ b/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> | |||
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index 839431afb..fcd828ae3 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -86,7 +86,7 @@ usersRouter.get('/', | |||
86 | usersSortValidator, | 86 | usersSortValidator, |
87 | setDefaultSort, | 87 | setDefaultSort, |
88 | setDefaultPagination, | 88 | setDefaultPagination, |
89 | asyncMiddleware(usersListValidator), | 89 | usersListValidator, |
90 | asyncMiddleware(listUsers) | 90 | asyncMiddleware(listUsers) |
91 | ) | 91 | ) |
92 | 92 | ||
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 6860a3bed..423da9bc0 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -41,10 +41,9 @@ import { Hooks } from '@server/lib/plugins/hooks' | |||
41 | const usersListValidator = [ | 41 | const usersListValidator = [ |
42 | query('blocked') | 42 | query('blocked') |
43 | .optional() | 43 | .optional() |
44 | .customSanitizer(toBooleanOrNull) | ||
45 | .isBoolean().withMessage('Should be a valid boolean banned state'), | 44 | .isBoolean().withMessage('Should be a valid boolean banned state'), |
46 | 45 | ||
47 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 46 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
48 | logger.debug('Checking usersList parameters', { parameters: req.query }) | 47 | logger.debug('Checking usersList parameters', { parameters: req.query }) |
49 | 48 | ||
50 | if (areValidationErrors(req, res)) return | 49 | if (areValidationErrors(req, res)) return |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 74f0a2d3f..2fea2cbd5 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -155,6 +155,18 @@ describe('Test users API validators', function () { | |||
155 | await checkBadSortPagination(server.url, path, server.accessToken) | 155 | await checkBadSortPagination(server.url, path, server.accessToken) |
156 | }) | 156 | }) |
157 | 157 | ||
158 | it('Should fail with a bad blocked/banned user filter', async function () { | ||
159 | await makeGetRequest({ | ||
160 | url: server.url, | ||
161 | path, | ||
162 | query: { | ||
163 | blocked: 42 | ||
164 | }, | ||
165 | token: server.accessToken, | ||
166 | statusCodeExpected: 400 | ||
167 | }) | ||
168 | }) | ||
169 | |||
158 | it('Should fail with a non authenticated user', async function () { | 170 | it('Should fail with a non authenticated user', async function () { |
159 | await makeGetRequest({ | 171 | await makeGetRequest({ |
160 | url: server.url, | 172 | url: server.url, |