-
Notifications
You must be signed in to change notification settings - Fork 129
/
shell_test.go
44 lines (38 loc) · 1.45 KB
/
shell_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package winrm
import (
"github.com/masterzen/winrm/soap"
. "gopkg.in/check.v1"
)
func (s *WinRMSuite) TestShellExecuteResponse(c *C) {
endpoint := NewEndpoint("localhost", 5985, false, false, nil, nil, nil, 0)
client, err := NewClient(endpoint, "Administrator", "v3r1S3cre7")
c.Assert(err, IsNil)
shell := &Shell{client: client, id: "67A74734-DD32-4F10-89DE-49A060483810"}
first := true
r := Requester{}
r.http = func(client *Client, message *soap.SoapMessage) (string, error) {
if first {
c.Assert(message.String(), Contains, "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command")
first = false
return executeCommandResponse, nil
}
c.Assert(message.String(), Contains, "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive")
return outputResponse, nil
}
client.http = &r
command, _ := shell.Execute("ipconfig /all")
c.Assert(command.id, Equals, "1A6DEE6B-EC68-4DD6-87E9-030C0048ECC4")
}
func (s *WinRMSuite) TestShellCloseResponse(c *C) {
endpoint := NewEndpoint("localhost", 5985, false, false, nil, nil, nil, 0)
client, err := NewClient(endpoint, "Administrator", "v3r1S3cre7")
c.Assert(err, IsNil)
shell := &Shell{client: client, id: "67A74734-DD32-4F10-89DE-49A060483810"}
r := Requester{}
r.http = func(client *Client, message *soap.SoapMessage) (string, error) {
c.Assert(message.String(), Contains, "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete")
return "", nil
}
client.http = &r
shell.Close()
}