@@ -63,6 +63,60 @@ fn configuration_name_sets_shell_resource_uri() {
6363 ) ;
6464}
6565
66+ /// With a JEA `configuration_name`, post-create operations must keep targeting the
67+ /// JEA resource URI even when the server's CreateResponse omits the ResourceUri echo.
68+ #[ test]
69+ fn configuration_name_survives_create_response_without_resource_uri_echo ( ) {
70+ let mut config = support:: test_config ( ) ;
71+ config. configuration_name = Some ( "MyJEAEndpoint" . into ( ) ) ;
72+ let mut connector = Connector :: new ( config) ;
73+
74+ // 1. Idle step emits the shell Create request.
75+ let result = connector. step ( None ) . expect ( "idle step" ) ;
76+ let ConnectorStepResult :: SendBack { try_send } = result else {
77+ panic ! ( "expected SendBack for Create" ) ;
78+ } ;
79+ let ( _request, conn_id) = support:: expect_just_send ( try_send) ;
80+
81+ // 2. Reply with a CreateResponse whose Shell does NOT echo a ResourceUri element.
82+ let create_response = include_str ! ( "resources/resource_created.xml" ) ;
83+ let strip_resource_uri =
84+ regex:: Regex :: new ( r"(?s)<rsp:ResourceUri>.*?</rsp:ResourceUri>" ) . expect ( "valid regex" ) ;
85+ let create_response = strip_resource_uri. replace ( create_response, "" ) . into_owned ( ) ;
86+ assert ! (
87+ !create_response. contains( "rsp:ResourceUri" ) ,
88+ "fixture must not echo a shell ResourceUri for this test"
89+ ) ;
90+
91+ let result = connector
92+ . step ( Some ( support:: xml_response ( conn_id, create_response) ) )
93+ . expect ( "accept CreateResponse" ) ;
94+ let ConnectorStepResult :: SendBack { try_send } = result else {
95+ panic ! ( "expected SendBack for Receive" ) ;
96+ } ;
97+
98+ // 3. The post-create Receive must still target the JEA endpoint resource URI.
99+ let ( request, _conn_id) = support:: expect_just_send ( try_send) ;
100+ let receive_xml = request
101+ . body
102+ . expect ( "receive has a body" )
103+ . as_str ( )
104+ . expect ( "plaintext body" )
105+ . to_owned ( ) ;
106+ assert ! (
107+ receive_xml. contains( "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive" ) ,
108+ "connector must fire a Receive after shell creation"
109+ ) ;
110+ assert ! (
111+ receive_xml. contains( "powershell/MyJEAEndpoint" ) ,
112+ "post-create Receive must target the JEA endpoint resource URI"
113+ ) ;
114+ assert ! (
115+ !receive_xml. contains( "powershell/Microsoft.PowerShell" ) ,
116+ "post-create Receive must not fall back to the default resource URI"
117+ ) ;
118+ }
119+
66120/// Drive the connector through the full handshake against a fake server:
67121/// Create -> CreateResponse -> Receive -> ReceiveResponse(PSRP negotiation) -> Connected.
68122#[ test]
0 commit comments