@@ -34,6 +34,25 @@ function findRdpApp(state: TerraformState) {
3434 return null ;
3535}
3636
37+ function findRdpScript ( state : TerraformState ) {
38+ for ( const resource of state . resources ) {
39+ const isRdpScriptResource =
40+ resource . type === "coder_script" && resource . name === "rdp_setup" ;
41+
42+ if ( ! isRdpScriptResource ) {
43+ continue ;
44+ }
45+
46+ for ( const instance of resource . instances ) {
47+ if ( instance . attributes . display_name === "Configure RDP" ) {
48+ return instance . attributes ;
49+ }
50+ }
51+ }
52+
53+ return null ;
54+ }
55+
3756describe ( "local-windows-rdp" , async ( ) => {
3857 await runTerraformInit ( import . meta. dir ) ;
3958
@@ -63,6 +82,27 @@ describe("local-windows-rdp", async () => {
6382 expect ( app ?. url ) . toContain ( "password=coderRDP!" ) ;
6483 } ) ;
6584
85+ it ( "should create RDP configuration script" , async ( ) => {
86+ const state = await runTerraformApply < TestVariables > ( import . meta. dir , {
87+ agent_id : "test-agent-id" ,
88+ } ) ;
89+
90+ const script = findRdpScript ( state ) ;
91+
92+ // Verify the script was created
93+ expect ( script ) . not . toBeNull ( ) ;
94+ expect ( script ?. display_name ) . toBe ( "Configure RDP" ) ;
95+ expect ( script ?. icon ) . toBe ( "/icon/desktop.svg" ) ;
96+ expect ( script ?. run_on_start ) . toBe ( true ) ;
97+ expect ( script ?. run_on_stop ) . toBe ( false ) ;
98+
99+ // Verify the script contains PowerShell configuration
100+ expect ( script ?. script ) . toContain ( "Set-AdminPassword" ) ;
101+ expect ( script ?. script ) . toContain ( "Enable-RDP" ) ;
102+ expect ( script ?. script ) . toContain ( "Configure-Firewall" ) ;
103+ expect ( script ?. script ) . toContain ( "Start-RDPService" ) ;
104+ } ) ;
105+
66106 it ( "should create RDP app with custom values" , async ( ) => {
67107 const state = await runTerraformApply < TestVariables > ( import . meta. dir , {
68108 agent_id : "custom-agent-id" ,
@@ -85,6 +125,20 @@ describe("local-windows-rdp", async () => {
85125 expect ( app ?. url ) . toContain ( "password=CustomPass123!" ) ;
86126 } ) ;
87127
128+ it ( "should pass custom credentials to PowerShell script" , async ( ) => {
129+ const state = await runTerraformApply < TestVariables > ( import . meta. dir , {
130+ agent_id : "test-agent-id" ,
131+ username : "TestAdmin" ,
132+ password : "TestPassword123!" ,
133+ } ) ;
134+
135+ const script = findRdpScript ( state ) ;
136+
137+ // Verify custom credentials are in the script
138+ expect ( script ?. script ) . toContain ( '$username = "TestAdmin"' ) ;
139+ expect ( script ?. script ) . toContain ( '$password = "TestPassword123!"' ) ;
140+ } ) ;
141+
88142 it ( "should handle sensitive password variable" , async ( ) => {
89143 const state = await runTerraformApply < TestVariables > ( import . meta. dir , {
90144 agent_id : "test-agent-id" ,
0 commit comments