Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const conf: Config = {
"private_key_passphrase",
"secret_access_key",
"client_secret",
"encrypted_disks_passphrase",
],

// The number of items per page applicable to default lists:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ jest.mock("@src/components/modules/EndpointModule/EndpointLogos", () => ({
default: (props: any) => <div>{props.endpoint}</div>,
}));
jest.mock("react-router", () => ({ Link: "a" }));
jest.mock("@src/utils/Config", () => ({
__esModule: true,
default: {
config: {
passwordFields: [
"private_key_passphrase",
"secret_access_key",
"client_secret",
"encrypted_disks_passphrase",
],
},
},
}));

describe("MainDetails", () => {
let defaultProps: MainDetails["props"];
Expand Down Expand Up @@ -104,4 +117,32 @@ describe("MainDetails", () => {
getByText(TRANSFER_MOCK.destination_environment.password),
).toBeTruthy();
});

it("masks encrypted disks passphrase", () => {
const { queryByText } = render(<MainDetails {...defaultProps} />);
const actualPassphrase =
TRANSFER_MOCK.destination_environment.encrypted_disks_passphrase;
expect(queryByText(actualPassphrase)).toBeFalsy();
const passwordEls = TestUtils.selectAll("PasswordValue__Wrapper");
expect(passwordEls.length).toBeGreaterThan(1);
});

it("shows encrypted disks passphrase when clicked", async () => {
const { getByText } = render(<MainDetails {...defaultProps} />);
const passwordEls = TestUtils.selectAll("PasswordValue__Wrapper");
expect(passwordEls.length).toBeGreaterThan(1);

const passphrasePasswordEl = passwordEls[passwordEls.length - 1];
expect(passphrasePasswordEl.textContent).toBe("•••••••••");

await act(async () => {
passphrasePasswordEl.click();
});

expect(
getByText(
TRANSFER_MOCK.destination_environment.encrypted_disks_passphrase,
),
).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import StatusIcon from "@src/components/ui/StatusComponents/StatusIcon";
import StatusImage from "@src/components/ui/StatusComponents/StatusImage";
import DateUtils from "@src/utils/DateUtils";
import LabelDictionary from "@src/utils/LabelDictionary";
import configLoader from "@src/utils/Config";

import arrowImage from "./images/arrow.svg";

Expand Down Expand Up @@ -249,7 +250,7 @@ class MainDetails extends React.Component<Props, State> {
if (value && value.join) {
value.forEach((v: any, i: number) => {
const useLabel = i === 0 ? label : "";
properties.push({ label: useLabel, value: v });
properties.push({ label: useLabel, value: v, name: pn });
});
} else if (value && typeof value === "object") {
properties = properties.concat(
Expand All @@ -263,11 +264,12 @@ class MainDetails extends React.Component<Props, State> {
return {
label: `${label} - ${LabelDictionary.get(p)}`,
value: getValue(p, value[p]),
name: p,
};
}),
);
} else {
properties.push({ label, value: getValue(pn, value) });
properties.push({ label, value: getValue(pn, value), name: pn });
}
});

Expand All @@ -280,7 +282,10 @@ class MainDetails extends React.Component<Props, State> {
<PropertyRow key={prop.label}>
<PropertyName>{prop.label}</PropertyName>
<PropertyValue>
{prop.label.toLowerCase().indexOf("password") > -1 &&
{(prop.label.toLowerCase().indexOf("password") > -1 ||
configLoader.config.passwordFields.find(
f => f === prop.name,
)) &&
!this.state.showPassword.find(
f => f === `${prop.label}-${type}`,
) ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,22 @@ jest.mock("@src/components/modules/EndpointModule/EndpointLogos", () => ({
}));
jest.mock("react-router", () => ({ Link: "a" }));
jest.mock("@src/utils/Config", () => ({
config: {
providerSortPriority: {},
providerNames: {
openstack: "OpenStack",
vmware_vsphere: "VMware vSphere",
__esModule: true,
default: {
config: {
providerSortPriority: {},
providerNames: {
openstack: "OpenStack",
vmware_vsphere: "VMware vSphere",
},
providersDisabledExecuteOptions: ["metal"],
passwordFields: [
"private_key_passphrase",
"secret_access_key",
"client_secret",
"encrypted_disks_passphrase",
],
},
providersDisabledExecuteOptions: ["metal"],
},
}));
jest.mock("@src/components/modules/TransferModule/Schedule", () => ({
Expand Down
1 change: 1 addition & 0 deletions tests/mocks/TransferMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const TRANSFER_MOCK: TransferItem = {
disk_mappings: {},
},
password: "password-value",
encrypted_disks_passphrase: "password-encrypted-value",
},
source_environment: {},
transfer_result: {
Expand Down
Loading