diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-28 16:15:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-10-28 16:34:08 +0200 |
commit | 9e5cf66be7ad897e106f283bee73a165c72e74de (patch) | |
tree | 16de6f775c412281236b8f99be8e5118e5a6ff71 /server | |
parent | 3f9decbd01d25f1b1805e2764dff4beae7d36c19 (diff) | |
download | PeerTube-9e5cf66be7ad897e106f283bee73a165c72e74de.tar.gz PeerTube-9e5cf66be7ad897e106f283bee73a165c72e74de.tar.zst PeerTube-9e5cf66be7ad897e106f283bee73a165c72e74de.zip |
Breaking API: Consistency with role id/label
Diffstat (limited to 'server')
-rw-r--r-- | server/models/user/user.ts | 6 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 6 | ||||
-rw-r--r-- | server/tests/plugins/external-auth.ts | 6 | ||||
-rw-r--r-- | server/tests/plugins/id-and-pass-auth.ts | 8 |
4 files changed, 14 insertions, 12 deletions
diff --git a/server/models/user/user.ts b/server/models/user/user.ts index 34329580b..f70feed73 100644 --- a/server/models/user/user.ts +++ b/server/models/user/user.ts | |||
@@ -891,8 +891,10 @@ export class UserModel extends Model<Partial<AttributesOnly<UserModel>>> { | |||
891 | autoPlayNextVideoPlaylist: this.autoPlayNextVideoPlaylist, | 891 | autoPlayNextVideoPlaylist: this.autoPlayNextVideoPlaylist, |
892 | videoLanguages: this.videoLanguages, | 892 | videoLanguages: this.videoLanguages, |
893 | 893 | ||
894 | role: this.role, | 894 | role: { |
895 | roleLabel: USER_ROLE_LABELS[this.role], | 895 | id: this.role, |
896 | label: USER_ROLE_LABELS[this.role] | ||
897 | }, | ||
896 | 898 | ||
897 | videoQuota: this.videoQuota, | 899 | videoQuota: this.videoQuota, |
898 | videoQuotaDaily: this.videoQuotaDaily, | 900 | videoQuotaDaily: this.videoQuotaDaily, |
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 3952a7aed..421b3ce16 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -219,7 +219,7 @@ describe('Test users', function () { | |||
219 | expect(user.email).to.equal('user_1@example.com') | 219 | expect(user.email).to.equal('user_1@example.com') |
220 | expect(user.nsfwPolicy).to.equal('display') | 220 | expect(user.nsfwPolicy).to.equal('display') |
221 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | 221 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) |
222 | expect(user.roleLabel).to.equal('User') | 222 | expect(user.role.label).to.equal('User') |
223 | expect(user.id).to.be.a('number') | 223 | expect(user.id).to.be.a('number') |
224 | expect(user.account.displayName).to.equal('user_1') | 224 | expect(user.account.displayName).to.equal('user_1') |
225 | expect(user.account.description).to.be.null | 225 | expect(user.account.description).to.be.null |
@@ -277,7 +277,7 @@ describe('Test users', function () { | |||
277 | const user = data[0] | 277 | const user = data[0] |
278 | expect(user.username).to.equal('root') | 278 | expect(user.username).to.equal('root') |
279 | expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com') | 279 | expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com') |
280 | expect(user.roleLabel).to.equal('Administrator') | 280 | expect(user.role.label).to.equal('Administrator') |
281 | expect(user.nsfwPolicy).to.equal('display') | 281 | expect(user.nsfwPolicy).to.equal('display') |
282 | }) | 282 | }) |
283 | 283 | ||
@@ -531,7 +531,7 @@ describe('Test users', function () { | |||
531 | expect(user.emailVerified).to.be.true | 531 | expect(user.emailVerified).to.be.true |
532 | expect(user.nsfwPolicy).to.equal('do_not_list') | 532 | expect(user.nsfwPolicy).to.equal('do_not_list') |
533 | expect(user.videoQuota).to.equal(42) | 533 | expect(user.videoQuota).to.equal(42) |
534 | expect(user.roleLabel).to.equal('Moderator') | 534 | expect(user.role.label).to.equal('Moderator') |
535 | expect(user.id).to.be.a('number') | 535 | expect(user.id).to.be.a('number') |
536 | expect(user.adminFlags).to.equal(UserAdminFlag.NONE) | 536 | expect(user.adminFlags).to.equal(UserAdminFlag.NONE) |
537 | expect(user.pluginAuth).to.equal('toto') | 537 | expect(user.pluginAuth).to.equal('toto') |
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index e08b83791..437777e90 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts | |||
@@ -155,7 +155,7 @@ describe('Test external auth plugins', function () { | |||
155 | expect(body.username).to.equal('cyan') | 155 | expect(body.username).to.equal('cyan') |
156 | expect(body.account.displayName).to.equal('cyan') | 156 | expect(body.account.displayName).to.equal('cyan') |
157 | expect(body.email).to.equal('cyan@example.com') | 157 | expect(body.email).to.equal('cyan@example.com') |
158 | expect(body.role).to.equal(UserRole.USER) | 158 | expect(body.role.id).to.equal(UserRole.USER) |
159 | } | 159 | } |
160 | }) | 160 | }) |
161 | 161 | ||
@@ -177,7 +177,7 @@ describe('Test external auth plugins', function () { | |||
177 | expect(body.username).to.equal('kefka') | 177 | expect(body.username).to.equal('kefka') |
178 | expect(body.account.displayName).to.equal('Kefka Palazzo') | 178 | expect(body.account.displayName).to.equal('Kefka Palazzo') |
179 | expect(body.email).to.equal('kefka@example.com') | 179 | expect(body.email).to.equal('kefka@example.com') |
180 | expect(body.role).to.equal(UserRole.ADMINISTRATOR) | 180 | expect(body.role.id).to.equal(UserRole.ADMINISTRATOR) |
181 | } | 181 | } |
182 | }) | 182 | }) |
183 | 183 | ||
@@ -237,7 +237,7 @@ describe('Test external auth plugins', function () { | |||
237 | expect(body.username).to.equal('cyan') | 237 | expect(body.username).to.equal('cyan') |
238 | expect(body.account.displayName).to.equal('Cyan Garamonde') | 238 | expect(body.account.displayName).to.equal('Cyan Garamonde') |
239 | expect(body.account.description).to.equal('Retainer to the king of Doma') | 239 | expect(body.account.description).to.equal('Retainer to the king of Doma') |
240 | expect(body.role).to.equal(UserRole.USER) | 240 | expect(body.role.id).to.equal(UserRole.USER) |
241 | }) | 241 | }) |
242 | 242 | ||
243 | it('Should not update an external auth email', async function () { | 243 | it('Should not update an external auth email', async function () { |
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index 85faac5a8..fc24a5656 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts | |||
@@ -48,7 +48,7 @@ describe('Test id and pass auth plugins', function () { | |||
48 | 48 | ||
49 | expect(body.username).to.equal('spyro') | 49 | expect(body.username).to.equal('spyro') |
50 | expect(body.account.displayName).to.equal('Spyro the Dragon') | 50 | expect(body.account.displayName).to.equal('Spyro the Dragon') |
51 | expect(body.role).to.equal(UserRole.USER) | 51 | expect(body.role.id).to.equal(UserRole.USER) |
52 | }) | 52 | }) |
53 | 53 | ||
54 | it('Should login Crash, create the user and use the token', async function () { | 54 | it('Should login Crash, create the user and use the token', async function () { |
@@ -63,7 +63,7 @@ describe('Test id and pass auth plugins', function () { | |||
63 | 63 | ||
64 | expect(body.username).to.equal('crash') | 64 | expect(body.username).to.equal('crash') |
65 | expect(body.account.displayName).to.equal('Crash Bandicoot') | 65 | expect(body.account.displayName).to.equal('Crash Bandicoot') |
66 | expect(body.role).to.equal(UserRole.MODERATOR) | 66 | expect(body.role.id).to.equal(UserRole.MODERATOR) |
67 | } | 67 | } |
68 | }) | 68 | }) |
69 | 69 | ||
@@ -79,7 +79,7 @@ describe('Test id and pass auth plugins', function () { | |||
79 | 79 | ||
80 | expect(body.username).to.equal('laguna') | 80 | expect(body.username).to.equal('laguna') |
81 | expect(body.account.displayName).to.equal('laguna') | 81 | expect(body.account.displayName).to.equal('laguna') |
82 | expect(body.role).to.equal(UserRole.USER) | 82 | expect(body.role.id).to.equal(UserRole.USER) |
83 | } | 83 | } |
84 | }) | 84 | }) |
85 | 85 | ||
@@ -129,7 +129,7 @@ describe('Test id and pass auth plugins', function () { | |||
129 | expect(body.username).to.equal('crash') | 129 | expect(body.username).to.equal('crash') |
130 | expect(body.account.displayName).to.equal('Beautiful Crash') | 130 | expect(body.account.displayName).to.equal('Beautiful Crash') |
131 | expect(body.account.description).to.equal('Mutant eastern barred bandicoot') | 131 | expect(body.account.description).to.equal('Mutant eastern barred bandicoot') |
132 | expect(body.role).to.equal(UserRole.MODERATOR) | 132 | expect(body.role.id).to.equal(UserRole.MODERATOR) |
133 | }) | 133 | }) |
134 | 134 | ||
135 | it('Should reject token of laguna by the plugin hook', async function () { | 135 | it('Should reject token of laguna by the plugin hook', async function () { |