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

Function TestWrite_JSON_Cookie

output/output_test.go:181–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

179}
180
181func TestWrite_JSON_Cookie(t *testing.T) {
182 dir := t.TempDir()
183 out, err := NewWriter(dir, "json")
184 require.NoError(t, err)
185 out.Add("Chrome", "Default", chromeData())
186 require.NoError(t, out.Write())
187
188 type ckJSON struct {
189 Browser string `json:"browser"`
190 Profile string `json:"profile"`
191 Host string `json:"host"`
192 Path string `json:"path"`
193 Name string `json:"name"`
194 Value string `json:"value"`
195 IsSecure bool `json:"is_secure"`
196 IsHTTPOnly bool `json:"is_http_only"`
197 HasExpire bool `json:"has_expire"`
198 IsPersistent bool `json:"is_persistent"`
199 ExpireAt time.Time `json:"expire_at"`
200 CreatedAt time.Time `json:"created_at"`
201 }
202 var rows []ckJSON
203 readJSON(t, filepath.Join(dir, "cookie.json"), &rows)
204 require.Len(t, rows, 1)
205
206 assert.Equal(t, ckJSON{
207 Browser: "Chrome", Profile: "Default",
208 Host: ".example.com", Path: "/", Name: "session", Value: "abc123",
209 IsSecure: true, IsHTTPOnly: true, HasExpire: true, IsPersistent: true,
210 ExpireAt: testTime, CreatedAt: testTime,
211 }, rows[0])
212}
213
214func TestWrite_JSON_NoBOM(t *testing.T) {
215 dir := t.TempDir()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected