HackBrowserData/filemanager/filemanager_test.go
moonD4rk 8b37ad577a
feat: introduce file manager for data extraction operations
- Added error handling for missing master key and data files in profile package
- Introduced error variables for missing files in profile package
- Implemented validation function for checking presence of master key and data files in profile package
- Created FileManager type for managing temporary file operations in filemanager package
- Implemented methods for copying profiles, copying profile data, and cleaning up temporary files in FileManager type
2024-11-25 00:04:31 +08:00

47 lines
1.1 KiB
Go

package filemanager
import (
"fmt"
"path/filepath"
"runtime"
"testing"
"github.com/stretchr/testify/assert"
"github.com/moond4rk/hackbrowserdata/profile"
"github.com/moond4rk/hackbrowserdata/types2"
)
func TestNewFileManager(t *testing.T) {
fm, err := NewFileManager()
assert.NoError(t, err)
defer fm.Cleanup()
fmt.Println(fm.TempDir)
}
func TestFileManager_CopyProfile(t *testing.T) {
if runtime.GOOS != "darwin" {
t.Skip("skipping test on non-darwin system")
}
paths, err := filepath.Glob(`/Users/*/Library/Application Support/Firefox/Profiles`)
assert.NoError(t, err)
if len(paths) == 0 {
t.Skip("no chrome profile found")
}
rootPath := paths[0]
browserType := types2.FirefoxType
dataTypes := types2.AllDataTypes
finder := profile.NewFinder()
profiles, err := finder.FindProfiles(rootPath, browserType, dataTypes)
assert.NoError(t, err)
assert.NotNil(t, profiles)
fmt.Println(profiles)
fm, err := NewFileManager()
assert.NoError(t, err)
fmt.Println(fm.TempDir)
defer fm.Cleanup()
newProfiles, err := fm.CopyProfiles(profiles)
assert.NoError(t, err)
_ = newProfiles
}