Fix SetFirmwarePassword and VerifyFirmwarePassword parameters (#743)

This commit is contained in:
Kory Prince
2021-04-24 11:31:28 -05:00
committed by GitHub
parent cf20685e89
commit 876ce83dc9
2 changed files with 80 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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 {