Files
Roger eca1f058c6 refactor: move the ABE unit into internal/abe (#670)
crypto/windows and utils/injector were the last public packages, against the no-library-API rule, and
utils/ named nothing. They move as one unit; only import paths and Makefile variables change, and the
built payload is byte-identical.
2026-10-29 16:48:46 +08:00

80 lines
1.5 KiB
Go

//go:build windows
package injector
import (
"strings"
"testing"
"github.com/moond4rk/hackbrowserdata/internal/abe/native/bootstrap"
)
func TestFormatABEError(t *testing.T) {
cases := []struct {
name string
result scratchResult
wants []string
}{
{
name: "known err code with known HRESULT",
result: scratchResult{
Marker: 0xff,
Status: 0x00,
ErrCode: bootstrap.ErrDecryptData,
HResult: 0x80070005,
ComErr: 0,
},
wants: []string{
"err=IElevator.DecryptData failed",
"hr=E_ACCESSDENIED (0x80070005)",
"comErr=0x0",
"marker=0xff",
},
},
{
name: "known err code, unknown HRESULT falls back to hex",
result: scratchResult{
Marker: 0xff,
Status: 0x00,
ErrCode: bootstrap.ErrBrowserUnknown,
HResult: 0x12345678,
},
wants: []string{
"err=browser not in com_iid table",
"hr=0x12345678",
},
},
{
name: "unknown err code falls back to hex",
result: scratchResult{
ErrCode: 0xaa,
HResult: 0,
},
wants: []string{
"err=0xaa",
"hr=0x00000000",
},
},
{
name: "err code zero (ok) also renders",
result: scratchResult{
ErrCode: bootstrap.ErrOk,
},
wants: []string{
"err=0x00",
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := formatABEError(tc.result)
for _, want := range tc.wants {
if !strings.Contains(got, want) {
t.Errorf("formatABEError missing %q\n got: %s", want, got)
}
}
})
}
}