Compare commits
3 Commits
main
...
cat/window
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af829e4083 | ||
|
|
5ca7450349 | ||
|
|
02b5ae42f1 |
@ -59,7 +59,7 @@ const formFieldEntries = {
|
|||||||
querySelector: "web-client-username-control input",
|
querySelector: "web-client-username-control input",
|
||||||
|
|
||||||
/** @readonly */
|
/** @readonly */
|
||||||
value: "${CODER_USERNAME}",
|
value: JSON.parse("${CODER_USERNAME}"),
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @readonly */
|
/** @readonly */
|
||||||
@ -68,7 +68,7 @@ const formFieldEntries = {
|
|||||||
querySelector: "web-client-password-control input",
|
querySelector: "web-client-password-control input",
|
||||||
|
|
||||||
/** @readonly */
|
/** @readonly */
|
||||||
value: "${CODER_PASSWORD}",
|
value: JSON.parse("${CODER_PASSWORD}"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -89,7 +89,7 @@ describe("Web RDP", async () => {
|
|||||||
* @see {@link https://regex101.com/r/UMgQpv/2}
|
* @see {@link https://regex101.com/r/UMgQpv/2}
|
||||||
*/
|
*/
|
||||||
const formEntryValuesRe =
|
const formEntryValuesRe =
|
||||||
/^const formFieldEntries = \{$.*?^\s+username: \{$.*?^\s*?querySelector.*?,$.*?^\s*value: "(?<username>.+?)",$.*?password: \{$.*?^\s+querySelector: .*?,$.*?^\s*value: "(?<password>.+?)",$.*?^};$/ms;
|
/^const formFieldEntries = \{$.*?^\s+username: \{$.*?^\s*?querySelector.*?,$.*?^\s*value: JSON\.parse\("(?<username>.+?)"\),$.*?password: \{$.*?^\s+querySelector: .*?,$.*?^\s*value: JSON\.parse\("(?<password>.+?)"\),$.*?^};$/ms;
|
||||||
|
|
||||||
// Test that things work with the default username/password
|
// Test that things work with the default username/password
|
||||||
const defaultState = await runTerraformApply<TestVariables>(
|
const defaultState = await runTerraformApply<TestVariables>(
|
||||||
@ -106,12 +106,13 @@ describe("Web RDP", async () => {
|
|||||||
const defaultResultsGroup =
|
const defaultResultsGroup =
|
||||||
formEntryValuesRe.exec(defaultRdpScript ?? "")?.groups ?? {};
|
formEntryValuesRe.exec(defaultRdpScript ?? "")?.groups ?? {};
|
||||||
|
|
||||||
expect(defaultResultsGroup.username).toBe("Administrator");
|
// Should match the escaped JSON values
|
||||||
expect(defaultResultsGroup.password).toBe("coderRDP!");
|
expect(defaultResultsGroup.username).toBe(JSON.stringify("Administrator"));
|
||||||
|
expect(defaultResultsGroup.password).toBe(JSON.stringify("coderRDP!"));
|
||||||
|
|
||||||
// Test that custom usernames/passwords are also forwarded correctly
|
// Test that custom usernames/passwords are also forwarded correctly
|
||||||
const customAdminUsername = "crouton";
|
const customAdminUsername = "crouton";
|
||||||
const customAdminPassword = "VeryVeryVeryVeryVerySecurePassword97!";
|
const customAdminPassword = "VeryVeryVeryVeryVerySecurePassword97!\\"; // Added a backslash for testing
|
||||||
const customizedState = await runTerraformApply<TestVariables>(
|
const customizedState = await runTerraformApply<TestVariables>(
|
||||||
import.meta.dir,
|
import.meta.dir,
|
||||||
{
|
{
|
||||||
@ -128,7 +129,12 @@ describe("Web RDP", async () => {
|
|||||||
const customResultsGroup =
|
const customResultsGroup =
|
||||||
formEntryValuesRe.exec(customRdpScript ?? "")?.groups ?? {};
|
formEntryValuesRe.exec(customRdpScript ?? "")?.groups ?? {};
|
||||||
|
|
||||||
expect(customResultsGroup.username).toBe(customAdminUsername);
|
// Should match the escaped JSON values
|
||||||
expect(customResultsGroup.password).toBe(customAdminPassword);
|
expect(customResultsGroup.username).toBe(
|
||||||
|
JSON.stringify(customAdminUsername),
|
||||||
|
);
|
||||||
|
expect(customResultsGroup.password).toBe(
|
||||||
|
JSON.stringify(customAdminPassword),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -52,8 +52,9 @@ resource "coder_script" "windows-rdp" {
|
|||||||
# doesn't allow recursive calls to the templatefile function. Have to feed
|
# doesn't allow recursive calls to the templatefile function. Have to feed
|
||||||
# results of the JS template replace into the powershell template
|
# results of the JS template replace into the powershell template
|
||||||
patch_file_contents = templatefile("${path.module}/devolutions-patch.js", {
|
patch_file_contents = templatefile("${path.module}/devolutions-patch.js", {
|
||||||
CODER_USERNAME = var.admin_username
|
# Properly escape the username and password to preserve special characters
|
||||||
CODER_PASSWORD = var.admin_password
|
CODER_USERNAME = jsonencode(var.admin_username)
|
||||||
|
CODER_PASSWORD = jsonencode(var.admin_password)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user