From 3b4e2a5f9df1228a4a847e767fef6037ac9f3943 Mon Sep 17 00:00:00 2001 From: Michal Orlik Date: Wed, 19 Jun 2024 14:16:01 +0200 Subject: [PATCH] add scopes --- ...ission_allows_then_it_should_be_allowed.js | 36 ++++++++++++------- ...ually_included_users_with_link_disabled.js | 33 +++++++++++------ test/tests/permissions/check.js | 33 +++++++++++------ 3 files changed, 68 insertions(+), 34 deletions(-) diff --git a/test/tests/moderation/#5583_if_some_permission_allows_then_it_should_be_allowed.js b/test/tests/moderation/#5583_if_some_permission_allows_then_it_should_be_allowed.js index 1cc5362a7fb..840b9ff6ed8 100644 --- a/test/tests/moderation/#5583_if_some_permission_allows_then_it_should_be_allowed.js +++ b/test/tests/moderation/#5583_if_some_permission_allows_then_it_should_be_allowed.js @@ -29,7 +29,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 0, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -40,7 +41,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 1, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -51,7 +53,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 2, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -62,7 +65,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 3, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -73,7 +77,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 4, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); }); @@ -97,7 +102,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 0, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.CASTERS] = true; @@ -110,7 +116,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 1, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.MODERATORS] = true; @@ -122,7 +129,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 2, userIds: [user.viewer.userId], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -133,7 +141,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 2, userIds: [user.viewer.userId], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -144,7 +153,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 3, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.SUBSCRIBERS] = true; @@ -157,7 +167,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 4, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.VIP] = true; @@ -170,7 +181,8 @@ describe('#5583 - If lower permission allows, then it should be allowed - @func1 isWaterfallAllowed: true, order: 5, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.VIEWERS] = true; diff --git a/test/tests/moderation/discord#868236481406324747_manually_included_users_with_link_disabled.js b/test/tests/moderation/discord#868236481406324747_manually_included_users_with_link_disabled.js index c3cb6185b9d..b7e601a77eb 100644 --- a/test/tests/moderation/discord#868236481406324747_manually_included_users_with_link_disabled.js +++ b/test/tests/moderation/discord#868236481406324747_manually_included_users_with_link_disabled.js @@ -28,7 +28,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 0, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -39,7 +40,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 1, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -50,7 +52,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 2, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -61,7 +64,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 3, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -72,7 +76,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 4, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); }); @@ -96,7 +101,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 0, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.CASTERS] = true; @@ -109,7 +115,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 1, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.MODERATORS] = true; @@ -121,7 +128,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 2, userIds: [user.viewer.userId], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); await AppDataSource.getRepository(Permissions).insert({ @@ -132,7 +140,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 3, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.SUBSCRIBERS] = true; @@ -145,7 +154,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 4, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.VIP] = true; @@ -158,7 +168,8 @@ describe('discord#868236481406324747 - Manually included users with link disable isWaterfallAllowed: true, order: 5, userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); moderation.__permission_based__cLinksEnabled[defaultPermissions.VIEWERS] = true; diff --git a/test/tests/permissions/check.js b/test/tests/permissions/check.js index 345446f8925..846d7545ca1 100644 --- a/test/tests/permissions/check.js +++ b/test/tests/permissions/check.js @@ -113,7 +113,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'none', userIds: [6], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [], }); }); @@ -146,7 +147,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '==', type: 'points', value: 100, }], @@ -181,7 +183,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '==', type: 'watched', value: 100, }], @@ -216,7 +219,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '>=', type: 'tips', value: 100, }], @@ -251,7 +255,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '>=', type: 'bits', value: 100, }], @@ -286,7 +291,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '>=', type: 'messages', value: 100, }], @@ -321,7 +327,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '>=', type: 'subtier', value: 2, }], @@ -356,7 +363,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '>=', type: 'subcumulativemonths', value: 2, }], @@ -391,7 +399,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '>=', type: 'substreakmonths', value: 2, }], @@ -426,7 +435,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '==', type: 'ranks', value: 'Lorem Ipsum', }], @@ -461,7 +471,8 @@ describe('Permissions - check() - @func1', () => { isWaterfallAllowed: false, automation: 'viewers', userIds: [], - excludeUserIds: [], + scopes: [], +excludeUserIds: [], filters: [{ comparator: '==', type: 'level', value: 5, }],