Revert "fix(volumes): decrypt values before testing connection (#939)"
This reverts commit 885ea10f2a.
This commit is contained in:
parent
4a4e5c0abe
commit
11614daf51
2 changed files with 2 additions and 32 deletions
|
|
@ -16,7 +16,6 @@ import { withContext } from "~/server/core/request-context";
|
||||||
import { asShortId } from "~/server/utils/branded";
|
import { asShortId } from "~/server/utils/branded";
|
||||||
import { createTestVolume } from "~/test/helpers/volume";
|
import { createTestVolume } from "~/test/helpers/volume";
|
||||||
import { config } from "~/server/core/config";
|
import { config } from "~/server/core/config";
|
||||||
import { cryptoUtils } from "~/server/utils/crypto";
|
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
config.flags.enableLocalAgent = false;
|
config.flags.enableLocalAgent = false;
|
||||||
|
|
@ -287,31 +286,4 @@ describe("volumeService.testConnection", () => {
|
||||||
expect.objectContaining({ name: "volume.testConnection" }),
|
expect.objectContaining({ name: "volume.testConnection" }),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("decrypts encrypted config values before testing the connection", async () => {
|
|
||||||
config.flags.enableLocalAgent = true;
|
|
||||||
agentManagerMock.runVolumeCommand.mockResolvedValue({
|
|
||||||
name: "volume.testConnection",
|
|
||||||
result: { success: true, message: "Connection successful" },
|
|
||||||
});
|
|
||||||
const encryptedPassword = await cryptoUtils.sealSecret("plain-password");
|
|
||||||
|
|
||||||
await volumeService.testConnection({
|
|
||||||
backend: "smb",
|
|
||||||
server: "127.0.0.1",
|
|
||||||
share: "backup",
|
|
||||||
username: "backup-user",
|
|
||||||
password: encryptedPassword,
|
|
||||||
domain: "",
|
|
||||||
vers: "3.0",
|
|
||||||
port: 445,
|
|
||||||
mapToContainerUidGid: false,
|
|
||||||
readOnly: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(agentManagerMock.runVolumeCommand).toHaveBeenCalledWith("local", {
|
|
||||||
name: "volume.testConnection",
|
|
||||||
backendConfig: expect.objectContaining({ password: "plain-password" }),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -285,13 +285,11 @@ const updateVolume = async (shortId: ShortId, volumeData: UpdateVolumeBody) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const testConnection = async (backendConfig: BackendConfig) => {
|
const testConnection = async (backendConfig: BackendConfig) => {
|
||||||
const resolvedConfig = await decryptVolumeConfig(backendConfig);
|
|
||||||
|
|
||||||
if (!config.flags.enableLocalAgent) {
|
if (!config.flags.enableLocalAgent) {
|
||||||
return Effect.runPromise(testVolumeConnection(resolvedConfig));
|
return Effect.runPromise(testVolumeConnection(backendConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
const command = await runVolumeCommand(LOCAL_AGENT_ID, { name: "volume.testConnection", backendConfig: resolvedConfig });
|
const command = await runVolumeCommand(LOCAL_AGENT_ID, { name: "volume.testConnection", backendConfig });
|
||||||
return command.result;
|
return command.result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue