fix(windows-rdp): update test assertions for username and password handling
- Modified regex to use JSON.parse for extracting username and password values. - Updated test assertions to compare against JSON.stringify for proper value matching. - Added a backslash to the custom admin password for testing purposes.
This commit is contained in:
parent
5ca7450349
commit
af829e4083
@ -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),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user