Skip to content

Commit

Permalink
Merge branch 'develop' into 'release'
Browse files Browse the repository at this point in the history
Develop

See merge request passbolt/passbolt-styleguide!1723
  • Loading branch information
Gamabunta57 committed Aug 22, 2024
2 parents 8f3e727 + 69c8538 commit 34dbeb0
Show file tree
Hide file tree
Showing 86 changed files with 3,167 additions and 3,035 deletions.
582 changes: 275 additions & 307 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "passbolt-styleguide",
"version": "4.9.3",
"version": "4.9.4",
"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 Expand Up @@ -37,15 +37,15 @@
"grunt-contrib-watch": "^1.1.0",
"grunt-header": "^1.1.0",
"grunt-shell": "^4.0.0",
"i18next-parser": "^8.12.0",
"i18next-parser": "^9.0.1",
"jest": "^29.6.2",
"jest-each": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"jest-fetch-mock": "^3.0.3",
"jest-junit": "^16.0.0",
"jest-useragent-mock": "^0.1.1",
"jest-webextension-mock": "^3.8.9",
"lockfile-lint": "^4.12.1",
"lockfile-lint": "^4.14.0",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,21 +457,19 @@ class CreateResource extends Component {
*/
async createResource() {
const resourceDto = {
name: this.state.name,
username: this.state.username,
uri: this.state.uri,
folder_parent_id: this.props.folderParentId,
metadata: {
name: this.state.name,
username: this.state.username,
uris: [this.state.uri],
resource_type_id: this.state.resourceTypeId,
},
};

if (this.props.passwordExpiryContext.isFeatureEnabled()) {
this.setResourceExpirationDate(resourceDto);
}

// No resource types, legacy case
if (!this.state.resourceTypeId) {
return this.createResourceLegacy(resourceDto, this.state.password);
}

// Resource types enabled but legacy type requested
if (this.isLegacyResource) {
return this.createWithoutEncryptedDescription(resourceDto, this.state.password);
Expand Down Expand Up @@ -519,19 +517,6 @@ class CreateResource extends Component {
resourceDto.expired = date.toISO();
}

/**
* Create legacy resource with no resource type
*
* @param resourceDto
* @param {string} secretString
* @returns {Promise<*>}
* @deprecated will be removed when v2 support is dropped
*/
async createResourceLegacy(resourceDto, secretString) {
resourceDto.description = this.state.description;
return this.props.context.port.request("passbolt.resources.create", resourceDto, secretString);
}

/**
* Create with encrypted description type
*
Expand Down Expand Up @@ -567,7 +552,7 @@ class CreateResource extends Component {
resourceDto.resource_type_id = this.resourceTypesSettings.findResourceTypeIdBySlug(
this.resourceTypesSettings.DEFAULT_RESOURCE_TYPES_SLUGS.PASSWORD_STRING
);
resourceDto.description = this.state.description;
resourceDto.metadata.description = this.state.description;

return this.props.context.port.request("passbolt.resources.create", resourceDto, secretString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function defaultProps(data = {}) {

export const defaultResourceMeta = (data = {}) => ({
name: "Password name",
uri: "https://uri.dev",
uris: ["https://uri.dev"],
username: "Password username",
description: "Password description",
...data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe("See the Create Resource", () => {

// Fill the form
page.passwordCreate.fillInput(page.passwordCreate.name, resourceMeta.name);
page.passwordCreate.fillInput(page.passwordCreate.uri, resourceMeta.uri);
page.passwordCreate.fillInput(page.passwordCreate.uri, resourceMeta.uris[0]);
page.passwordCreate.fillInput(page.passwordCreate.username, resourceMeta.username);
page.passwordCreate.fillInput(page.passwordCreate.description, resourceMeta.description);
await page.passwordCreate.click(page.passwordCreate.descriptionEncryptedLock);
Expand All @@ -188,17 +188,20 @@ describe("See the Create Resource", () => {
jest.spyOn(context.port, 'emit').mockImplementation(jest.fn());
jest.spyOn(ActionFeedbackContext._currentValue, 'displaySuccess').mockImplementation(() => {});

const onApiUpdateResourceMeta = defaultResourceMeta({
const onApiResourceDto = {
folder_parent_id: null,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_STRING,
expired: null,
...resourceMeta
});
metadata: {
...resourceMeta,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_STRING,
}
};

await page.passwordCreate.click(page.passwordCreate.saveButton);
await waitFor(() => {});
expect(context.port.request).toHaveBeenNthCalledWith(1, "passbolt.secrets.powned-password", "RN9n8XuECN3");
expect(context.port.request).toHaveBeenNthCalledWith(2, "passbolt.resources.create", onApiUpdateResourceMeta, resourcePassword);
expect(context.port.request).toHaveBeenNthCalledWith(2, "passbolt.resources.create", onApiResourceDto, resourcePassword);
expect(ActionFeedbackContext._currentValue.displaySuccess).toHaveBeenCalled();
expect(props.onClose).toBeCalled();
});
Expand All @@ -214,7 +217,7 @@ describe("See the Create Resource", () => {

// Fill the form
page.passwordCreate.fillInput(page.passwordCreate.name, resourceMeta.name);
page.passwordCreate.fillInput(page.passwordCreate.uri, resourceMeta.uri);
page.passwordCreate.fillInput(page.passwordCreate.uri, resourceMeta.uris[0]);
page.passwordCreate.fillInput(page.passwordCreate.username, resourceMeta.username);
page.passwordCreate.fillInput(page.passwordCreate.description, resourceMeta.description);

Expand All @@ -230,17 +233,21 @@ describe("See the Create Resource", () => {
jest.spyOn(context.port, 'emit').mockImplementation(jest.fn());
jest.spyOn(ActionFeedbackContext._currentValue, 'displaySuccess').mockImplementation(() => {});

const onApiUpdateSecretDto = {
password: resourcePassword,
description: resourceMeta.description,
};

delete resourceMeta.description;

const onApiUpdateResourceDto = {
...resourceMeta,
folder_parent_id: null,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
expired: null,
};
delete onApiUpdateResourceDto.description;

const onApiUpdateSecretDto = {
description: resourceMeta.description,
password: resourcePassword
metadata: {
...resourceMeta,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
}
};

await page.passwordCreate.click(page.passwordCreate.saveButton);
Expand Down Expand Up @@ -281,7 +288,7 @@ describe("See the Create Resource", () => {
// create password
const resourceMeta = {
name: "Password name",
uri: "",
uris: [""],
username: "",
password: "RN9n8XuECN3",
description: "",
Expand All @@ -297,10 +304,13 @@ describe("See the Create Resource", () => {

const onApiUpdateResourceMeta = {
folder_parent_id: null,
name: resourceMeta.name,
uri: resourceMeta.uri,
username: resourceMeta.username,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
metadata: {
name: resourceMeta.name,
uris: resourceMeta.uris,
username: resourceMeta.username,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
},
expired: resourceMeta.expired,
};

Expand Down Expand Up @@ -338,10 +348,9 @@ describe("See the Create Resource", () => {
expect(page.passwordCreate.exists()).toBeTruthy();
// create password
const resourceMeta = defaultResourceMeta({
uri: "",
uris: [""],
username: "",
description: "",
expired: null
description: ""
});

const resourcePassword = "RN9n8XuECN3";
Expand All @@ -351,11 +360,16 @@ describe("See the Create Resource", () => {
await page.passwordCreate.fillInputPassword(resourcePassword);

const onApiUpdateResourceMeta = {
...resourceMeta,
metadata: {
...resourceMeta,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
},
folder_parent_id: null,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
expired: null
};
delete onApiUpdateResourceMeta.description;

delete onApiUpdateResourceMeta.metadata.description;

const createResourceSecretDto = {
description: resourceMeta.description,
Expand Down Expand Up @@ -390,7 +404,7 @@ describe("See the Create Resource", () => {
// create password
const resourceMeta = {
name: "Password name",
uri: "",
uris: [""],
username: "",
password: "RN9n8XuECN3",
description: "",
Expand All @@ -402,9 +416,12 @@ describe("See the Create Resource", () => {

const onApiUpdateResourceMeta = {
folder_parent_id: null,
name: resourceMeta.name,
uri: resourceMeta.uri,
username: resourceMeta.username,
metadata: {
name: resourceMeta.name,
uris: resourceMeta.uris,
username: resourceMeta.username,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
},
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
};

Expand Down Expand Up @@ -441,7 +458,7 @@ describe("See the Create Resource", () => {
// create password
const resourceMeta = {
name: "Password name",
uri: "",
uris: [""],
username: "",
password: "RN9n8XuECN3",
description: "",
Expand All @@ -453,9 +470,12 @@ describe("See the Create Resource", () => {

const onApiUpdateResourceMeta = {
folder_parent_id: null,
name: resourceMeta.name,
uri: resourceMeta.uri,
username: resourceMeta.username,
metadata: {
name: resourceMeta.name,
uris: resourceMeta.uris,
username: resourceMeta.username,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
},
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
};

Expand Down Expand Up @@ -490,10 +510,9 @@ describe("See the Create Resource", () => {
expect(page.passwordCreate.exists()).toBeTruthy();
// create password
const resourceMeta = defaultResourceMeta({
uri: "",
uris: [""],
username: "",
description: "",
expired: null
description: ""
});
const resourcePassword = "RN9n8XuECN3";

Expand All @@ -502,12 +521,15 @@ describe("See the Create Resource", () => {
await page.passwordCreate.fillInputPassword(resourcePassword);

const onApiUpdateResourceMeta = {
...resourceMeta,
metadata: {
...resourceMeta,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
},
folder_parent_id: null,
resource_type_id: TEST_RESOURCE_TYPE_PASSWORD_AND_DESCRIPTION,
expired: resourceMeta.expired,
expired: null,
};
delete onApiUpdateResourceMeta.description;
delete onApiUpdateResourceMeta.metadata.description;

const createResourceSecretDto = {
description: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class DeleteResource extends Component {
<>
<p>
<Trans>
Are you sure you want to delete the resource <strong className="dialog-variable">{{resourceName: this.resources[0].name}}</strong>?
Are you sure you want to delete the resource <strong className="dialog-variable">{{resourceName: this.resources[0].metadata.name}}</strong>?
</Trans>
</p>
<p><Trans>Once the resource is deleted, it will be removed permanently and will not be recoverable.</Trans></p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {defaultUserAppContext} from "../../../contexts/ExtAppContext.test.data";
import {defaultActionFeedbackContext} from "../../../contexts/ActionFeedbackContext.test.data";
import {defaultResourceDto} from "../../../../shared/models/entity/resource/resourceEntity.test.data";
import {readPermissionDto} from "../../../../shared/models/entity/permission/permissionEntity.test.data";

/**
* Default props one selected resource owned
Expand Down Expand Up @@ -46,28 +48,14 @@ export function defaultPropsOneResourceLongPassword() {
* Mocked list of resources
*/
export const resourcesMock = [
{
"id": "8e3874ae-4b40-590b-968a-418f704b9d9a",
"name": "apache",
"username": "www-data",
"uri": "http:\/\/www.apache.org\/",
"description": "Apache is the world\u0027s most used web server software.",
"deleted": false,
"created": "2020-08-25T08:35:19+00:00",
"modified": "2020-08-26T08:35:19+00:00",
"created_by": "f848277c-5398-58f8-a82a-72397af2d450",
"modified_by": "f848277c-5398-58f8-a82a-72397af2d450",
"permission": {
"id": "8dfd59a7-852d-5c57-bd45-75c28bbb3f6c",
"aco": "Resource",
"aco_foreign_key": "8e3874ae-4b40-590b-968a-418f704b9d9a",
"aro": "User",
"aro_foreign_key": "f848277c-5398-58f8-a82a-72397af2d450",
"type": 15,
"created": "2020-08-27T08:35:19+00:00",
"modified": "2020-08-27T08:35:19+00:00"
defaultResourceDto({
metadata: {
name: "apache",
username: "www-data",
uri: "http://www.apache.org/",
description: "Apache is the world\u0027s most used web server software.",
},
"tags": [
tags: [
{
"id": "1c8afebc-7e23-51bd-a0b6-2e695afeb32f",
"slug": "#charlie",
Expand All @@ -79,32 +67,15 @@ export const resourcesMock = [
"is_shared": true
}
],
"folder_parent_id": null,
"personal": false
}, {
"id": "09c790c0-c003-53c8-a640-25d33cfebc22",
"name": "bower",
"username": "bower",
"uri": "bower.io",
"description": "A package manager for the web!",
"deleted": false,
"created": "2018-08-27T08:35:19+00:00",
"modified": "2019-08-27T08:35:19+00:00",
"created_by": "640ebc06-5ec1-5322-a1ae-6120ed2f3a74",
"modified_by": "640ebc06-5ec1-5322-a1ae-6120ed2f3a74",
"favorite": null,
"permission": {
"id": "672728ac-c3f2-52a5-a21c-07dfe84b7ad9",
"aco": "Resource",
"aco_foreign_key": "09c790c0-c003-53c8-a640-25d33cfebc22",
"aro": "User",
"aro_foreign_key": "f848277c-5398-58f8-a82a-72397af2d450",
"type": 1,
"created": "2020-08-27T08:35:19+00:00",
"modified": "2020-08-27T08:35:19+00:00"
}),
defaultResourceDto({
metadata: {
name: "bower",
username: "bower",
uri: "bower.io",
description: "A package manager for the web!",
},
"tags": [],
"folder_parent_id": null,
"personal": false
},
permission: readPermissionDto(),
tags: [],
})
];
Loading

0 comments on commit 34dbeb0

Please sign in to comment.