mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-09 19:15:58 +08:00
Fix SetFirmwarePassword and VerifyFirmwarePassword parameters (#743)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user