Skip to content

Commit

Permalink
Deploying to gh-pages from @ 737428b 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
dlen committed Sep 4, 2024
1 parent 6cd617a commit bab2a8c
Show file tree
Hide file tree
Showing 52 changed files with 944 additions and 278 deletions.
2 changes: 1 addition & 1 deletion iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,4 @@



window['STORIES'] = [{"titlePrefix":"","directory":"./.storybook/stories","files":"**/*.stories.mdx","importPathMatcher":"^\\.[\\\\/](?:\\.storybook\\/stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.mdx)$"},{"titlePrefix":"","directory":"./.storybook/stories","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:\\.storybook\\/stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx))$"},{"titlePrefix":"","directory":"./src","files":"**/*.stories.mdx","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.mdx)$"},{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx))$"}];</script><script src="runtime~main.27ec7551.iframe.bundle.js"></script><script src="832.1f4b3c69.iframe.bundle.js"></script><script src="main.b595d743.iframe.bundle.js"></script></body></html>
window['STORIES'] = [{"titlePrefix":"","directory":"./.storybook/stories","files":"**/*.stories.mdx","importPathMatcher":"^\\.[\\\\/](?:\\.storybook\\/stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.mdx)$"},{"titlePrefix":"","directory":"./.storybook/stories","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:\\.storybook\\/stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx))$"},{"titlePrefix":"","directory":"./src","files":"**/*.stories.mdx","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.mdx)$"},{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx))$"}];</script><script src="runtime~main.27ec7551.iframe.bundle.js"></script><script src="832.1f4b3c69.iframe.bundle.js"></script><script src="main.773b47fe.iframe.bundle.js"></script></body></html>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,20 @@
* @since 4.6.1
*/

/**
* 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.7.0
*/

/**
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
Expand Down
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"generatedAt":1725376932936,"builder":{"name":"webpack5"},"hasCustomBabel":false,"hasCustomWebpack":false,"hasStaticDirs":true,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"10.7.0"},"language":"javascript","storybookPackages":{},"framework":{},"addons":{"@storybook/addon-links":{"version":"6.5.16"},"@storybook/addon-essentials":{"options":{"backgrounds":false},"version":"6.5.16"}}}
{"generatedAt":1725443234109,"builder":{"name":"webpack5"},"hasCustomBabel":false,"hasCustomWebpack":false,"hasStaticDirs":true,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"10.7.0"},"language":"javascript","storybookPackages":{},"framework":{},"addons":{"@storybook/addon-links":{"version":"6.5.16"},"@storybook/addon-essentials":{"options":{"backgrounds":false},"version":"6.5.16"}}}
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class DisplayEmailNotificationsAdministration extends React.Component {
<input type="checkbox" className="toggle-switch-checkbox checkbox" name="passwordExpiryExpiredUser" disabled={this.hasAllInputDisabled()}
onChange={this.handleInputChange} checked={settings.passwordExpiryExpiredUser} id="password-expiry-expired-user-toggle-button"/>
<label className="text" htmlFor="password-expiry-expired-user-toggle-button">
<Trans>When a password is expired, notify the owners to change it.</Trans>
<Trans>When a permission is revoked on a consumed password, notify the owner(s) to change it.</Trans>
</label>
</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions react-extension/components/Resource/AddTotp/AddTotp.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class AddTotp extends Component {
const error = this.state.errors?.getError('period');
if (error?.type) {
return this.translate("TOTP expiry is required.");
} else if (error?.gte) {
} else if (error?.minimum) {
return this.translate("TOTP expiry must be greater than 0.");
}
return null;
Expand All @@ -264,7 +264,7 @@ class AddTotp extends Component {
const error = this.state.errors?.getError('digits');
if (error?.type) {
return this.translate("TOTP length is required.");
} else if (error?.gte || error?.lte) {
} else if (error?.minimum || error?.maximum) {
return this.translate("TOTP length must be between 6 and 8.");
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class CreateStandaloneTotp extends Component {
const error = this.state.errors?.getError('period');
if (error?.type) {
return this.translate("TOTP expiry is required.");
} else if (error?.gte) {
} else if (error?.minimum) {
return this.translate("TOTP expiry must be greater than 0.");
}
return null;
Expand All @@ -279,7 +279,7 @@ class CreateStandaloneTotp extends Component {
const error = this.state.errors?.getError('digits');
if (error?.type) {
return this.translate("TOTP length is required.");
} else if (error?.gte || error?.lte) {
} else if (error?.minimum || error?.maximum) {
return this.translate("TOTP length must be between 6 and 8.");
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class EditStandaloneTotp extends Component {
const error = this.state.errors?.getError('period');
if (error?.type) {
return this.translate("TOTP expiry is required.");
} else if (error?.gte) {
} else if (error?.minimum) {
return this.translate("TOTP expiry must be greater than 0.");
}
return null;
Expand All @@ -332,7 +332,7 @@ class EditStandaloneTotp extends Component {
const error = this.state.errors?.getError('digits');
if (error?.type) {
return this.translate("TOTP length is required.");
} else if (error?.gte || error?.lte) {
} else if (error?.minimum || error?.maximum) {
return this.translate("TOTP length must be between 6 and 8.");
}
return null;
Expand Down
4 changes: 2 additions & 2 deletions react-extension/components/Resource/EditTotp/EditTotp.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class EditTotp extends Component {
const error = this.state.errors?.getError('period');
if (error?.type) {
return this.translate("TOTP expiry is required.");
} else if (error?.gte) {
} else if (error?.minimum) {
return this.translate("TOTP expiry must be greater than 0.");
}
return null;
Expand All @@ -264,7 +264,7 @@ class EditTotp extends Component {
const error = this.state.errors?.getError('digits');
if (error?.type) {
return this.translate("TOTP length is required.");
} else if (error?.gte || error?.lte) {
} else if (error?.minimum || error?.maximum) {
return this.translate("TOTP length must be between 6 and 8.");
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
* @since 2.11.0
*/

