http-webtest-commits Mailing List for HTTP-WebTest (Page 7)
Brought to you by:
m_ilya,
richardanderson
You can subscribe to this list here.
| 2002 |
Jan
(38) |
Feb
(83) |
Mar
(10) |
Apr
(28) |
May
(42) |
Jun
(61) |
Jul
(43) |
Aug
(42) |
Sep
(14) |
Oct
(27) |
Nov
(16) |
Dec
(81) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(81) |
Feb
(29) |
Mar
(32) |
Apr
(42) |
May
(3) |
Jun
|
Jul
(11) |
Aug
|
Sep
(33) |
Oct
(6) |
Nov
(4) |
Dec
|
| 2004 |
Jan
|
Feb
|
Mar
(10) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Ilya M. <m_...@us...> - 2003-02-13 11:26:37
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest
In directory sc8-pr-cvs1:/tmp/cvs-serv29092/lib/HTTP/WebTest
Modified Files:
Recorder.pm
Log Message:
Added filtering of requests
Index: Recorder.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Recorder.pm 25 Jan 2003 18:22:55 -0000 1.5
--- Recorder.pm 13 Feb 2003 11:26:30 -0000 1.6
***************
*** 53,56 ****
--- 53,58 ----
# if recording is enabled
*is_recording = make_access_method('IS_RECORDING', sub { 0 });
+ # store filter settings
+ *filter = make_access_method('FILTER', sub { {} });
# serve web interface and do recording/proxying
***************
*** 69,73 ****
# proxy request
my $response = $self->user_agent->simple_request($request);
! if($self->is_recording) {
push @{$self->tests}, $self->make_test($request, $response);
}
--- 71,82 ----
# proxy request
my $response = $self->user_agent->simple_request($request);
! my $is_recording = $self->is_recording;
! if($self->filter->{header}) {
! while(my($header, $regexp) = each %{$self->filter->{header}}) {
! $is_recording &&= $response->header($header) =~ $regexp;
! }
! }
!
! if($is_recording) {
push @{$self->tests}, $self->make_test($request, $response);
}
|
|
From: Ilya M. <m_...@us...> - 2003-02-13 11:26:37
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv29092/t
Modified Files:
01-recorder.t
Log Message:
Added filtering of requests
Index: 01-recorder.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/01-recorder.t,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** 01-recorder.t 25 Jan 2003 18:24:27 -0000 1.6
--- 01-recorder.t 13 Feb 2003 11:26:30 -0000 1.7
***************
*** 8,12 ****
use HTTP::WebTest::SelfTest;
! use Test::More tests => 44;
# get test template files directory included in search path
--- 8,12 ----
use HTTP::WebTest::SelfTest;
! use Test::More tests => 46;
# get test template files directory included in search path
***************
*** 162,165 ****
--- 162,182 ----
method => 'POST' },
'Check test params for POST with params');
+ }
+
+ # test filtering of requests
+ {
+ my $recorder = new HTTP::WebTest::Recorder;
+ $recorder->is_recording(1);
+ $recorder->filter({ header => { Content_Type => qr|text/html| } });
+ my $request = GET abs_url($URL, '/content-type/text/plain');
+ $recorder->handle($request);
+ is(@{$recorder->tests}, 0,
+ 'Test if request to plain text file is not recorded');
+
+ $recorder->tests([]);
+ $request = GET abs_url($URL, '/content-type/text/html');
+ $recorder->handle($request);
+ is(@{$recorder->tests}, 1,
+ 'Test if request to html text file is recorded');
}
|
|
From: Ilya M. <m_...@us...> - 2003-02-02 17:30:27
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder In directory sc8-pr-cvs1:/tmp/cvs-serv24946 Modified Files: MANIFEST Log Message: Updated Index: MANIFEST =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/MANIFEST,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MANIFEST 1 Feb 2003 22:30:35 -0000 1.3 --- MANIFEST 2 Feb 2003 17:30:24 -0000 1.4 *************** *** 9,12 **** --- 9,13 ---- lib/HTTP/WebTest/Recorder/template/page.inc lib/HTTP/WebTest/Recorder/template/request + lib/HTTP/WebTest/Recorder/template/response_content lib/HTTP/WebTest/Recorder/template/wtscript t/01-recorder.t |
|
From: Ilya M. <m_...@us...> - 2003-02-02 17:27:45
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder
In directory sc8-pr-cvs1:/tmp/cvs-serv23429/lib/HTTP/WebTest/Recorder
Modified Files:
Actions.pm
Log Message:
Support text view of content body
Index: Actions.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Actions.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Actions.pm 2 Feb 2003 00:02:05 -0000 1.3
--- Actions.pm 2 Feb 2003 17:27:41 -0000 1.4
***************
*** 49,57 ****
my $num = $controller->cgi->param('num');
my $test = $controller->recorder->tests->[$num];
! $controller->raw_response(headers => [ 'Content-Type' =>
! $test->response->content_type ],
! content => $test->response->content);
}
--- 49,63 ----
my $num = $controller->cgi->param('num');
+ my $view = $controller->cgi->param('view');
my $test = $controller->recorder->tests->[$num];
! if($view eq 'raw') {
! $controller->raw_response(headers => [ 'Content-Type' =>
! $test->response->content_type ],
! content => $test->response->content);
! } else {
! return(default_action($controller),
! content => $test->response->content);
! }
}
|
|
From: Ilya M. <m_...@us...> - 2003-02-02 17:27:45
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv23429/t
Modified Files:
03-actions.t
Log Message:
Support text view of content body
Index: 03-actions.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/03-actions.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** 03-actions.t 2 Feb 2003 00:02:42 -0000 1.3
--- 03-actions.t 2 Feb 2003 17:27:41 -0000 1.4
***************
*** 6,10 ****
use HTTP::Status;
! use Test::More tests => 31;
use Test::Exception;
--- 6,10 ----
use HTTP::Status;
! use Test::More tests => 32;
use Test::Exception;
***************
*** 163,167 ****
# test response_content_action()
{
! $CONTROLLER->cgi(CGI->new({num => 0}));
dies_ok { response_content_action($CONTROLLER) } 'Expect raw response';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::RawResponse',
--- 163,167 ----
# test response_content_action()
{
! $CONTROLLER->cgi(CGI->new({num => 0, view => 'raw'}));
dies_ok { response_content_action($CONTROLLER) } 'Expect raw response';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::RawResponse',
***************
*** 173,177 ****
'Test headers property of exception');
! $CONTROLLER->cgi(CGI->new({num => 2}));
dies_ok { response_content_action($CONTROLLER) } 'Expect raw response';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::RawResponse',
--- 173,177 ----
'Test headers property of exception');
! $CONTROLLER->cgi(CGI->new({num => 2, view => 'raw'}));
dies_ok { response_content_action($CONTROLLER) } 'Expect raw response';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::RawResponse',
***************
*** 182,184 ****
--- 182,189 ----
[ 'Content-Type' => 'text/plain' ],
'Test headers property of exception');
+
+ $CONTROLLER->cgi(CGI->new({num => 0, view => 'text'}));
+ my %data = response_content_action($CONTROLLER);
+ is($data{content}, $RECORDER->tests->[0]->response->content,
+ "Test if action doesn't die and returns response content");
}
|
|
From: Ilya M. <m_...@us...> - 2003-02-02 17:26:58
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/template
In directory sc8-pr-cvs1:/tmp/cvs-serv23076/lib/HTTP/WebTest/Recorder/template
Modified Files:
request
Log Message:
Added link on text view of content body
Index: request
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/template/request,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** request 1 Feb 2003 23:59:04 -0000 1.2
--- request 2 Feb 2003 17:26:54 -0000 1.3
***************
*** 3,7 ****
%]
- [% USE HTML %]
[% USE test_request_url = URL(test.request.uri) %]
[% USE response_content_url = URL('response_content') %]
--- 3,6 ----
***************
*** 12,26 ****
<th>Request</th>
<td>
! <pre>[% HTML.escape(test.request.method) %] <a href="[% test_request_url %]">[% HTML.escape(test.request.uri) %]</a></pre>
</td>
</tr>
<tr>
<th>Headers</th>
! <td><pre>[% HTML.escape(test.request.headers_as_string) %]</pre></td>
</tr>
[% IF test.request.content %]
<tr>
<th>Content</th>
! <td><pre>[% HTML.escape(test.request.content) %]</pre></td>
</tr>
[% END %]
--- 11,25 ----
<th>Request</th>
<td>
! <pre>[% test.request.method | html %] <a href="[% test_request_url %]">[% test.request.uri | html %]</a></pre>
</td>
</tr>
<tr>
<th>Headers</th>
! <td><pre>[% test.request.headers_as_string | html %]</pre></td>
</tr>
[% IF test.request.content %]
<tr>
<th>Content</th>
! <td><pre>[% test.request.content | html %]</pre></td>
</tr>
[% END %]
***************
*** 30,43 ****
<tr>
<th>Status Line</th>
! <td><pre>[% HTML.escape(test.response.status_line) %]</pre></td>
</tr>
<tr>
<th>Headers</th>
! <td><pre>[% HTML.escape(test.response.headers_as_string) %]</pre></td>
</tr>
[% IF test.response.content %]
<tr>
<th>Content</th>
! <td><a href="[% response_content_url(num => num) %]">Click to see</a></td>
</tr>
[% END %]
--- 29,45 ----
<tr>
<th>Status Line</th>
! <td><pre>[% test.response.status_line | html %]</pre></td>
</tr>
<tr>
<th>Headers</th>
! <td><pre>[% test.response.headers_as_string | html %]</pre></td>
</tr>
[% IF test.response.content %]
<tr>
<th>Content</th>
! <td>
! <a href="[% response_content_url(num => num, view => 'raw') %]">View</a>
! (as <a href="[% response_content_url(num => num, view => 'text') %]">plain text</a>)
! </td>
</tr>
[% END %]
|
|
From: Ilya M. <m_...@us...> - 2003-02-02 17:26:13
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/template In directory sc8-pr-cvs1:/tmp/cvs-serv22550/lib/HTTP/WebTest/Recorder/template Added Files: response_content Log Message: Added --- NEW FILE: response_content --- [% WRAPPER page.inc title => 'Show Response Content' %] <pre>[% content | html %]</pre> [% END %] |
|
From: Ilya M. <m_...@us...> - 2003-02-02 17:25:08
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/template
In directory sc8-pr-cvs1:/tmp/cvs-serv20781/lib/HTTP/WebTest/Recorder/template
Modified Files:
wtscript page.inc list
Log Message:
Don't use HTML plugin but rather use html filter
Index: wtscript
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/template/wtscript,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** wtscript 25 Jan 2003 14:54:51 -0000 1.1
--- wtscript 2 Feb 2003 17:25:00 -0000 1.2
***************
*** 3,10 ****
%]
- [% USE HTML %]
-
<pre>
! [% HTML.escape(wtscript) %]
</pre>
--- 3,8 ----
%]
<pre>
! [% wtscript | html %]
</pre>
Index: page.inc
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/template/page.inc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** page.inc 25 Jan 2003 15:24:47 -0000 1.2
--- page.inc 2 Feb 2003 17:25:00 -0000 1.3
***************
*** 1,13 ****
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
- [% USE HTML %]
-
<html>
<head>
! <title>[% HTML.escape(title) %]</title>
</head>
<body>
! <h1>[% HTML.escape(title) %]</h1>
[% content %]
--- 1,11 ----
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
! <title>[% title | html %]</title>
</head>
<body>
! <h1>[% title | html %]</h1>
[% content %]
Index: list
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/template/list,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** list 25 Jan 2003 15:24:47 -0000 1.2
--- list 2 Feb 2003 17:25:00 -0000 1.3
***************
*** 3,7 ****
%]
- [% USE HTML %]
[% USE enable_url = URL('enable') %]
--- 3,6 ----
***************
*** 21,28 ****
<td>
<a href="[% request_url(num => loop.index) %]">
! [% HTML.escape(test.request.uri) %]
</a>
</td>
! <td>[% HTML.escape(test.response.status_line) %]</td>
</tr>
[% END %]
--- 20,27 ----
<td>
<a href="[% request_url(num => loop.index) %]">
! [% test.request.uri | html %]
</a>
</td>
! <td>[% test.response.status_line | html %]</td>
</tr>
[% END %]
|
|
From: Ilya M. <m_...@us...> - 2003-02-02 00:02:45
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv12320/t
Modified Files:
03-actions.t 02-controller.t
Log Message:
Updated
Index: 03-actions.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/03-actions.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** 03-actions.t 1 Feb 2003 22:40:07 -0000 1.2
--- 03-actions.t 2 Feb 2003 00:02:42 -0000 1.3
***************
*** 6,10 ****
use HTTP::Status;
! use Test::More tests => 23;
use Test::Exception;
--- 6,10 ----
use HTTP::Status;
! use Test::More tests => 31;
use Test::Exception;
***************
*** 56,70 ****
{
$CONTROLLER->cgi(CGI->new({num => 0}));
! my %data = request_action($CONTROLLER);
! is($data{test}, $RECORDER->tests->[0],
! 'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 1}));
! %data = request_action($CONTROLLER);
! is($data{test}, $RECORDER->tests->[1],
! 'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 2}));
! %data = request_action($CONTROLLER);
is($data{test}, undef,
'Check if "test" variable is not defined');
--- 56,74 ----
{
$CONTROLLER->cgi(CGI->new({num => 0}));
! is_deeply({ request_action($CONTROLLER) },
! { controller => $CONTROLLER,
! test => $RECORDER->tests->[0],
! num => 0 },
! 'Test if test and test num are returned');
$CONTROLLER->cgi(CGI->new({num => 1}));
! is_deeply({ request_action($CONTROLLER) },
! { controller => $CONTROLLER,
! test => $RECORDER->tests->[1],
! num => 1 },
! 'Test if test and test num are returned');
$CONTROLLER->cgi(CGI->new({num => 2}));
! my %data = request_action($CONTROLLER);
is($data{test}, undef,
'Check if "test" variable is not defined');
***************
*** 76,79 ****
--- 80,84 ----
my $request = GET 'http://example.com/doc1.html';
my $response = HTTP::Response->new(RC_OK);
+ $response->header('Content-Type' => 'text/xml');
$response->content('DOC #1');
push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
***************
*** 89,92 ****
--- 94,98 ----
my $request = GET 'http://example.com/doc3.html?a=b&a=c';
my $response = HTTP::Response->new(RC_OK);
+ $response->header('Content-Type' => 'text/plain');
$response->content('DOC #2');
push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
***************
*** 153,155 ****
--- 159,184 ----
is($@->url, 'list', 'Test url property of exception');
ok($CONTROLLER->recorder->is_recording, 'Recording');
+ }
+
+ # test response_content_action()
+ {
+ $CONTROLLER->cgi(CGI->new({num => 0}));
+ dies_ok { response_content_action($CONTROLLER) } 'Expect raw response';
+ isa_ok($@, 'HTTP::WebTest::Recorder::Exception::RawResponse',
+ 'Verify exception class');
+ is($@->content, $RECORDER->tests->[0]->response->content,
+ 'Test content property of exception');
+ is_deeply($@->headers,
+ [ 'Content-Type' => 'text/xml' ],
+ 'Test headers property of exception');
+
+ $CONTROLLER->cgi(CGI->new({num => 2}));
+ dies_ok { response_content_action($CONTROLLER) } 'Expect raw response';
+ isa_ok($@, 'HTTP::WebTest::Recorder::Exception::RawResponse',
+ 'Verify exception class');
+ is($@->content, $RECORDER->tests->[2]->response->content,
+ 'Test content property of exception');
+ is_deeply($@->headers,
+ [ 'Content-Type' => 'text/plain' ],
+ 'Test headers property of exception');
}
Index: 02-controller.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/02-controller.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** 02-controller.t 1 Feb 2003 22:25:32 -0000 1.4
--- 02-controller.t 2 Feb 2003 00:02:43 -0000 1.5
***************
*** 6,10 ****
use HTTP::Status;
! use Test::More tests => 34;
use Test::Exception;
--- 6,10 ----
use HTTP::Status;
! use Test::More tests => 41;
use Test::Exception;
***************
*** 119,124 ****
local %HTTP::WebTest::Recorder::Controller::DISPATCH =
( redirect => $test_redirect );
- # just to disable used only once warning
- () = %HTTP::WebTest::Recorder::Controller::DISPATCH;
my $request = GET 'http://localhost/webtest/redirect';
--- 119,122 ----
***************
*** 128,130 ****
--- 126,163 ----
is($response->header('Location'), 'xxx',
'Check if we got correct Location header');
+ }
+
+ # test raw_response()
+ {
+ my $headers = [ 'Content-Type' => 'image/png' ];
+ my $content = "Expect the worst, it's the least you can do.";
+
+ dies_ok { $CONTROLLER->raw_response(headers => $headers,
+ content => $content) }
+ 'Expecting raw response exception';
+ isa_ok($@, 'HTTP::WebTest::Recorder::Exception::RawResponse',
+ 'Verify exception class');
+ is($@->headers, $headers, 'Test headers property of exception');
+ is($@->content, $content, 'Test content property of exception');
+ }
+
+ # try to access page that generates a raw response
+ {
+ my $test_raw_response = sub {
+ my $controller = shift;
+
+ return $controller->raw_response(headers =>
+ [ 'Content-Type', 'text/xml' ],
+ content => 'Bla Bla');
+ };
+ local %HTTP::WebTest::Recorder::Controller::DISPATCH =
+ ( raw_response => $test_raw_response );
+
+ my $request = GET 'http://localhost/webtest/raw_response';
+ my $response = $CONTROLLER->execute(action => 'raw_response',
+ request => $request);
+ is($response->code, RC_OK, 'Expect ok status');
+ is($response->content, 'Bla Bla', 'Verify content in response');
+ is($response->header('Content-Type'), 'text/xml',
+ 'Verify headers in response');
}
|
|
From: Ilya M. <m_...@us...> - 2003-02-02 00:02:08
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder
In directory sc8-pr-cvs1:/tmp/cvs-serv12117/lib/HTTP/WebTest/Recorder
Modified Files:
Actions.pm
Log Message:
Added response_content_action()
Index: Actions.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Actions.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Actions.pm 1 Feb 2003 22:40:08 -0000 1.2
--- Actions.pm 2 Feb 2003 00:02:05 -0000 1.3
***************
*** 8,12 ****
@EXPORT_OK = qw(default_action enable_action list_action
! request_action wtscript_action);
%EXPORT_TAGS = (all => [@EXPORT_OK]);
--- 8,12 ----
@EXPORT_OK = qw(default_action enable_action list_action
! request_action response_content_action wtscript_action);
%EXPORT_TAGS = (all => [@EXPORT_OK]);
***************
*** 42,47 ****
return(default_action($controller),
! test => $test);
}
sub wtscript_action {
my $controller = shift;
--- 42,59 ----
return(default_action($controller),
! test => $test, num => $num);
! }
!
! sub response_content_action {
! my $controller = shift;
!
! my $num = $controller->cgi->param('num');
! my $test = $controller->recorder->tests->[$num];
!
! $controller->raw_response(headers => [ 'Content-Type' =>
! $test->response->content_type ],
! content => $test->response->content);
}
+
sub wtscript_action {
my $controller = shift;
|
|
From: Ilya M. <m_...@us...> - 2003-02-02 00:01:11
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder
In directory sc8-pr-cvs1:/tmp/cvs-serv11763/lib/HTTP/WebTest/Recorder
Modified Files:
Exceptions.pm
Log Message:
Added raw response exception
Index: Exceptions.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Exceptions.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Exceptions.pm 25 Jan 2003 14:54:52 -0000 1.1
--- Exceptions.pm 2 Feb 2003 00:01:07 -0000 1.2
***************
*** 12,17 ****
HTTP::WebTest::Recorder::Exception::Redirect =>
{ isa => 'HTTP::WebTest::Recorder::Exception',
! fields => [ 'url' ],
description => 'Redirect message' },
);
}
--- 12,22 ----
HTTP::WebTest::Recorder::Exception::Redirect =>
{ isa => 'HTTP::WebTest::Recorder::Exception',
! fields => [ qw(url) ],
description => 'Redirect message' },
+
+ HTTP::WebTest::Recorder::Exception::RawResponse =>
+ { isa => 'HTTP::WebTest::Recorder::Exception',
+ fields => [ qw(headers content) ],
+ description => 'Raw response message' },
);
}
|
|
From: Ilya M. <m_...@us...> - 2003-02-02 00:00:22
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder
In directory sc8-pr-cvs1:/tmp/cvs-serv11536/lib/HTTP/WebTest/Recorder
Modified Files:
Controller.pm
Log Message:
Support raw response made by actions
Index: Controller.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Controller.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Controller.pm 1 Feb 2003 22:40:07 -0000 1.4
--- Controller.pm 2 Feb 2003 00:00:18 -0000 1.5
***************
*** 34,42 ****
use vars qw(%DISPATCH);
! %DISPATCH = (list => \&list_action,
! request => \&request_action,
! wtscript => \&wtscript_action,
! enable => \&enable_action,
! default => \&default_action);
# serves requests for web interface of the proxy
--- 34,43 ----
use vars qw(%DISPATCH);
! %DISPATCH = (list => \&list_action,
! request => \&request_action,
! response_content => \&response_content_action,
! wtscript => \&wtscript_action,
! enable => \&enable_action,
! default => \&default_action);
# serves requests for web interface of the proxy
***************
*** 61,64 ****
--- 62,69 ----
$response = HTTP::Response->new(RC_FOUND);
$response->header(Location => $@->url);
+ } elsif($@->isa('HTTP::WebTest::Recorder::Exception::RawResponse')) {
+ $response = HTTP::Response->new(RC_OK);
+ $response->header(@{$@->headers});
+ $response->content($@->content);
} else {
$@->rethrow;
***************
*** 101,104 ****
--- 106,119 ----
HTTP::WebTest::Recorder::Exception::Redirect->throw(message => 'Redirect',
url => $url);
+ }
+
+ # generates raw response exception
+ sub raw_response {
+ my $self = shift;
+ my %param = @_;
+
+ $param{message} = 'Raw Response';
+
+ HTTP::WebTest::Recorder::Exception::RawResponse->throw(%param);
}
|
|
From: Ilya M. <m_...@us...> - 2003-02-01 23:59:10
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/template
In directory sc8-pr-cvs1:/tmp/cvs-serv11084/lib/HTTP/WebTest/Recorder/template
Modified Files:
request
Log Message:
Show link on response content view
Index: request
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/template/request,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** request 25 Jan 2003 14:54:51 -0000 1.1
--- request 1 Feb 2003 23:59:04 -0000 1.2
***************
*** 4,8 ****
[% USE HTML %]
! [% USE request_url = URL(test.request.uri) %]
<table>
--- 4,9 ----
[% USE HTML %]
! [% USE test_request_url = URL(test.request.uri) %]
! [% USE response_content_url = URL('response_content') %]
<table>
***************
*** 11,15 ****
<th>Request</th>
<td>
! <pre>[% HTML.escape(test.request.method) %] <a href="[% request_url %]">[% HTML.escape(test.request.uri) %]</a></pre>
</td>
</tr>
--- 12,16 ----
<th>Request</th>
<td>
! <pre>[% HTML.escape(test.request.method) %] <a href="[% test_request_url %]">[% HTML.escape(test.request.uri) %]</a></pre>
</td>
</tr>
***************
*** 35,38 ****
--- 36,45 ----
<td><pre>[% HTML.escape(test.response.headers_as_string) %]</pre></td>
</tr>
+ [% IF test.response.content %]
+ <tr>
+ <th>Content</th>
+ <td><a href="[% response_content_url(num => num) %]">Click to see</a></td>
+ </tr>
+ [% END %]
</table>
|
|
From: Ilya M. <m_...@us...> - 2003-02-01 22:40:13
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder In directory sc8-pr-cvs1:/tmp/cvs-serv20975/lib/HTTP/WebTest/Recorder Modified Files: Controller.pm Actions.pm Log Message: Export action subs from Actions.pm Index: Controller.pm =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Controller.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Controller.pm 1 Feb 2003 22:29:58 -0000 1.3 --- Controller.pm 1 Feb 2003 22:40:07 -0000 1.4 *************** *** 12,16 **** use HTTP::WebTest::Recorder::Exceptions; ! use HTTP::WebTest::Recorder::Actions; # constructor --- 12,16 ---- use HTTP::WebTest::Recorder::Exceptions; ! use HTTP::WebTest::Recorder::Actions qw(:all); # constructor *************** *** 34,42 **** use vars qw(%DISPATCH); ! %DISPATCH = (list => \&HTTP::WebTest::Recorder::Actions::list_action, ! request => \&HTTP::WebTest::Recorder::Actions::request_action, ! wtscript => \&HTTP::WebTest::Recorder::Actions::wtscript_action, ! enable => \&HTTP::WebTest::Recorder::Actions::enable_action, ! default => \&HTTP::WebTest::Recorder::Actions::default_action); # serves requests for web interface of the proxy --- 34,42 ---- use vars qw(%DISPATCH); ! %DISPATCH = (list => \&list_action, ! request => \&request_action, ! wtscript => \&wtscript_action, ! enable => \&enable_action, ! default => \&default_action); # serves requests for web interface of the proxy Index: Actions.pm =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Actions.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Actions.pm 1 Feb 2003 22:29:58 -0000 1.1 --- Actions.pm 1 Feb 2003 22:40:08 -0000 1.2 *************** *** 3,6 **** --- 3,14 ---- use strict; + use base qw(Exporter); + + use vars qw(@EXPORT_OK %EXPORT_TAGS); + + @EXPORT_OK = qw(default_action enable_action list_action + request_action wtscript_action); + %EXPORT_TAGS = (all => [@EXPORT_OK]); + use HTTP::WebTest::Parser; |
|
From: Ilya M. <m_...@us...> - 2003-02-01 22:40:13
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv20975/t
Modified Files:
03-actions.t
Log Message:
Export action subs from Actions.pm
Index: 03-actions.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/03-actions.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** 03-actions.t 1 Feb 2003 22:29:58 -0000 1.1
--- 03-actions.t 1 Feb 2003 22:40:07 -0000 1.2
***************
*** 12,16 ****
use lib 't';
! require_ok('HTTP::WebTest::Recorder::Actions');
require_ok('HTTP::WebTest::Recorder::Controller');
require_ok('HTTP::WebTest::Recorder');
--- 12,16 ----
use lib 't';
! BEGIN { use_ok('HTTP::WebTest::Recorder::Actions', ':all') }
require_ok('HTTP::WebTest::Recorder::Controller');
require_ok('HTTP::WebTest::Recorder');
***************
*** 25,29 ****
# test default_action()
{
! is_deeply([HTTP::WebTest::Recorder::Actions::default_action($CONTROLLER)],
[controller => $CONTROLLER],
'Test template_data()');
--- 25,29 ----
# test default_action()
{
! is_deeply([default_action($CONTROLLER)],
[controller => $CONTROLLER],
'Test template_data()');
***************
*** 32,36 ****
# test list_action()
{
! my %data = HTTP::WebTest::Recorder::Actions::list_action($CONTROLLER);
is($data{tests}, $RECORDER->tests,
'Check if "tests" variable is defined');
--- 32,36 ----
# test list_action()
{
! my %data = list_action($CONTROLLER);
is($data{tests}, $RECORDER->tests,
'Check if "tests" variable is defined');
***************
*** 56,70 ****
{
$CONTROLLER->cgi(CGI->new({num => 0}));
! my %data = HTTP::WebTest::Recorder::Actions::request_action($CONTROLLER);
is($data{test}, $RECORDER->tests->[0],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 1}));
! %data = HTTP::WebTest::Recorder::Actions::request_action($CONTROLLER);
is($data{test}, $RECORDER->tests->[1],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 2}));
! %data = HTTP::WebTest::Recorder::Actions::request_action($CONTROLLER);
is($data{test}, undef,
'Check if "test" variable is not defined');
--- 56,70 ----
{
$CONTROLLER->cgi(CGI->new({num => 0}));
! my %data = request_action($CONTROLLER);
is($data{test}, $RECORDER->tests->[0],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 1}));
! %data = request_action($CONTROLLER);
is($data{test}, $RECORDER->tests->[1],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 2}));
! %data = request_action($CONTROLLER);
is($data{test}, undef,
'Check if "test" variable is not defined');
***************
*** 95,99 ****
# test wtscript_action()
{
! my %data = HTTP::WebTest::Recorder::Actions::wtscript_action($CONTROLLER);
is($data{wtscript}, <<'WTSCRIPT',
test_name = N/A
--- 95,99 ----
# test wtscript_action()
{
! my %data = wtscript_action($CONTROLLER);
is($data{wtscript}, <<'WTSCRIPT',
test_name = N/A
***************
*** 128,133 ****
{
$CONTROLLER->cgi(CGI->new({ enable => 1 }));
! dies_ok { HTTP::WebTest::Recorder::Actions::enable_action($CONTROLLER) }
! 'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
'Verify exception class');
--- 128,132 ----
{
$CONTROLLER->cgi(CGI->new({ enable => 1 }));
! dies_ok { enable_action($CONTROLLER) } 'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
'Verify exception class');
***************
*** 139,144 ****
{
$CONTROLLER->cgi(CGI->new({ enable => 0 }));
! dies_ok { HTTP::WebTest::Recorder::Actions::enable_action($CONTROLLER) }
! 'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
'Verify exception class');
--- 138,142 ----
{
$CONTROLLER->cgi(CGI->new({ enable => 0 }));
! dies_ok { enable_action($CONTROLLER) } 'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
'Verify exception class');
***************
*** 150,155 ****
{
$CONTROLLER->cgi(CGI->new({ enable => 1 }));
! dies_ok { HTTP::WebTest::Recorder::Actions::enable_action($CONTROLLER) }
! 'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
'Verify exception class');
--- 148,152 ----
{
$CONTROLLER->cgi(CGI->new({ enable => 1 }));
! dies_ok { enable_action($CONTROLLER) } 'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
'Verify exception class');
|
|
From: Ilya M. <m_...@us...> - 2003-02-01 22:30:38
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder In directory sc8-pr-cvs1:/tmp/cvs-serv18767 Modified Files: MANIFEST Log Message: Updated Index: MANIFEST =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/MANIFEST,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MANIFEST 25 Jan 2003 14:58:14 -0000 1.2 --- MANIFEST 1 Feb 2003 22:30:35 -0000 1.3 *************** *** 3,11 **** bin/rec-proxy lib/HTTP/WebTest/Recorder.pm ! lib/HTTP/WebTest/Recorder/Action.pm ! lib/HTTP/WebTest/Recorder/Action/Enable.pm ! lib/HTTP/WebTest/Recorder/Action/List.pm ! lib/HTTP/WebTest/Recorder/Action/Request.pm ! lib/HTTP/WebTest/Recorder/Action/WTScript.pm lib/HTTP/WebTest/Recorder/Controller.pm lib/HTTP/WebTest/Recorder/Exceptions.pm --- 3,7 ---- bin/rec-proxy lib/HTTP/WebTest/Recorder.pm ! lib/HTTP/WebTest/Recorder/Actions.pm lib/HTTP/WebTest/Recorder/Controller.pm lib/HTTP/WebTest/Recorder/Exceptions.pm *************** *** 16,24 **** t/01-recorder.t t/02-controller.t ! t/03-action.t ! t/04-action-list.t ! t/05-action-request.t ! t/06-action-wtscript.t ! t/07-action-enable.t t/50-web.t t/HTTP/WebTest/Recorder/template/testcrash --- 12,16 ---- t/01-recorder.t t/02-controller.t ! t/03-actions.t t/50-web.t t/HTTP/WebTest/Recorder/template/testcrash |
|
From: Ilya M. <m_...@us...> - 2003-02-01 22:30:03
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv18476/t
Added Files:
03-actions.t
Removed Files:
03-action.t
Log Message:
Rename package Action to Actions
--- NEW FILE: 03-actions.t ---
#!/usr/bin/perl -w
use strict;
use HTTP::Request::Common;
use HTTP::Status;
use Test::More tests => 23;
use Test::Exception;
# get test template files directory included in search path
use lib 't';
require_ok('HTTP::WebTest::Recorder::Actions');
require_ok('HTTP::WebTest::Recorder::Controller');
require_ok('HTTP::WebTest::Recorder');
# test constructors
my $CONTROLLER = new HTTP::WebTest::Recorder::Controller;
isa_ok($CONTROLLER, 'HTTP::WebTest::Recorder::Controller');
my $RECORDER = new HTTP::WebTest::Recorder;
isa_ok($RECORDER, 'HTTP::WebTest::Recorder');
$CONTROLLER->recorder($RECORDER);
# test default_action()
{
is_deeply([HTTP::WebTest::Recorder::Actions::default_action($CONTROLLER)],
[controller => $CONTROLLER],
'Test template_data()');
}
# test list_action()
{
my %data = HTTP::WebTest::Recorder::Actions::list_action($CONTROLLER);
is($data{tests}, $RECORDER->tests,
'Check if "tests" variable is defined');
}
# init recorder with some data
{
my $test1 = HTTP::WebTest::Test->new;
$test1->request(GET 'http://example.com/doc1.html');
$test1->response(HTTP::Response->new(RC_OK));
$test1->response->content('DOC #1');
my $test2 = HTTP::WebTest::Test->new;
$test2->request(POST 'http://example.com/doc2.html',
[ xx => 'yy', 1 => 2]);
$test2->response(HTTP::Response->new(RC_NOT_FOUND));
$test2->response->content('Not Found');
push @{$RECORDER->tests}, $test1, $test2;
}
# test request_action()
{
$CONTROLLER->cgi(CGI->new({num => 0}));
my %data = HTTP::WebTest::Recorder::Actions::request_action($CONTROLLER);
is($data{test}, $RECORDER->tests->[0],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 1}));
%data = HTTP::WebTest::Recorder::Actions::request_action($CONTROLLER);
is($data{test}, $RECORDER->tests->[1],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 2}));
%data = HTTP::WebTest::Recorder::Actions::request_action($CONTROLLER);
is($data{test}, undef,
'Check if "test" variable is not defined');
}
# reinit recorder with some test data
{
$RECORDER->tests([]);
my $request = GET 'http://example.com/doc1.html';
my $response = HTTP::Response->new(RC_OK);
$response->content('DOC #1');
push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
}
{
my $request = (POST 'http://example.com/doc2.html',
[ xx => 'yy', 1 => 2]);
my $response = HTTP::Response->new(RC_NOT_FOUND);
$response->content('Not Found');
push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
}
{
my $request = GET 'http://example.com/doc3.html?a=b&a=c';
my $response = HTTP::Response->new(RC_OK);
$response->content('DOC #2');
push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
}
# test wtscript_action()
{
my %data = HTTP::WebTest::Recorder::Actions::wtscript_action($CONTROLLER);
is($data{wtscript}, <<'WTSCRIPT',
test_name = N/A
url = http://example.com/doc1.html
end_test
test_name = N/A
method = POST
params = (
xx
yy
1
2
)
url = http://example.com/doc2.html
end_test
test_name = N/A
params = (
a
b
a
c
)
url = http://example.com/doc3.html
end_test
WTSCRIPT
'Check if "wtscript" variable is defined');
}
# test with enable_action() if we can turn on recording
{
$CONTROLLER->cgi(CGI->new({ enable => 1 }));
dies_ok { HTTP::WebTest::Recorder::Actions::enable_action($CONTROLLER) }
'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
'Verify exception class');
is($@->url, 'list', 'Test url property of exception');
ok($CONTROLLER->recorder->is_recording, 'Recording');
}
# test with enable_action() if we can turn off recording
{
$CONTROLLER->cgi(CGI->new({ enable => 0 }));
dies_ok { HTTP::WebTest::Recorder::Actions::enable_action($CONTROLLER) }
'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
'Verify exception class');
is($@->url, 'list', 'Test url property of exception');
ok(not($CONTROLLER->recorder->is_recording), 'Not recording');
}
# test with enable_action() if we can turn on recording once again
{
$CONTROLLER->cgi(CGI->new({ enable => 1 }));
dies_ok { HTTP::WebTest::Recorder::Actions::enable_action($CONTROLLER) }
'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
'Verify exception class');
is($@->url, 'list', 'Test url property of exception');
ok($CONTROLLER->recorder->is_recording, 'Recording');
}
--- 03-action.t DELETED ---
|
|
From: Ilya M. <m_...@us...> - 2003-02-01 22:30:03
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder
In directory sc8-pr-cvs1:/tmp/cvs-serv18476/lib/HTTP/WebTest/Recorder
Modified Files:
Controller.pm
Added Files:
Actions.pm
Removed Files:
Action.pm
Log Message:
Rename package Action to Actions
--- NEW FILE: Actions.pm ---
package HTTP::WebTest::Recorder::Actions;
use strict;
use HTTP::WebTest::Parser;
sub default_action {
my $controller = shift;
return(controller => $controller);
}
sub enable_action {
my $controller = shift;
my $enable = $controller->cgi->param('enable');
$controller->recorder->is_recording($enable);
$controller->redirect('list');
}
sub list_action {
my $controller = shift;
return(default_action($controller),
tests => $controller->recorder->tests);
}
sub request_action {
my $controller = shift;
my $num = $controller->cgi->param('num');
my $test = $controller->recorder->tests->[$num];
return(default_action($controller),
test => $test);
}
sub wtscript_action {
my $controller = shift;
my $wtscript = (join "\n", map _test2wtscript($_),
@{$controller->recorder->tests});
return(default_action($controller),
wtscript => $wtscript);
}
sub _test2wtscript {
my $test = shift;
my @params = map +($_ => $test->params->{$_}), sort keys %{$test->params};
return HTTP::WebTest::Parser->write_test(\@params);
}
1;
Index: Controller.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Controller.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Controller.pm 1 Feb 2003 22:25:33 -0000 1.2
--- Controller.pm 1 Feb 2003 22:29:58 -0000 1.3
***************
*** 12,16 ****
use HTTP::WebTest::Recorder::Exceptions;
! use HTTP::WebTest::Recorder::Action;
# constructor
--- 12,16 ----
use HTTP::WebTest::Recorder::Exceptions;
! use HTTP::WebTest::Recorder::Actions;
# constructor
***************
*** 34,42 ****
use vars qw(%DISPATCH);
! %DISPATCH = (list => \&HTTP::WebTest::Recorder::Action::list_action,
! request => \&HTTP::WebTest::Recorder::Action::request_action,
! wtscript => \&HTTP::WebTest::Recorder::Action::wtscript_action,
! enable => \&HTTP::WebTest::Recorder::Action::enable_action,
! default => \&HTTP::WebTest::Recorder::Action::default_action);
# serves requests for web interface of the proxy
--- 34,42 ----
use vars qw(%DISPATCH);
! %DISPATCH = (list => \&HTTP::WebTest::Recorder::Actions::list_action,
! request => \&HTTP::WebTest::Recorder::Actions::request_action,
! wtscript => \&HTTP::WebTest::Recorder::Actions::wtscript_action,
! enable => \&HTTP::WebTest::Recorder::Actions::enable_action,
! default => \&HTTP::WebTest::Recorder::Actions::default_action);
# serves requests for web interface of the proxy
--- Action.pm DELETED ---
|
|
From: Ilya M. <m_...@us...> - 2003-02-01 22:25:43
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder
In directory sc8-pr-cvs1:/tmp/cvs-serv17274/lib/HTTP/WebTest/Recorder
Modified Files:
Controller.pm Action.pm
Log Message:
Simplify design of actions by merging all action classes in single
action package with procedural style subs
Index: Controller.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Controller.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Controller.pm 25 Jan 2003 14:54:52 -0000 1.1
--- Controller.pm 1 Feb 2003 22:25:33 -0000 1.2
***************
*** 12,15 ****
--- 12,16 ----
use HTTP::WebTest::Recorder::Exceptions;
+ use HTTP::WebTest::Recorder::Action;
# constructor
***************
*** 33,41 ****
use vars qw(%DISPATCH);
! %DISPATCH = (list => 'HTTP::WebTest::Recorder::Action::List',
! request => 'HTTP::WebTest::Recorder::Action::Request',
! wtscript => 'HTTP::WebTest::Recorder::Action::WTScript',
! enable => 'HTTP::WebTest::Recorder::Action::Enable',
! default => 'HTTP::WebTest::Recorder::Action');
# serves requests for web interface of the proxy
--- 34,42 ----
use vars qw(%DISPATCH);
! %DISPATCH = (list => \&HTTP::WebTest::Recorder::Action::list_action,
! request => \&HTTP::WebTest::Recorder::Action::request_action,
! wtscript => \&HTTP::WebTest::Recorder::Action::wtscript_action,
! enable => \&HTTP::WebTest::Recorder::Action::enable_action,
! default => \&HTTP::WebTest::Recorder::Action::default_action);
# serves requests for web interface of the proxy
***************
*** 50,60 ****
$self->view($param{action});
! my $action_package = $DISPATCH{$param{action}} || $DISPATCH{default};
! eval "require $action_package";
! my $action = $action_package->new;
my $response;
eval {
! $response = $self->process_template($action->execute($self));
};
if($@) {
--- 51,59 ----
$self->view($param{action});
! my $action = $DISPATCH{$param{action}} || $DISPATCH{default};
my $response;
eval {
! $response = $self->process_template($action->($self));
};
if($@) {
Index: Action.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Action.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Action.pm 25 Jan 2003 14:54:52 -0000 1.1
--- Action.pm 1 Feb 2003 22:25:33 -0000 1.2
***************
*** 1,22 ****
package HTTP::WebTest::Recorder::Action;
- # $Id$
-
use strict;
! # constructor
! sub new {
! my $class = shift;
! my $self = bless {}, $class;
! return $self;
}
! # serves requests
! sub execute {
! my $self = shift;
my $controller = shift;
! return(action => $self,
! controller => $controller);
}
--- 1,55 ----
package HTTP::WebTest::Recorder::Action;
use strict;
! use HTTP::WebTest::Parser;
!
! sub default_action {
! my $controller = shift;
!
! return(controller => $controller);
}
! sub enable_action {
my $controller = shift;
! my $enable = $controller->cgi->param('enable');
! $controller->recorder->is_recording($enable);
!
! $controller->redirect('list');
! }
!
! sub list_action {
! my $controller = shift;
!
! return(default_action($controller),
! tests => $controller->recorder->tests);
! }
!
! sub request_action {
! my $controller = shift;
!
! my $num = $controller->cgi->param('num');
! my $test = $controller->recorder->tests->[$num];
!
! return(default_action($controller),
! test => $test);
! }
! sub wtscript_action {
! my $controller = shift;
!
! my $wtscript = (join "\n", map _test2wtscript($_),
! @{$controller->recorder->tests});
!
! return(default_action($controller),
! wtscript => $wtscript);
! }
!
! sub _test2wtscript {
! my $test = shift;
!
! my @params = map +($_ => $test->params->{$_}), sort keys %{$test->params};
!
! return HTTP::WebTest::Parser->write_test(\@params);
}
|
|
From: Ilya M. <m_...@us...> - 2003-02-01 22:25:43
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Action In directory sc8-pr-cvs1:/tmp/cvs-serv17274/lib/HTTP/WebTest/Recorder/Action Removed Files: WTScript.pm Request.pm List.pm Enable.pm Log Message: Simplify design of actions by merging all action classes in single action package with procedural style subs --- WTScript.pm DELETED --- --- Request.pm DELETED --- --- List.pm DELETED --- --- Enable.pm DELETED --- |
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv17274/t
Modified Files:
03-action.t 02-controller.t
Removed Files:
07-action-enable.t 06-action-wtscript.t 05-action-request.t
04-action-list.t
Log Message:
Simplify design of actions by merging all action classes in single
action package with procedural style subs
Index: 03-action.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/03-action.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** 03-action.t 25 Jan 2003 14:54:51 -0000 1.3
--- 03-action.t 1 Feb 2003 22:25:32 -0000 1.4
***************
*** 6,10 ****
use HTTP::Status;
! use Test::More tests => 5;
# get test template files directory included in search path
--- 6,11 ----
use HTTP::Status;
! use Test::More tests => 23;
! use Test::Exception;
# get test template files directory included in search path
***************
*** 13,27 ****
require_ok('HTTP::WebTest::Recorder::Action');
require_ok('HTTP::WebTest::Recorder::Controller');
# test constructors
- my $ACTION = new HTTP::WebTest::Recorder::Action;
- isa_ok($ACTION, 'HTTP::WebTest::Recorder::Action');
my $CONTROLLER = new HTTP::WebTest::Recorder::Controller;
isa_ok($CONTROLLER, 'HTTP::WebTest::Recorder::Controller');
! # test execute()
{
! is_deeply([$ACTION->execute($CONTROLLER)],
! [action => $ACTION, controller => $CONTROLLER],
'Test template_data()');
}
--- 14,158 ----
require_ok('HTTP::WebTest::Recorder::Action');
require_ok('HTTP::WebTest::Recorder::Controller');
+ require_ok('HTTP::WebTest::Recorder');
# test constructors
my $CONTROLLER = new HTTP::WebTest::Recorder::Controller;
isa_ok($CONTROLLER, 'HTTP::WebTest::Recorder::Controller');
+ my $RECORDER = new HTTP::WebTest::Recorder;
+ isa_ok($RECORDER, 'HTTP::WebTest::Recorder');
+ $CONTROLLER->recorder($RECORDER);
! # test default_action()
{
! is_deeply([HTTP::WebTest::Recorder::Action::default_action($CONTROLLER)],
! [controller => $CONTROLLER],
'Test template_data()');
+ }
+
+ # test list_action()
+ {
+ my %data = HTTP::WebTest::Recorder::Action::list_action($CONTROLLER);
+ is($data{tests}, $RECORDER->tests,
+ 'Check if "tests" variable is defined');
+ }
+
+ # init recorder with some data
+ {
+ my $test1 = HTTP::WebTest::Test->new;
+ $test1->request(GET 'http://example.com/doc1.html');
+ $test1->response(HTTP::Response->new(RC_OK));
+ $test1->response->content('DOC #1');
+
+ my $test2 = HTTP::WebTest::Test->new;
+ $test2->request(POST 'http://example.com/doc2.html',
+ [ xx => 'yy', 1 => 2]);
+ $test2->response(HTTP::Response->new(RC_NOT_FOUND));
+ $test2->response->content('Not Found');
+
+ push @{$RECORDER->tests}, $test1, $test2;
+ }
+
+ # test request_action()
+ {
+ $CONTROLLER->cgi(CGI->new({num => 0}));
+ my %data = HTTP::WebTest::Recorder::Action::request_action($CONTROLLER);
+ is($data{test}, $RECORDER->tests->[0],
+ 'Check if "test" variable is defined');
+
+ $CONTROLLER->cgi(CGI->new({num => 1}));
+ %data = HTTP::WebTest::Recorder::Action::request_action($CONTROLLER);
+ is($data{test}, $RECORDER->tests->[1],
+ 'Check if "test" variable is defined');
+
+ $CONTROLLER->cgi(CGI->new({num => 2}));
+ %data = HTTP::WebTest::Recorder::Action::request_action($CONTROLLER);
+ is($data{test}, undef,
+ 'Check if "test" variable is not defined');
+ }
+
+ # reinit recorder with some test data
+ {
+ $RECORDER->tests([]);
+ my $request = GET 'http://example.com/doc1.html';
+ my $response = HTTP::Response->new(RC_OK);
+ $response->content('DOC #1');
+ push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
+ }
+ {
+ my $request = (POST 'http://example.com/doc2.html',
+ [ xx => 'yy', 1 => 2]);
+ my $response = HTTP::Response->new(RC_NOT_FOUND);
+ $response->content('Not Found');
+ push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
+ }
+ {
+ my $request = GET 'http://example.com/doc3.html?a=b&a=c';
+ my $response = HTTP::Response->new(RC_OK);
+ $response->content('DOC #2');
+ push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
+ }
+
+ # test wtscript_action()
+ {
+ my %data = HTTP::WebTest::Recorder::Action::wtscript_action($CONTROLLER);
+ is($data{wtscript}, <<'WTSCRIPT',
+ test_name = N/A
+ url = http://example.com/doc1.html
+ end_test
+
+ test_name = N/A
+ method = POST
+ params = (
+ xx
+ yy
+ 1
+ 2
+ )
+ url = http://example.com/doc2.html
+ end_test
+
+ test_name = N/A
+ params = (
+ a
+ b
+ a
+ c
+ )
+ url = http://example.com/doc3.html
+ end_test
+ WTSCRIPT
+ 'Check if "wtscript" variable is defined');
+ }
+
+ # test with enable_action() if we can turn on recording
+ {
+ $CONTROLLER->cgi(CGI->new({ enable => 1 }));
+ dies_ok { HTTP::WebTest::Recorder::Action::enable_action($CONTROLLER) }
+ 'Expect redirect';
+ isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
+ 'Verify exception class');
+ is($@->url, 'list', 'Test url property of exception');
+ ok($CONTROLLER->recorder->is_recording, 'Recording');
+ }
+
+ # test with enable_action() if we can turn off recording
+ {
+ $CONTROLLER->cgi(CGI->new({ enable => 0 }));
+ dies_ok { HTTP::WebTest::Recorder::Action::enable_action($CONTROLLER) }
+ 'Expect redirect';
+ isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
+ 'Verify exception class');
+ is($@->url, 'list', 'Test url property of exception');
+ ok(not($CONTROLLER->recorder->is_recording), 'Not recording');
+ }
+
+ # test with enable_action() if we can turn on recording once again
+ {
+ $CONTROLLER->cgi(CGI->new({ enable => 1 }));
+ dies_ok { HTTP::WebTest::Recorder::Action::enable_action($CONTROLLER) }
+ 'Expect redirect';
+ isa_ok($@, 'HTTP::WebTest::Recorder::Exception::Redirect',
+ 'Verify exception class');
+ is($@->url, 'list', 'Test url property of exception');
+ ok($CONTROLLER->recorder->is_recording, 'Recording');
}
Index: 02-controller.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/02-controller.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** 02-controller.t 25 Jan 2003 14:54:51 -0000 1.3
--- 02-controller.t 1 Feb 2003 22:25:32 -0000 1.4
***************
*** 112,130 ****
# try to access page that generates a redirect
{
local %HTTP::WebTest::Recorder::Controller::DISPATCH =
! ( redirect => 'TestRedirect' );
# just to disable used only once warning
() = %HTTP::WebTest::Recorder::Controller::DISPATCH;
- {
- package TestRedirect;
- use base qw(HTTP::WebTest::Recorder::Action);
-
- sub execute {
- my $self = shift;
- my $controller = shift;
- return $controller->redirect('xxx');
- }
- }
my $request = GET 'http://localhost/webtest/redirect';
my $response = $CONTROLLER->execute(action => 'redirect',
--- 112,125 ----
# try to access page that generates a redirect
{
+ my $test_redirect = sub {
+ my $controller = shift;
+
+ return $controller->redirect('xxx');
+ };
local %HTTP::WebTest::Recorder::Controller::DISPATCH =
! ( redirect => $test_redirect );
# just to disable used only once warning
() = %HTTP::WebTest::Recorder::Controller::DISPATCH;
my $request = GET 'http://localhost/webtest/redirect';
my $response = $CONTROLLER->execute(action => 'redirect',
--- 07-action-enable.t DELETED ---
--- 06-action-wtscript.t DELETED ---
--- 05-action-request.t DELETED ---
--- 04-action-list.t DELETED ---
|
|
From: Ilya M. <m_...@us...> - 2003-01-25 18:24:31
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv1047/t
Modified Files:
06-action-wtscript.t 01-recorder.t
Log Message:
Updated
Index: 06-action-wtscript.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/06-action-wtscript.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** 06-action-wtscript.t 25 Jan 2003 14:54:51 -0000 1.3
--- 06-action-wtscript.t 25 Jan 2003 18:24:27 -0000 1.4
***************
*** 5,9 ****
use HTTP::Request::Common;
use HTTP::Status;
- use HTTP::WebTest::Test;
use Test::More tests => 7;
--- 5,8 ----
***************
*** 24,44 ****
# init recorder with some data
{
! my $test1 = HTTP::WebTest::Test->new;
! $test1->request(GET 'http://example.com/doc1.html');
! $test1->response(HTTP::Response->new(RC_OK));
! $test1->response->content('DOC #1');
!
! my $test2 = HTTP::WebTest::Test->new;
! $test2->request(POST 'http://example.com/doc2.html',
! [ xx => 'yy', 1 => 2]);
! $test2->response(HTTP::Response->new(RC_NOT_FOUND));
! $test2->response->content('Not Found');
!
! my $test3 = HTTP::WebTest::Test->new;
! $test3->request(GET 'http://example.com/doc3.html?a=b&a=c');
! $test3->response(HTTP::Response->new(RC_OK));
! $test3->response->content('DOC #2');
!
! push @{$RECORDER->tests}, $test1, $test2, $test3;
}
--- 23,43 ----
# init recorder with some data
{
! my $request = GET 'http://example.com/doc1.html';
! my $response = HTTP::Response->new(RC_OK);
! $response->content('DOC #1');
! push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
! }
! {
! my $request = (POST 'http://example.com/doc2.html',
! [ xx => 'yy', 1 => 2]);
! my $response = HTTP::Response->new(RC_NOT_FOUND);
! $response->content('Not Found');
! push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
! }
! {
! my $request = GET 'http://example.com/doc3.html?a=b&a=c';
! my $response = HTTP::Response->new(RC_OK);
! $response->content('DOC #2');
! push @{$RECORDER->tests}, $RECORDER->make_test($request, $response);
}
***************
*** 52,68 ****
test_name = N/A
- url = http://example.com/doc2.html
method = POST
params = (
! xx => yy
! 1 => 2
)
end_test
test_name = N/A
- url = http://example.com/doc3.html
params = (
! a => b
)
end_test
WTSCRIPT
--- 51,72 ----
test_name = N/A
method = POST
params = (
! xx
! yy
! 1
! 2
)
+ url = http://example.com/doc2.html
end_test
test_name = N/A
params = (
! a
! b
! a
! c
)
+ url = http://example.com/doc3.html
end_test
WTSCRIPT
Index: 01-recorder.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/01-recorder.t,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** 01-recorder.t 25 Jan 2003 14:54:51 -0000 1.5
--- 01-recorder.t 25 Jan 2003 18:24:27 -0000 1.6
***************
*** 8,12 ****
use HTTP::WebTest::SelfTest;
! use Test::More tests => 40;
# get test template files directory included in search path
--- 8,12 ----
use HTTP::WebTest::SelfTest;
! use Test::More tests => 44;
# get test template files directory included in search path
***************
*** 129,132 ****
--- 129,165 ----
'Check content of response');
}
+ }
+
+ # test recorder's ability to turn request/response pair into the test
+ {
+ my $recorder = new HTTP::WebTest::Recorder;
+ $recorder->is_recording(1);
+ my $request = GET abs_url($URL, '/test-file1');
+ $recorder->handle($request);
+ is_deeply($recorder->tests->[0]->params,
+ { url => $request->uri->as_string },
+ 'Check test params for simple GET');
+
+ $request = POST abs_url($URL, '/test-file1');
+ $recorder->handle($request);
+ is_deeply($recorder->tests->[1]->params,
+ { url => $request->uri->as_string,
+ method => 'POST' },
+ 'Check test params for simple POST');
+
+ $request = GET abs_url($URL, '/test-file1?a=b&c=d');
+ $recorder->handle($request);
+ is_deeply($recorder->tests->[2]->params,
+ { url => abs_url($URL, '/test-file1')->as_string,
+ params => [ a => 'b', c => 'd' ] },
+ 'Check test params for GET with params)');
+
+ $request = POST abs_url($URL, '/test-file1'), [ xx => 'yy' ];
+ $recorder->handle($request);
+ is_deeply($recorder->tests->[3]->params,
+ { url => $request->uri->as_string,
+ params => [ xx => 'yy' ],
+ method => 'POST' },
+ 'Check test params for POST with params');
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-25 18:23:47
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Action
In directory sc8-pr-cvs1:/tmp/cvs-serv635/lib/HTTP/WebTest/Recorder/Action
Modified Files:
WTScript.pm
Log Message:
Use HTTP::WebTest::Parser to create wtscript file
Index: WTScript.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder/Action/WTScript.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** WTScript.pm 25 Jan 2003 14:54:52 -0000 1.1
--- WTScript.pm 25 Jan 2003 18:23:43 -0000 1.2
***************
*** 5,8 ****
--- 5,10 ----
use strict;
+ use HTTP::WebTest::Parser;
+
use base qw(HTTP::WebTest::Recorder::Action);
***************
*** 13,19 ****
my $controller = shift;
! my @tests = @{$controller->recorder->tests};
!
! my $wtscript = join "\n", map $self->test2wtscript($_), @tests;
return($self->SUPER::execute($controller),
--- 15,20 ----
my $controller = shift;
! my $wtscript = (join "\n", map $self->test2wtscript($_),
! @{$controller->recorder->tests});
return($self->SUPER::execute($controller),
***************
*** 25,58 ****
my $test = shift;
! my $request = $test->request;
!
! my $wtscript = '';
!
! $wtscript .= "test_name = N/A\n";
!
! my $short_uri = URI->new($request->uri);
! $short_uri->query(undef);
! $wtscript .= ' url = ' . $short_uri . "\n";
! $wtscript .= ' method = ' . $request->method . "\n"
! if $request->method ne 'GET';
!
! my $cgi;
! if($request->method eq 'POST') {
! $cgi = CGI->new($request->content);
! } else {
! $cgi = CGI->new($request->uri->query);
! }
! if($cgi->param) {
! $wtscript .= " params = (\n";
! for my $param ($cgi->param) {
! $wtscript .= ' ' .
! $param . ' => ' . $cgi->param($param) . "\n";
! }
! $wtscript .= " )\n";
! }
!
! $wtscript .= "end_test\n";
! return $wtscript;
}
--- 26,32 ----
my $test = shift;
! my @params = map +($_ => $test->params->{$_}), sort keys %{$test->params};
! return HTTP::WebTest::Parser->write_test(\@params);
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-25 18:23:00
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest
In directory sc8-pr-cvs1:/tmp/cvs-serv32469/lib/HTTP/WebTest
Modified Files:
Recorder.pm
Log Message:
Recorder autocreate a test case now
Index: Recorder.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Recorder.pm 25 Jan 2003 14:54:52 -0000 1.4
--- Recorder.pm 25 Jan 2003 18:22:55 -0000 1.5
***************
*** 70,80 ****
my $response = $self->user_agent->simple_request($request);
if($self->is_recording) {
! my $test = HTTP::WebTest::Test->new;
! $test->request($request);
! $test->response($response);
! push @{$self->tests}, $test;
}
return $response;
}
}
--- 70,114 ----
my $response = $self->user_agent->simple_request($request);
if($self->is_recording) {
! push @{$self->tests}, $self->make_test($request, $response);
}
return $response;
}
+ }
+
+ # creates a test object from request/response pair
+ sub make_test {
+ my $self = shift;
+ my($request, $response) = @_;
+
+ my $test = HTTP::WebTest::Test->new;
+ $test->request($request);
+ $test->response($response);
+
+ my %params;
+
+ {
+ my $short_uri = URI->new($request->uri);
+ $short_uri->query(undef);
+ $params{url} = $short_uri->as_string;
+ }
+
+ my $cgi;
+ if($request->method eq 'POST') {
+ $params{method} = 'POST';
+ $cgi = CGI->new($request->content);
+ } else {
+ $cgi = CGI->new($request->uri->query);
+ }
+ if($cgi->param) {
+ for my $param ($cgi->param) {
+ for my $value ($cgi->param($param)) {
+ push @{$params{params}}, $param, $value;
+ }
+ }
+ }
+
+ $test->params(\%params);
+
+ return $test;
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-25 18:02:08
|
Update of /cvsroot/http-webtest/HTTP-WebTest/t
In directory sc8-pr-cvs1:/tmp/cvs-serv15378
Modified Files:
06-parser.t
Log Message:
More tests for wtscript writting
Index: 06-parser.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/06-parser.t,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** 06-parser.t 25 Jan 2003 17:48:05 -0000 1.20
--- 06-parser.t 25 Jan 2003 18:02:05 -0000 1.21
***************
*** 122,126 ****
check_file => 't/test.out/borked8.err');
! # 69: test writing wtscript for single test
{
my @params = ( xxx => 'yyy',
--- 122,126 ----
check_file => 't/test.out/borked8.err');
! # 69-70: test writing wtscript for single test
{
my @params = ( xxx => 'yyy',
***************
*** 131,134 ****
--- 131,142 ----
compare_output(check_file => 't/test.out/write_params',
output_ref => \$output);
+
+ # crash test - parse wtscript, generate, parse wtscript and
+ # compare results
+ my ($tests1, $opts1) = HTTP::WebTest::Parser->parse($output);
+ my $output1 = HTTP::WebTest::Parser->write_test([ %{$tests1->[0]} ]);
+ my ($tests2, $opts2) = HTTP::WebTest::Parser->parse($output1);
+ is_deeply([$tests1, $opts1],
+ [$tests2, $opts2]);
}
|