MCPcopy
hub / github.com/moonD4rk/HackBrowserData / TestWrite_JSON_Password

Function TestWrite_JSON_Password

output/output_test.go:151–179  ·  view source on GitHub ↗

--- JSON output ---

(t *testing.T)

Source from the content-addressed store, hash-verified

149// --- JSON output ---
150
151func TestWrite_JSON_Password(t *testing.T) {
152 dir := t.TempDir()
153 out, err := NewWriter(dir, "json")
154 require.NoError(t, err)
155 out.Add("Chrome", "Default", chromeData())
156 out.Add("Firefox", "abc123", firefoxData())
157 require.NoError(t, out.Write())
158
159 type pwJSON struct {
160 Browser string `json:"browser"`
161 Profile string `json:"profile"`
162 URL string `json:"url"`
163 Username string `json:"username"`
164 Password string `json:"password"`
165 CreatedAt time.Time `json:"created_at"`
166 }
167 var rows []pwJSON
168 readJSON(t, filepath.Join(dir, "password.json"), &rows)
169 require.Len(t, rows, 2)
170
171 assert.Equal(t, pwJSON{
172 Browser: "Chrome", Profile: "Default",
173 URL: "https://example.com", Username: "alice", Password: "secret", CreatedAt: testTime,
174 }, rows[0])
175 assert.Equal(t, pwJSON{
176 Browser: "Firefox", Profile: "abc123",
177 URL: "https://reddit.com", Username: "bob", Password: "hunter2", CreatedAt: testTime,
178 }, rows[1])
179}
180
181func TestWrite_JSON_Cookie(t *testing.T) {
182 dir := t.TempDir()

Callers

nothing calls this directly

Calls 7

AddMethod · 0.95
WriteMethod · 0.95
NewWriterFunction · 0.85
chromeDataFunction · 0.85
firefoxDataFunction · 0.85
readJSONFunction · 0.85
TempDirMethod · 0.80

Tested by

no test coverage detected