mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-29 07:21:16 -07:00
Add these private widget options
This commit is contained in:
@@ -31,7 +31,7 @@ export async function cleanWidgetGroups(widgets) {
|
|||||||
const optionKeys = Object.keys(sanitizedOptions);
|
const optionKeys = Object.keys(sanitizedOptions);
|
||||||
|
|
||||||
// delete private options from the sanitized options
|
// delete private options from the sanitized options
|
||||||
["username", "password", "key", "apiKey"].forEach((pO) => {
|
["username", "password", "key", "apiKey", "headers", "requestBody", "method"].forEach((pO) => {
|
||||||
if (optionKeys.includes(pO)) {
|
if (optionKeys.includes(pO)) {
|
||||||
delete sanitizedOptions[pO];
|
delete sanitizedOptions[pO];
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ export async function getPrivateWidgetOptions(type, widgetIndex) {
|
|||||||
|
|
||||||
const privateOptions =
|
const privateOptions =
|
||||||
widgets.map((widget) => {
|
widgets.map((widget) => {
|
||||||
const { index, url, username, password, key, apiKey } = widget.options;
|
const { index, url, username, password, key, apiKey, headers, requestBody, method } = widget.options;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: widget.type,
|
type: widget.type,
|
||||||
@@ -68,6 +68,9 @@ export async function getPrivateWidgetOptions(type, widgetIndex) {
|
|||||||
password,
|
password,
|
||||||
key,
|
key,
|
||||||
apiKey,
|
apiKey,
|
||||||
|
headers,
|
||||||
|
requestBody,
|
||||||
|
method,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}) || {};
|
}) || {};
|
||||||
|
|||||||
@@ -60,6 +60,17 @@ describe("utils/config/widget-helpers", () => {
|
|||||||
expect(cleaned[2].options.apiKey).toBeUndefined();
|
expect(cleaned[2].options.apiKey).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("cleanWidgetGroups removes customapi request options", async () => {
|
||||||
|
const cleaned = await cleanWidgetGroups([
|
||||||
|
{
|
||||||
|
type: "customapi",
|
||||||
|
options: { index: 0, url: "http://x", headers: { a: "b" }, requestBody: "body", method: "POST", icon: "mdi-x" },
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(cleaned[0].options).toEqual({ index: 0, icon: "mdi-x" });
|
||||||
|
});
|
||||||
|
|
||||||
it("getPrivateWidgetOptions returns private options for a specific widget", async () => {
|
it("getPrivateWidgetOptions returns private options for a specific widget", async () => {
|
||||||
fs.readFile.mockResolvedValueOnce("ignored");
|
fs.readFile.mockResolvedValueOnce("ignored");
|
||||||
yaml.load.mockReturnValueOnce([{ search: { url: "http://x", username: "u", password: "p", key: "k" } }]);
|
yaml.load.mockReturnValueOnce([{ search: { url: "http://x", username: "u", password: "p", key: "k" } }]);
|
||||||
|
|||||||
Reference in New Issue
Block a user