diff --git a/mdm/mdm/command.go b/mdm/mdm/command.go index dbbd9f9b..16e2b81d 100644 --- a/mdm/mdm/command.go +++ b/mdm/mdm/command.go @@ -243,12 +243,12 @@ type ManagedApplicationFeedback struct { type SetFirmwarePassword struct { CurrentPassword string `plist:",omitempty" json:"current_password,omitempty"` - NewPassword string `plist:",omitempty" json:"new_password,omitempty"` + NewPassword string `json:"new_password"` AllowOroms bool `plist:",omitempty" json:"allow_oroms,omitempty"` } type VerifyFirmwarePassword struct { - Password string `plist:",omitempty" json:"password,omitempty"` + Password string `json:"password"` } type SetAutoAdminPassword struct { diff --git a/mdm/mdm/mdm_command_test.go b/mdm/mdm/mdm_command_test.go index 083711b0..84a3efbd 100644 --- a/mdm/mdm/mdm_command_test.go +++ b/mdm/mdm/mdm_command_test.go @@ -62,6 +62,30 @@ func TestMarshalCommand(t *testing.T) { RequestType: "DisableRemoteDesktop", }, }, + { + Command: Command{ + RequestType: "SetFirmwarePassword", + SetFirmwarePassword: &SetFirmwarePassword{ + CurrentPassword: "test", + }, + }, + }, + { + Command: Command{ + RequestType: "SetFirmwarePassword", + SetFirmwarePassword: &SetFirmwarePassword{ + NewPassword: "test", + }, + }, + }, + { + Command: Command{ + RequestType: "SetFirmwarePassword", + VerifyFirmwarePassword: &VerifyFirmwarePassword{ + Password: "test", + }, + }, + }, } for _, tt := range tests { t.Run(tt.Command.RequestType+"_json", func(t *testing.T) { @@ -223,6 +247,60 @@ func TestEndToEnd(t *testing.T) { } }, }, + + { + name: "SetFirmwarePassword_NoNewPassword", + requestBytes: []byte( + `{"request_type":"SetFirmwarePassword","current_password":"test"}`, + ), + testFn: func(t *testing.T, parts endToEndParts) { + needToSee := [][]byte{ + []byte(`CurrentPassword`), + []byte(`test`), + []byte(`NewPassword`), + } + for _, b := range needToSee { + if !bytes.Contains(parts.plistData, b) { + t.Error(fmt.Sprintf("marshaled plist does not contain required bytes: '%s'", string(b))) + } + } + }, + }, + { + name: "SetFirmwarePassword_NewPassword", + requestBytes: []byte( + `{"request_type":"SetFirmwarePassword","new_password":"test"}`, + ), + testFn: func(t *testing.T, parts endToEndParts) { + needToSee := [][]byte{ + []byte(`NewPassword`), + []byte(`test`), + } + for _, b := range needToSee { + if !bytes.Contains(parts.plistData, b) { + t.Error(fmt.Sprintf("marshaled plist does not contain required bytes: '%s'", string(b))) + } + } + }, + }, + + { + name: "VerifyFirmwarePassword", + requestBytes: []byte( + `{"request_type":"VerifyFirmwarePassword","password":"test"}`, + ), + testFn: func(t *testing.T, parts endToEndParts) { + needToSee := [][]byte{ + []byte(`Password`), + []byte(`test`), + } + for _, b := range needToSee { + if !bytes.Contains(parts.plistData, b) { + t.Error(fmt.Sprintf("marshaled plist does not contain required bytes: '%s'", string(b))) + } + } + }, + }, } for _, tt := range tests {