Skip to content

Commit

Permalink
PB-24096 Fix missing apiClient updateAll. Fix copy secret to clipoard…
Browse files Browse the repository at this point in the history
… in main password workspace menu.

Signed-off-by: Cedric Alfonsi <[email protected]>
  • Loading branch information
cedricalfonsi committed Jun 7, 2023
1 parent d13761b commit ce36b63
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,15 @@ class DisplayResourcesWorkspaceMenu extends React.Component {
<div className="col2_3 actions-wrapper">
<div className="actions">
<ul>
<li id="password_action">
<button type="button" disabled={!this.hasOneResourceSelected()}
onClick={this.handleCopySecretClickEvent}>
<Icon name="copy-to-clipboard"/>
<span><Trans>Copy</Trans></span>
</button>
</li>
{canCopySecret &&
<li id="password_action">
<button type="button" disabled={!this.hasOneResourceSelected()}
onClick={this.handleCopySecretClickEvent}>
<Icon name="copy-to-clipboard"/>
<span><Trans>Copy</Trans></span>
</button>
</li>
}
<li id="edit_action">
<button type="button" disabled={!this.hasOneResourceSelected() || !this.canUpdate()}
onClick={this.handleEditClickEvent}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
import {SecretGeneratorComplexity} from "./SecretGeneratorComplexity";

describe.only("SecretGeneratorComplexity", () => {
describe("SecretGeneratorComplexity", () => {
/**
* To ensure the test is a bit more relevant, the results to compare with are taken from https://www.omnicalculator.com/other/password-entropy
*/
Expand Down
18 changes: 18 additions & 0 deletions src/shared/lib/apiClient/apiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,24 @@ export class ApiClient {
return this.fetchAndHandleResponse('PUT', url, bodyString);
}

/**
* Update all.
*
* @param {Object} body (will be converted to JavaScript Object Notation (JSON) string)
* @param {Object} [urlOptions] Optional url parameters for example {"contain[something]": "1"}
* @throws {TypeError} if body is empty or cannot converted to valid JSON string
* @throws {PassboltServiceUnavailableError} if service is not reachable
* @throws {PassboltBadResponseError} if passbolt API responded with non parsable JSON
* @throws {PassboltApiFetchError} if passbolt API response is not OK (non 2xx status)
* @returns {Promise<*>}
* @public
*/
async updateAll(body, urlOptions = {}) {
const url = this.buildUrl(this.baseUrl.toString(), urlOptions);
const bodyString = body ? this.buildBody(body) : null;
return this.fetchAndHandleResponse('PUT', url, bodyString);
}

/**
* Assert that an id is a valid non empty string
*
Expand Down
5 changes: 3 additions & 2 deletions src/shared/models/entity/rbac/actionEntity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ActionEntity from "./actionEntity";
import {defaultActionData} from "./actionEntity.test.data";
import each from "jest-each";
import EntityValidationError from "../abstract/entityValidationError";
import {v4 as uuid} from "uuid";

describe("ActionEntity", () => {
describe("ActionEntity:constructor", () => {
Expand Down Expand Up @@ -56,7 +57,7 @@ describe("ActionEntity", () => {
each([
{scenario: 'required', rule: 'type'},
{scenario: 'not null', rule: 'type', value: null},
{scenario: 'max length', rule: 'format', value: "a".repeat(256)},
{scenario: 'max length', rule: 'maxLength', value: "a".repeat(256)},
]).describe("Should validate the name", test => {
it(`Should not accept: ${test.scenario}`, async() => {
expect.assertions(2);
Expand All @@ -68,7 +69,7 @@ describe("ActionEntity", () => {
new ActionEntity(dto);
} catch (error) {
expect(error).toBeInstanceOf(EntityValidationError);
expect(error.hasError('id', test.rule)).toBeTruthy();
expect(error.hasError('name', test.rule)).toBeTruthy();
}
});
});
Expand Down

0 comments on commit ce36b63

Please sign in to comment.