Skip to content

Commit

Permalink
PB-33320 Cover PermissionCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricalfonsi committed May 9, 2024
1 parent 3e94fd9 commit 80b5c3d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "passbolt-styleguide",
"version": "4.8.0-alpha.6",
"version": "4.8.0-alpha.7",
"license": "AGPL-3.0",
"copyright": "Copyright 2023 Passbolt SA",
"description": "Passbolt styleguide contains common styling assets used by the different sites, plugin, etc.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.passbolt.com Passbolt(tm)
* @since 4.8.0
*/


import {defaultPermissionDto} from "./permissionEntity.test.data";

/**
* Build dtos.
* @param {number} [count=10] The number of dtos.
* @returns {object}
*/
export const defaultPermissionsDtos = (count = 10) => {
const dtos = [];
const acoForeignKey = crypto.randomUUID();
for (let i = 0; i < count; i++) {
const groupDto = defaultPermissionDto({aco_foreign_key: acoForeignKey});
dtos.push(groupDto);
}
return dtos;
};

25 changes: 21 additions & 4 deletions src/shared/models/entity/permission/permissionEntity.test.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,29 @@ export const minimumPermissionDto = (data = {}) => ({
...data
});

export const ownerMinimalFolderPermissionDto = (data = {}) => minimumPermissionDto({
aco: "Folder",
...data
});

export const updateMinimalFolderPermissionDto = (data = {}) => minimumPermissionDto({
aco: "Folder",
type: 7,
...data
});

export const readMinimalFolderPermissionDto = (data = {}) => minimumPermissionDto({
aco: "Folder",
type: 1,
...data
});

/**
* Build default permissiondto.
* @param {object} data The data to override the default dto.
* @param {Object} [options]
* @param {Object} [options.withUser=false] Add user default dto.
* @param {Object} [options.withGroup=false] Add group default dto.
* @param {Object|boolean} [options.withUser=false] Add user default dto. Can be used to pass parameter to the user factory.
* @param {Object|boolean} [options.withGroup=false] Add group default dto. Can be used to pass parameter to the group factory.
* @returns {object}
*/
export const defaultPermissionDto = (data = {}, options = {}) => {
Expand All @@ -46,11 +63,11 @@ export const defaultPermissionDto = (data = {}, options = {}) => {
};

if (!data.user && options?.withUser) {
defaultData.user = defaultUserDto({id: defaultData.aro_foreign_key});
defaultData.user = defaultUserDto({id: defaultData.aro_foreign_key}, options.withUser);
}

if (!data.group && options?.withGroup) {
defaultData.group = defaultGroupDto({id: defaultData.aro_foreign_key});
defaultData.group = defaultGroupDto({id: defaultData.aro_foreign_key}, options.withGroup);
}

return defaultData;
Expand Down

0 comments on commit 80b5c3d

Please sign in to comment.