Archive-Har

 view release on metacpan or  search on metacpan

t/firebug_cookies_n_cache.t  view on Meta::CPAN

618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
      "value": "5128"
    },
    {
      "name": "Age",
      "value": "59687"
    }
  ],
  "content": {
    "mimeType": "text/css",
    "size": 33756,
    "text": "/* Copyright 2012 Google Inc. All Rights Reserved. */\n.goog-inline-block{position:relative;display:-moz-inline-box;display:inline-block}* html .goog-inline-block{display:inline}*:first-child+html .goog-inline-block{display:inlin...
  },
  "redirectURL": "",
  "headersSize": 387,
  "bodySize": 5128
},
"cache": {},
"timings": {
  "blocked": 0,
  "dns": 0,
  "connect": 134,

t/httpwatch_cookies_n_cache.t  view on Meta::CPAN

685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
        },
        {
            "name" : "X-XSS-Protection",
            "value" : "1; mode=block"
        }
    ],
    "content" : {
        "size" : 33756,
        "compression" : 28628,
        "mimeType" : "text/css; charset=utf-8",
        "text" : "/* Copyright 2012 Google Inc. All Rights Reserved. */\n.goog-inline-block{position:relative;display:-moz-inline-box;display:inline-block}* html .goog-inline-block{display:inline}*:first-child+html .goog-inline-block{...
    },
    "redirectURL" : "",
    "headersSize" : 388,
    "bodySize" : 5128
},
"cache" : {
    "beforeRequest" : null,
    "afterRequest" : {
        "expires" : "2012-05-02T07:50:40.000Z",
        "lastAccess" : "2012-04-03T22:13:52.000Z",

t/mandatory_optional.t  view on Meta::CPAN

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
ok($hash->{log}->{pages}->[0]->{id} eq 'page_0', "page->id is defined as page_0:$hash->{log}->{pages}->[0]->{id}");
ok(length $hash->{log}->{pages}->[0]->{title}, "page->title is defined:$hash->{log}->{pages}->[0]->{title}");
ok((defined $hash->{log}->{pages}->[0]->{pageTimings} and ref $hash->{log}->{pages}->[0]->{pageTimings} eq 'HASH'), "page->pageTimings is defined as a HASH");
 
ok($hash->{log}->{browser}->{comment} eq "test browser", "comment is correct");
ok($hash->{log}->{browser}->{_private} eq "browser", "_private value is correct");
$har->browser()->_private("value");
$hash = $har->hashref();
ok($hash->{log}->{browser}->{_private} eq "value", "new _private value is correct (1)");
ok($har->browser()->_private() eq "value", "new _private value is correct (2)");
eval { $har->browser()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{creator}->{comment} eq "test creator", "comment is correct");
ok($hash->{log}->{creator}->{_private} eq "creator", "_private value is correct");
$har->creator()->_private("value");
$hash = $har->hashref();
ok($hash->{log}->{creator}->{_private} eq "value", "new _private value is correct (1)");
ok($har->creator()->_private() eq "value", "new _private value is correct (2)");
eval { $har->creator()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
# entries
 
$checking = <<'_CHECK_';
{
  "log": {
        "entries": [ { "comment": "test entry", "_private": "entry", "cache": { "comment": "test cache", "_private": "cache", "beforeRequest": { "comment": "test beforeRequest", "_private": "beforeRequest" }, "afterRequest": null } } ]
   }
}
_CHECK_

t/mandatory_optional.t  view on Meta::CPAN

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
ok($hash->{log}->{entries}->[0]->{comment} eq "test entry", "comment is correct");
ok($hash->{log}->{entries}->[0]->{_private} eq "entry", "_private value is correct");
(($har->entries())[0])->_private(undef);
$hash = $har->hashref();
ok(!exists $hash->{log}->{entries}->[0]->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->_private("value");
$hash = $har->hashref();
ok($hash->{log}->{entries}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
eval { (($har->entries())[0])->started_date_time("not_formatted") };
ok($@ =~ /^started_date_time is not formatted correctly/, "started_date_time throws an exception with invalid input");
 
ok($hash->{log}->{entries}->[0]->{cache}->{comment} eq "test cache", "comment is correct");
ok($hash->{log}->{entries}->[0]->{cache}->{_private} eq "cache", "_private is correct");
(($har->entries())[0])->cache()->_private(undef);
$hash = $har->hashref();
ok(!exists $hash->{log}->{entries}->[0]->{cache}->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->cache()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{cache}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->cache()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->cache()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{entries}->[0]->{cache}->{beforeRequest}->{comment} eq "test beforeRequest", "comment is correct");
ok($hash->{log}->{entries}->[0]->{cache}->{beforeRequest}->{_private} eq "beforeRequest", "_private is correct");
(($har->entries())[0])->cache()->before_request()->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{cache}->{beforeRequest}->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->cache()->before_request()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{cache}->{beforeRequest}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->cache()->before_request()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->cache()->before_request()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
eval { (($har->entries())[0])->cache()->before_request()->last_access("not_formatted") };
ok($@ =~ /^last_access is not formatted correctly/, "last_access throws an exception with invalid input");
 
# request
 
ok(($hash->{log}->{entries}->[0]->{request}->{method} eq 'GET'), "request->method is GET by default");
ok(($hash->{log}->{entries}->[0]->{request}->{url} eq 'http://example.com/'), "request->url is http://example.com/ by default");
ok(($hash->{log}->{entries}->[0]->{request}->{httpVersion} eq 'HTTP/0.9'), "request->http_version is HTTP/0.9 by default");
ok(($hash->{log}->{entries}->[0]->{request}->{headersSize} == -1), "request->headersSize is -1 by default");
ok(($hash->{log}->{entries}->[0]->{request}->{bodySize} == -1), "request->bodySize is -1 by default");

t/mandatory_optional.t  view on Meta::CPAN

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
ok($hash->{log}->{entries}->[0]->{request}->{comment} eq "test request", "comment is correct");
ok($hash->{log}->{entries}->[0]->{request}->{_private} eq "request", "_private is correct");
(($har->entries())[0])->request()->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{request}->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->request()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->request()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->request()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{entries}->[0]->{response}->{comment} eq "test response", "comment is correct");
ok($hash->{log}->{entries}->[0]->{response}->{_private} eq "response", "_private is correct");
(($har->entries())[0])->response()->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{response}->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->response()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{response}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->response()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->response()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{entries}->[0]->{response}->{cookies}->[0]->{comment} eq "test cookie", "comment is correct");
ok($hash->{log}->{entries}->[0]->{response}->{cookies}->[0]->{_private} eq "cookie", "_private is correct");
(((($har->entries())[0])->response()->cookies())[0])->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{response}->{cookies}->[0]->{_private}, "new _private value is correct (2)");
(((($har->entries())[0])->response()->cookies())[0])->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{response}->{cookies}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((((($har->entries())[0])->response()->cookies())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (((($har->entries())[0])->response()->cookies())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{entries}->[0]->{response}->{content}->{comment} eq "test content", "comment is correct");
ok($hash->{log}->{entries}->[0]->{response}->{content}->{_private} eq "content", "_private is correct");
(($har->entries())[0])->response()->content()->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{response}->{content}->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->response()->content()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{response}->{content}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->response()->content()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->response()->content()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{entries}->[0]->{request}->{headers}->[0]->{comment} eq "test headers", "comment is correct");
ok($hash->{log}->{entries}->[0]->{request}->{headers}->[0]->{_private} eq "headers", "_private is correct");
(((($har->entries())[0])->request()->headers())[0])->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{request}->{headers}->[0]->{_private}, "new _private value is correct (2)");
(((($har->entries())[0])->request()->headers())[0])->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{headers}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((((($har->entries())[0])->request()->headers())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (((($har->entries())[0])->request()->headers())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{comment} eq "test postData", "comment is correct");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{_private} eq "postData", "_private is correct");
(($har->entries())[0])->request()->post_data()->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{request}->{postData}->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->request()->post_data()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->request()->post_data()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->request()->post_data()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{comment} eq "test params", "comment is correct");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{fileName} eq "example.pdf", "fileName is correct");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{contentType} eq "application/pdf", "contentType is correct");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{_private} eq "params", "_private is correct");
(((($har->entries())[0])->request()->post_data()->params())[0])->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{_private}, "new _private value is correct (2)");
(((($har->entries())[0])->request()->post_data()->params())[0])->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((((($har->entries())[0])->request()->post_data()->params())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (((($har->entries())[0])->request()->post_data()->params())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{entries}->[0]->{request}->{queryString}->[0]->{comment} eq "test queryString", "comment is correct");
ok($hash->{log}->{entries}->[0]->{request}->{queryString}->[0]->{_private} eq "queryString", "_private is correct");
(((($har->entries())[0])->request()->query_string())[0])->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{request}->{queryString}->[0]->{_private}, "new _private value is correct (2)");
(((($har->entries())[0])->request()->query_string())[0])->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{queryString}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((((($har->entries())[0])->request()->query_string())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (((($har->entries())[0])->request()->query_string())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
ok($hash->{log}->{entries}->[0]->{timings}->{comment} eq "test timings", "comment is correct");
ok($hash->{log}->{entries}->[0]->{timings}->{_private} eq "timings", "_private is correct");
(($har->entries())[0])->timings()->ssl(undef);
(($har->entries())[0])->timings()->blocked(undef);
(($har->entries())[0])->timings()->connect(undef);
(($har->entries())[0])->timings()->dns(undef);
(($har->entries())[0])->timings()->_private(undef);
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{timings}->{ssl} == -1, "timings ssl unavailable is correct");
ok($hash->{log}->{entries}->[0]->{timings}->{blocked} == -1, "timings blocked unavailable is correct");
ok($hash->{log}->{entries}->[0]->{timings}->{connect} == -1, "timings connect unavailable is correct");
ok($hash->{log}->{entries}->[0]->{timings}->{dns} == -1, "timings dns unavailable is correct");
ok(!exists $hash->{log}->{entries}->[0]->{timings}->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->timings()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{timings}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->timings()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->timings()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
 
(($har->entries())[0])->request()->post_data()->text("foobar");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{text} eq "foobar", "postData text is correct");
ok(!exists $hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0], "postData params does not exist");
 
$checking = <<'_CHECK_';
{
  "log": {
        "pages": [ { "comment": "test pages", "_private": "pages", "pageTimings": { "comment": "test pageTimings", "_private": "pageTimings" } } ]

t/mandatory_optional.t  view on Meta::CPAN

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
ok($hash, "Successfully read pages elements in har archive");
ok($hash->{log}->{pages}->[0]->{comment} eq "test pages", "comment is correct");
ok($hash->{log}->{pages}->[0]->{_private} eq "pages", "_private is correct");
(($har->pages())[0])->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{pages}->[0]->{_private}, "new _private value is correct (2)");
(($har->pages())[0])->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{pages}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((($har->pages())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (($har->pages())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
(($har->pages())[0])->started_date_time(undef);
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{pages}->[0]->{startedDateTime} eq '0000-00-00T00:00:00.0+00:00', "started_date_time is not defined");
eval { (($har->pages())[0])->started_date_time("not_formatted") };
ok($@ =~ /^started_date_time is not formatted correctly/, "started_date_time throws an exception with invalid input");
 
ok($hash->{log}->{pages}->[0]->{pageTimings}->{comment} eq "test pageTimings", "comment is correct");
ok($hash->{log}->{pages}->[0]->{pageTimings}->{_private} eq "pageTimings", "_private is correct");
(($har->pages())[0])->page_timings()->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{pages}->[0]->{pageTimings}->{_private}, "new _private value is correct (2)");
(($har->pages())[0])->page_timings()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{pages}->[0]->{pageTimings}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->pages())[0])->page_timings()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->pages())[0])->page_timings()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
eval { (($har->pages())[0])->page_timings()->on_content_load('sdf') };
ok($@ =~ /^on_content_load must be a positive number or -1/, "setting on_content_load to a non numeric throws an exception");
eval { (($har->pages())[0])->page_timings()->on_load('sdf') };
ok($@ =~ /^on_load must be a positive number or -1/, "setting on_load to a non numeric throws an exception");
 
no warnings;
eval "sub IO::Uncompress::Gunzip::gunzip { return; }";
my $plainData = "asdadsdsfsdF";
my $gzippedData ;



( run in 0.283 second using v1.01-cache-2.11-cpan-fb7fbe3ddfd )