mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-11 04:05:35 +08:00
Add raw command and clear device queue endpoints (#864)
This commit is contained in:
49
platform/command/event_test.go
Normal file
49
platform/command/event_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package command_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/command"
|
||||
)
|
||||
|
||||
const testRawCmd = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Command</key>
|
||||
<dict>
|
||||
<key>ManagedOnly</key>
|
||||
<true/>
|
||||
<key>RequestType</key>
|
||||
<string>ProfileList</string>
|
||||
</dict>
|
||||
<key>CommandUUID</key>
|
||||
<string>0001_ProfileList</string>
|
||||
</dict>
|
||||
</plist>`
|
||||
|
||||
func TestRawEvent(t *testing.T) {
|
||||
cmd := &command.RawCommand{
|
||||
UDID: "1234",
|
||||
CommandUUID: "0001_ProfileList",
|
||||
Raw: []byte(testRawCmd),
|
||||
}
|
||||
cmd.Command.RequestType = "ProfileList"
|
||||
|
||||
ev := command.NewRawEvent(cmd)
|
||||
|
||||
buf, err := command.MarshalRawEvent(ev)
|
||||
if err != nil {
|
||||
t.Fatalf("could not marshal event: %v", err)
|
||||
}
|
||||
|
||||
ev2 := new(command.RawEvent)
|
||||
if err = command.UnmarshalRawEvent(buf, ev2); err != nil {
|
||||
t.Fatalf("could not unmarshal event: %v", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(ev, ev2) {
|
||||
t.Error("expected events to be equal")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user