HackBrowserData/internal/browser/browser_test.go

87 lines
1.9 KiB
Go
Raw Normal View History

package browser
import (
"fmt"
"testing"
2022-04-11 07:53:19 +00:00
"hack-browser-data/internal/browser/chromium"
"hack-browser-data/internal/item"
2022-04-02 08:59:34 +00:00
"hack-browser-data/internal/outputter"
)
2022-01-11 10:19:17 +00:00
func TestPickChromium(t *testing.T) {
2022-04-11 11:57:40 +00:00
}
2022-01-11 10:19:17 +00:00
2022-04-01 07:00:56 +00:00
func TestGetChromiumItemAbsPath(t *testing.T) {
p := `/Library/Application Support/Google/Chrome/`
2022-04-11 07:53:19 +00:00
p = homeDir + p
c, err := chromium.New("chrome", "Chrome", p, item.DefaultChromium)
if err != nil {
t.Error(err)
}
data, err := c.GetBrowsingData()
if err != nil {
t.Error(err)
}
2022-04-11 11:57:40 +00:00
output := outputter.New("json")
2022-04-11 07:53:19 +00:00
2022-04-01 07:00:56 +00:00
if err != nil {
2022-04-11 07:53:19 +00:00
t.Error(err)
}
for _, v := range data.Sources {
f, err := output.CreateFile("result", v.Name()+".json")
if err != nil {
panic(err)
}
if err := output.Write(v, f); err != nil {
panic(err)
}
2022-04-01 07:00:56 +00:00
}
}
2022-03-26 06:03:40 +00:00
func TestPickBrowsers(t *testing.T) {
browsers := PickBrowser("all")
for _, v := range browsers {
2022-04-11 11:57:40 +00:00
fmt.Println(v.Name())
2022-03-26 06:03:40 +00:00
}
// filetype := "json"
// dir := "result"
2022-04-11 11:57:40 +00:00
// output := outputter.New(filetype)
2022-03-26 06:03:40 +00:00
}
2022-04-11 07:53:19 +00:00
// func TestPickFirefox(t *testing.T) {
// browsers := pickFirefox("all")
// filetype := "json"
// dir := "result"
2022-04-11 11:57:40 +00:00
// output := outputter.New(filetype)
2022-04-11 07:53:19 +00:00
// if err := output.MakeDir("result"); err != nil {
// panic(err)
// }
// for _, b := range browsers {
// fmt.Printf("%+v\n", b)
// if err := b.CopyItemFileToLocal(); err != nil {
// panic(err)
// }
// masterKey, err := b.GetMasterKey()
// if err != nil {
// fmt.Println(err)
// }
2022-04-11 11:57:40 +00:00
// browserName := b.Name()
2022-04-11 07:53:19 +00:00
// multiData := b.GetBrowsingData()
// for _, data := range multiData {
// if err := data.Parse(masterKey); err != nil {
// fmt.Println(err)
// }
// filename := fmt.Sprintf("%s_%s.%s", browserName, data.Name(), filetype)
// file, err := output.CreateFile(dir, filename)
// if err != nil {
// panic(err)
// }
// if err := output.Write(data, file); err != nil {
// panic(err)
// }
// }
// }
// }