import {commentsMock, defaultAppContext, defaultProps, tooLongComment} from "./AddResourceComment.test.data";
import {defaultAppContext, defaultProps, tooLongComment} from "./AddResourceComment.test.data";
import DisplayResourceDetailsCommentPage from "../../ResourceDetails/DisplayResourceDetails/DisplayResourceDetailsComment.test.page";
import {ActionFeedbackContext} from "../../../contexts/ActionFeedbackContext";
import {defaultCommentCollectionDto} from "../../../../shared/models/entity/comment/commentEntityCollection.test.data";

/**
* Unit tests on AddComponent in regard of specifications
Expand All @@ -32,7 +33,7 @@ describe("Add comments", () => {
// The mocked context port request
const mockContextRequest = implementation => jest.spyOn(context.port, 'request').mockImplementation(implementation);
const noneCommentFoundRequestMockImpl = jest.fn(() => Promise.resolve([]));
const commentsFoundRequestMockImpl = jest.fn(() => Promise.resolve(commentsMock));
const commentsFoundRequestMockImpl = jest.fn(() => Promise.resolve(defaultCommentCollectionDto()));

describe("Scenario: As LU I should start editing if there is no comment yet", () => {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,98 +67,3 @@ export function defaultProps() {
}
};
}

/**
* Mocked list of comments
*/
export const commentsMock = [{
children: [],
content: "This is a comment",
created: "2020-08-22T13:13:19+00:00",
created_by: "f848277c-5398-58f8-a82a-72397af2d450",
creator: {
id: "f848277c-5398-58f8-a82a-72397af2d450",
role_id: "c4870358-e32f-41ce-999b-8f80c9b0d17f",
active: true,
deleted: false,
last_logged_in: "",
profile: {
avatar: {url: {medium: "img/avatar/user_medium.png", small: "img/avatar/user.png"}},
created: "2020-09-01T13:11:08+00:00",
first_name: "Ada",
id: "f6b23982-d3dd-4f8b-9bcc-f3a473edffc2",
last_name: "Lovelace",
modified: "2020-09-01T13:11:08+00:00",
user_id: "f848277c-5398-58f8-a82a-72397af2d450",
},
},
role_id: "c4870358-e32f-41ce-999b-8f80c9b0d17f",
username: "[email protected]",
foreign_key: "f302754f-f290-42a6-9ea3-7049c6d4dbe3",
foreign_model: "Resource",
id: "9e56b21f-36f1-44a7-a363-1c6ccbbf09e2",
modified: "2020-09-01T13:13:19+00:00",
modified_by: "5247399c-6c8a-47f0-8880-aa854e01e554",
parent_id: null,
user_id: "f848277c-5398-58f8-a82a-72397af2d450",
}, {
children: [],
content: "This is another comment",
created: "2020-09-01T13:13:19+00:00",
created_by: "5247399c-6c8a-47f0-8880-aa854e01e554",
creator: {
id: "5247399c-6c8a-47f0-8880-aa854e01e554",
role_id: "c4870358-e32f-41ce-999b-8f80c9b0d17f",
active: true,
deleted: false,
last_logged_in: "",
profile: {
avatar: {url: {medium: "img/avatar/user_medium.png", small: "img/avatar/user.png"}},
created: "2020-09-01T13:11:08+00:00",
first_name: "Carol",
id: "f6b23982-d3dd-4f8b-9bcc-f3a473edffc2",
last_name: "Shaw",
modified: "2020-09-01T13:11:08+00:00",
user_id: "5247399c-6c8a-47f0-8880-aa854e01e554",
},
},
role_id: "c4870358-e32f-41ce-999b-8f80c9b0d17f",
username: "[email protected]",
foreign_key: "f302754f-f290-42a6-9ea3-7049c6d4dbe3",
foreign_model: "Resource",
id: "9e56b21f-36f1-44a7-a363-1c6ccbbf09e2",
modified: "2020-09-01T13:13:19+00:00",
modified_by: "5247399c-6c8a-47f0-8880-aa854e01e554",
parent_id: null,
user_id: "5247399c-6c8a-47f0-8880-aa854e01e554",
}, {
children: [],
content: "This is a third comment",
created: "2020-08-25T13:13:19+00:00",
created_by: "5247399c-6c8a-47f0-8880-aa854e01e554",
creator: {
id: "5247399c-6c8a-47f0-8880-aa854e01e554",
role_id: "c4870358-e32f-41ce-999b-8f80c9b0d17f",
active: true,
deleted: false,
last_logged_in: "",
profile: {
avatar: {url: {medium: "img/avatar/user_medium.png", small: "img/avatar/user.png"}},
created: "2020-09-01T13:11:08+00:00",
first_name: "Betty",
id: "f6b23982-d3dd-4f8b-9bcc-f3a473edffc2",
last_name: "Holberton",
modified: "2020-09-01T13:11:08+00:00",
user_id: "5247399c-6c8a-47f0-8880-aa854e01e554",
},
},
role_id: "c4870358-e32f-41ce-999b-8f80c9b0d17f",
username: "[email protected]",
foreign_key: "f302754f-f290-42a6-9ea3-7049c6d4dbe3",
foreign_model: "Resource",
id: "9e56b21f-36f1-44a7-a363-1c6ccbbf09e2",
modified: "2020-09-01T13:13:19+00:00",
modified_by: "5247399c-6c8a-47f0-8880-aa854e01e554",
parent_id: null,
user_id: "5247399c-6c8a-47f0-8880-aa854e01e554",
}];
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
* Unit tests on DeleteComment in regard of specifications
*/

