| 179 | } |
| 180 | |
| 181 | func 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 | |
| 214 | func TestWrite_JSON_NoBOM(t *testing.T) { |
| 215 | dir := t.TempDir() |