import {administratorAppContext, commentsMock, defaultAppContext, defaultProps} from "./DeleteComment.test.data";
import {administratorAppContext, defaultAppContext, defaultProps} from "./DeleteComment.test.data";
import DisplayResourceDetailsPage from "../../ResourceDetails/DisplayResourceDetails/DisplayResourceDetailsComment.test.page";
import {ActionFeedbackContext} from "../../../contexts/ActionFeedbackContext";
import {defaultCommentCollectionDto} from "../../../../shared/models/entity/comment/commentEntityCollection.test.data";

beforeEach(() => {
jest.resetModules();
Expand All @@ -32,7 +33,9 @@ describe("Delete comments", () => {

const mockContextRequest = (context, implementation) => jest.spyOn(context.port, 'request').mockImplementation(implementation);
const noneCommentFoundRequestMockImpl = jest.fn(() => Promise.resolve([]));
const commentsFoundRequestMockImpl = jest.fn(() => Promise.resolve(commentsMock));
const commentsFoundRequestMockImpl = jest.fn(() => Promise.resolve(defaultCommentCollectionDto({
id: '9e56b21f-36f1-44a7-a363-1c6ccbbf09e2'
})));

describe("As AD I should be able to delete comments I don’t own", () => {
describe('As AD I can delete a comment I don’t own', () => {
Expand Down Expand Up @@ -149,7 +152,7 @@ describe("Delete comments", () => {

it('I should not be able to delete the comment', async() => {
await page.title.click();
expect(page.displayCommentList.canDelete(2)).toBeFalsy();
expect(page.displayCommentList.canDelete(4)).toBeFalsy();
});
});
});
Expand Down
54 changes: 45 additions & 9 deletions shared/models/entity/abstract/entitySchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
import EntityValidationError from "./entityValidationError";
import Validator from "validator";
import CollectionValidationError from "./collectionValidationError";

class EntitySchema {
/**
Expand Down Expand Up @@ -95,7 +96,21 @@ class EntitySchema {
* @throws ValidationError
*/
static validateArray(name, dto, schema) {
return EntitySchema.validateProp('items', dto, schema);
let validationError;

const parsedItems = EntitySchema.validateProp('items', dto, schema);

if (typeof(schema.minItems) === 'number') {
if (!EntitySchema.isGreaterThanOrEqual(dto.length, schema.minItems)) {
validationError = EntitySchema.handleCollectionValidationError('minItems', `The items array should contain at least ${schema.minItems} item(s).`, validationError);
}
}

if (validationError) {
throw validationError;
}

return parsedItems;
}

/**
Expand Down Expand Up @@ -126,7 +141,11 @@ class EntitySchema {
result[propName] = null;
continue;
}
// @todo: else => props is not nullable and null we could set an error and then continue but it requires all schema to migrate to explicit "nullable": true
/*
* else:
* the property is null but not marked as nullable. However, it could still be valid if an `anyOf` rule is set
* with a type `null`. So, we cannot consider for the moment this data as invalid.
*/
}

// Check if property is required
Expand Down Expand Up @@ -340,28 +359,45 @@ class EntitySchema {
return validationError;
}

/**
* Handle collection validation error.
* instantiate it if it does not exist yet.
* @param {string} [rule] The failing rule.
* @param {string} [message] The error message.
* @param {CollectionValidationError|null} [validationError=null] The collection validation error to add the error to,
* instantiate it if it does not exist yet.
* @returns {CollectionValidationError}
*/
static handleCollectionValidationError(rule, message, validationError = null) {
validationError = validationError || new CollectionValidationError(`Could not validate collection.`);
validationError.addCollectionValidationError(rule, message);

return validationError;
}

/**
* Validate a prop of type number
* Throw an error with the validation details if validation fails
*
* @param {string} propName example: name
* @param {*} prop example 42
* @param {object} propSchema example {type: number, gte: 64}
* @param {object} propSchema example {type: number, minimum: 64, maximum: 128}
* @throw {EntityValidationError}
* @returns void
*/
static validatePropTypeNumber(propName, prop, propSchema) {
let validationError;
if (typeof(propSchema.gte) === 'number') {
if (!EntitySchema.isGreaterThanOrEqual(prop, propSchema.gte)) {
validationError = EntitySchema.handlePropertyValidationError(propName, 'gte', `The ${propName} should be greater or equal to ${propSchema.gte}.`, validationError);
if (typeof(propSchema.minimum) === 'number') {
if (!EntitySchema.isGreaterThanOrEqual(prop, propSchema.minimum)) {
validationError = EntitySchema.handlePropertyValidationError(propName, 'minimum', `The ${propName} should be greater or equal to ${propSchema.minimum}.`, validationError);
}
}
if (typeof(propSchema.lte) === 'number') {
if (!EntitySchema.isLesserThanOrEqual(prop, propSchema.lte)) {
validationError = EntitySchema.handlePropertyValidationError(propName, 'lte', `The ${propName} should be lesser or equal to ${propSchema.lte}.`, validationError);
if (typeof(propSchema.maximum) === 'number') {
if (!EntitySchema.isLesserThanOrEqual(prop, propSchema.maximum)) {
validationError = EntitySchema.handlePropertyValidationError(propName, 'maximum', `The ${propName} should be lesser or equal to ${propSchema.maximum}.`, validationError);
}
}

if (validationError) {
throw validationError;
}
Expand Down
Loading

0 comments on commit bab2a8c

Please sign in to comment.