[prev] [thread] [next] [lurker] [Date index for 2003/11/25]
Author: gabor
Date: 2003-11-25 01:54:16 +0200 (Tue, 25 Nov 2003)
New Revision: 36
Modified:
README
lib/YAPC/Organizer.pm
t/03-web-adduser.t
t/05-web-proposals.t
t/09-web-change-password.t
t/10-use-html-template.t
t/11-web-admin.t
t/lib/YAPC/Test/Data.pm
templates/change_password.tmpl
templates/login.tmpl
templates/lost_password.tmpl
templates/lost_validation.tmpl
templates/personal_info.tmpl
templates/proposal.tmpl
templates/registration.tmpl
templates/validation.tmpl
Log:
eliminate the run run mode, dispatch according to the name of the file
Modified: README
===================================================================
--- README 2003-11-24 23:02:18 UTC (rev 35)
+++ README 2003-11-24 23:54:16 UTC (rev 36)
@@ -42,8 +42,8 @@
0.07_03 2003.11.
- refactoring: using Class::DBI more in the way it should be used
- refactoring: moving run_mode dispatching, cleaning up the run_modes and authentication
+ - eliminate the 'run' field and base all the actions (run_mode) on the name of the file.
-
0.07_02 2003.11.24
- further refactoring the tests
- add pages to get back lost password and get validation code again
Modified: lib/YAPC/Organizer.pm
===================================================================
--- lib/YAPC/Organizer.pm 2003-11-24 23:02:18 UTC (rev 35)
+++ lib/YAPC/Organizer.pm 2003-11-24 23:54:16 UTC (rev 36)
@@ -20,7 +20,7 @@
my @user_pages = qw(proposal personal_info change_password user_account logout); # list pages that require valid login to access
my @admin_pages = qw(admin admin_list_people admin_list_proposals); # list of pages accessible to administrators only
-my @other_pages = qw(list_people login);
+my @other_pages = qw(list_people login registration validation lost_validation lost_password);
my @run_modes = map {$_, $_} @user_pages, @admin_pages, @other_pages;
@@ -31,10 +31,6 @@
$self->run_modes(
@run_modes,
'default' => 'default',
- 'registration' => 'registration',
- 'validation' => 'validation',
- 'get_validation_code' => 'get_validation_code',
- 'get_lost_password' => 'get_lost_password',
'no_such_page' => 'no_such_page',
'show_message' => 'show_message',
);
@@ -73,6 +69,7 @@
#warn "YAPC script called for not existing file. Original: '$ENV{REQUEST_URI}' cut down: '$filename'\n";
$self->prerun_mode('no_such_page');
}
+ $self->prerun_mode('default');
}
sub default {
@@ -170,7 +167,7 @@
}
}
-sub get_validation_code {
+sub lost_validation {
my $self = shift;
my $q = $self->query;
@@ -191,7 +188,7 @@
return $t->output;
}
-sub get_lost_password {
+sub lost_password {
my $self = shift;
my $q = $self->query;
Modified: t/03-web-adduser.t
===================================================================
--- t/03-web-adduser.t 2003-11-24 23:02:18 UTC (rev 35)
+++ t/03-web-adduser.t 2003-11-24 23:54:16 UTC (rev 36)
@@ -48,9 +48,9 @@
# that won't change with time and we might need to have a set of tests that are installation
# specific.
{
- #$ENV{REQUEST_URI} = '/list_people.html';
+ local $ENV{REQUEST_URI} = '/list_people.html';
my $webapp = YAPC::Organizer->new;
- $webapp->query(CGI->new({'run' => 'list_people'}));
+ $webapp->query(CGI->new());
my $result = $webapp->run();
like($result, qr/List Registered People/, 'empty ? list page is OK');
}
@@ -62,9 +62,8 @@
{
- #$ENV{REQUEST_URI} = '/registration.html';
+ local $ENV{REQUEST_URI} = '/registration.html';
my %user = %user1;
- $user{run} = 'registration';
$user{pauseid} = 'MYPAUSEID';
my $q = CGI->new(\%user);
my $webapp = YAPC::Organizer->new;
@@ -85,9 +84,8 @@
################ try to register with some data missing
# supply not-existing field
{
- #$ENV{REQUEST_URI} = '/registration.html';
+ local $ENV{REQUEST_URI} = '/registration.html';
my %user = %user1;
- $user{run} = 'registration';
$user{email} = 'dudu@tomtom';
$user{notexisting_field} = 'bad value';
@@ -102,9 +100,8 @@
# try to supply value to fields we do not want to be overwrittent
# id, acked, authcode
{
- #$ENV{REQUEST_URI} = '/registration.html';
+ local $ENV{REQUEST_URI} = '/registration.html';
my %user = %user1;
- $user{run} = 'registration';
$user{email} = 'dudu@bad-id';
$user{id} = 100;
@@ -115,9 +112,8 @@
like($result, qr/There was an error in the provided data/, 'User registered');
}
{
- #$ENV{REQUEST_URI} = '/registration.html';
+ local $ENV{REQUEST_URI} = '/registration.html';
my %user = %user1;
- $user{run} = 'registration';
$user{email} = 'dudu@bad-acked';
$user{acked} = 100;
@@ -128,9 +124,8 @@
like($result, qr/There was an error in the provided data/, 'User registered');
}
{
- #$ENV{REQUEST_URI} = '/registration.html';
+ local $ENV{REQUEST_URI} = '/registration.html';
my %user = %user1;
- $user{run} = 'registration';
$user{email} = 'dudu@bad-authcode';
$user{authcode} = 100;
@@ -147,7 +142,6 @@
{
local $ENV{REQUEST_URI} = '/login.html';
my %user = %user1;
- #$user{run} = 'registration';
my $q = CGI->new(\%user);
my $webapp = YAPC::Organizer->new;
@@ -159,9 +153,8 @@
###### validation
{
- local $ENV{REQUEST_URI} = '/registration.html';
+ local $ENV{REQUEST_URI} = '/validation.html';
my %user;
- $user{run} = 'validation';
$user{email} = $user1{email};
$user{authcode} = $authcode1;
@@ -199,7 +192,7 @@
my $path = '/';
local $ENV{REQUEST_URI} = '/login.html';
my %user;
- $user{run} = 'login';
+ #$user{run} = 'login';
$user{email} = $user1{email};
$user{password} = $user1{password};
$user{submit} = 1;
@@ -230,7 +223,7 @@
my $path = '/';
local $ENV{REQUEST_URI} = '/login.html';
my %user;
- $user{run} = 'login';
+ #$user{run} = 'login';
$user{email} = $user1{email};
$user{password} = $user1{password};
$user{submit} = 1;
@@ -259,7 +252,7 @@
{
local $ENV{REQUEST_URI} = '/login.html';
my %user;
- $user{run} = 'login';
+ #$user{run} = 'login';
$user{email} = $user1{email};
$user{password} = "$user1{password}xxx";
$user{submit} = 1;
@@ -381,7 +374,8 @@
####### get validation code if not validated yet
{
- my $q = CGI->new({email => 'bad-email', run => 'get_validation_code'});
+ local $ENV{REQUEST_URI} = '/lost_validation.html';
+ my $q = CGI->new({email => 'bad-email'});
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
my $result = $webapp->run();
@@ -390,7 +384,8 @@
## already validated
{
- my $q = CGI->new({email => $people[0]{email}, run => 'get_validation_code'});
+ local $ENV{REQUEST_URI} = '/lost_validation.html';
+ my $q = CGI->new({email => $people[0]{email}});
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
my $result = $webapp->run();
@@ -401,6 +396,7 @@
###### registeriong wihtout validation
{
+ local $ENV{REQUEST_URI} = '/registration.html';
my %user = %{$people[1]};
$user{run} = 'registration';
$user{pauseid} = 'MYPAUSEID';
@@ -414,7 +410,8 @@
## validation sent (we should check the real e-mail somehow)
{
- my $q = CGI->new({email => $people[1]{email}, run => 'get_validation_code'});
+ local $ENV{REQUEST_URI} = '/lost_validation.html';
+ my $q = CGI->new({email => $people[1]{email}});
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
my $result = $webapp->run();
@@ -424,7 +421,8 @@
####### get lost password
{
- my $q = CGI->new({email => 'bad-email', run => 'get_lost_password'});
+ local $ENV{REQUEST_URI} = '/lost_password.html';
+ my $q = CGI->new({email => 'bad-email'});
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
my $result = $webapp->run();
@@ -434,7 +432,8 @@
## password sent (we should check the real e-mail somehow)
{
- my $q = CGI->new({email => $people[0]{email}, run => 'get_lost_password'});
+ local $ENV{REQUEST_URI} = '/lost_password.html';
+ my $q = CGI->new({email => $people[0]{email}});
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
my $result = $webapp->run();
Modified: t/05-web-proposals.t
===================================================================
--- t/05-web-proposals.t 2003-11-24 23:02:18 UTC (rev 35)
+++ t/05-web-proposals.t 2003-11-24 23:54:16 UTC (rev 36)
@@ -61,7 +61,7 @@
local $ENV{REQUEST_URI} = '/proposal.html';
local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
my %prop = %proposal;
- $prop{run} = 'send_proposal';
+ #$prop{run} = 'send_proposal';
my $q = CGI->new(\%prop);
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
@@ -77,7 +77,7 @@
{
local $ENV{REQUEST_URI} = '/proposal.html';
my %prop = %proposal;
- $prop{run} = 'send_proposal';
+ #$prop{run} = 'send_proposal';
my $q = CGI->new(\%prop);
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
@@ -92,7 +92,7 @@
local $ENV{REQUEST_URI} = '/proposal.html';
local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
my %prop = %proposal;
- $prop{run} = 'send_proposal';
+ #$prop{run} = 'send_proposal';
$prop{subject} = '';
my $q = CGI->new(\%prop);
my $webapp = YAPC::Organizer->new;
@@ -103,11 +103,12 @@
is(@talks, 1, 'There is one talk in the database');
}
+
{
local $ENV{REQUEST_URI} = '/proposal.html';
local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
my %prop = %proposal;
- $prop{run} = 'send_proposal';
+ #$prop{run} = 'send_proposal';
$prop{abstract} = '';
my $q = CGI->new(\%prop);
my $webapp = YAPC::Organizer->new;
Modified: t/09-web-change-password.t
===================================================================
--- t/09-web-change-password.t 2003-11-24 23:02:18 UTC (rev 35)
+++ t/09-web-change-password.t 2003-11-24 23:54:16 UTC (rev 36)
@@ -52,12 +52,12 @@
# update password failes if not authenticated
# redirect to login page and do not touch database
{
+ local $ENV{REQUEST_URI} = '/change_password.html';
#local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
my $q = CGI->new(
{
password => 'somenewpw',
password2 => 'somenewpw',
- run => 'change_password'
});
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
@@ -88,12 +88,12 @@
# submit form with bad passwords should yield an error message
# and database should not change
{
+ local $ENV{REQUEST_URI} = '/change_password.html';
local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
my $q = CGI->new(
{
password => 'somenewpw',
password2 => 'somenewpwx',
- run => 'change_password'
});
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
@@ -112,12 +112,12 @@
# submit form with good password should yield a success message
# database should be updated.
{
+ local $ENV{REQUEST_URI} = '/change_password.html';
local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
my $q = CGI->new(
{
password => 'somenewpw',
password2 => 'somenewpw',
- run => 'change_password'
});
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
Modified: t/10-use-html-template.t
===================================================================
--- t/10-use-html-template.t 2003-11-24 23:02:18 UTC (rev 35)
+++ t/10-use-html-template.t 2003-11-24 23:54:16 UTC (rev 36)
@@ -32,9 +32,8 @@
=cut
{
- #$ENV{REQUEST_URI} = '/registration.html';
+ $ENV{REQUEST_URI} = '/registration.html';
my %user = %user1;
- $user{run} = 'registration';
$user{pauseid} = 'MYPAUSEID';
my $q = CGI->new(\%user);
my $webapp = YAPC::Organizer->new;
Modified: t/11-web-admin.t
===================================================================
--- t/11-web-admin.t 2003-11-24 23:02:18 UTC (rev 35)
+++ t/11-web-admin.t 2003-11-24 23:54:16 UTC (rev 36)
@@ -97,4 +97,16 @@
}
+### access admin page(s) by unauthenticated user using run=admin on the URL
+foreach my $page (qw(admin admin_list_people admin_list_proposals)) {
+ local $TODO = 'break-in using run mode';
+ local $ENV{REQUEST_URI} = '/index.html';
+ my $q = CGI->new({run => $page});
+ my $webapp = YAPC::Organizer->new;
+ $webapp->query($q);
+ my $result = $webapp->run();
+ like($result, qr/<h2>Login/, 'Could not fetch admin page(s)');
+}
+
+
Modified: t/lib/YAPC/Test/Data.pm
===================================================================
--- t/lib/YAPC/Test/Data.pm 2003-11-24 23:02:18 UTC (rev 35)
+++ t/lib/YAPC/Test/Data.pm 2003-11-24 23:54:16 UTC (rev 36)
@@ -71,8 +71,8 @@
# register user
{
+ local $ENV{REQUEST_URI} = '/registration.html';
my %user = %{$people[$i]};
- $user{run} = 'registration';
my $q = CGI->new(\%user);
my $webapp = YAPC::Organizer->new;
$webapp->query($q);
@@ -85,9 +85,8 @@
###### validate e-mail
{
- local $ENV{REQUEST_URI} = '/registration.html';
+ local $ENV{REQUEST_URI} = '/validation.html';
my %user;
- $user{run} = 'validation';
$user{email} = $people[$i]{email};
$user{authcode} = $authcode;
@@ -111,7 +110,6 @@
my $path = '/';
local $ENV{REQUEST_URI} = '/login.html';
my %user;
- $user{run} = 'login';
$user{email} = $people[$i]{email};
$user{password} = $people[$i]{password};
$user{submit} = 1;
@@ -133,7 +131,6 @@
local $ENV{REQUEST_URI} = '/proposal.html';
local $ENV{HTTP_COOKIE} = "Yapcom=$cookie";
my %prop = %{$talks[$t]};
- $prop{run} = 'send_proposal';
$prop{submit} = 1;
my $q = CGI->new(\%prop);
my $webapp = YAPC::Organizer->new;
Modified: templates/change_password.tmpl
===================================================================
--- templates/change_password.tmpl 2003-11-24 23:02:18 UTC (rev 35)
+++ templates/change_password.tmpl 2003-11-24 23:54:16 UTC (rev 36)
@@ -6,7 +6,6 @@
<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
<p>
<form method="post">
-<input type="hidden" name="run" value="change_password" />
<table>
<tr><td>New Password:</td><td><input size=40 name="password" type="password" /></td></tr>
<tr><td>Retype new Password:</td><td><input size=40 name="password2" type="password" /></td></tr>
Modified: templates/login.tmpl
===================================================================
--- templates/login.tmpl 2003-11-24 23:02:18 UTC (rev 35)
+++ templates/login.tmpl 2003-11-24 23:54:16 UTC (rev 36)
@@ -5,7 +5,6 @@
<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
<p>
<form method="post">
-<input type="hidden" name="run" value="<TMPL_VAR NAME=run>" />
<input type="hidden" name="next" value="<TMPL_VAR NAME=next>" />
<table>
<tr><td>Email:</td><td><input size=40 name="email" value="<TMPL_VAR NAME=email>" /></td></tr>
Modified: templates/lost_password.tmpl
===================================================================
--- templates/lost_password.tmpl 2003-11-24 23:02:18 UTC (rev 35)
+++ templates/lost_password.tmpl 2003-11-24 23:54:16 UTC (rev 36)
@@ -5,7 +5,6 @@
<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
<p>
<form method="post">
-<input type="hidden" name="run" value="get_lost_password" />
<input type="hidden" name="next" value="<TMPL_VAR NAME=next>" />
<table>
<tr><td>Email:</td><td><input size=40 name="email" value="<TMPL_VAR NAME=email>" /></td></tr>
Modified: templates/lost_validation.tmpl
===================================================================
--- templates/lost_validation.tmpl 2003-11-24 23:02:18 UTC (rev 35)
+++ templates/lost_validation.tmpl 2003-11-24 23:54:16 UTC (rev 36)
@@ -8,7 +8,6 @@
e-mail address yet, here you can ask the validation code to be sent to you again.
This will only work if you have not validated yet.
<form method="post">
-<input type="hidden" name="run" value="get_validation_code" />
<table>
<tr><td>Email:</td><td><input size=40 name="email" value="<TMPL_VAR NAME=email>" /></td></tr>
<tr><td></td><td><input type="submit" value="Get Validation code"></td></tr>
Modified: templates/personal_info.tmpl
===================================================================
--- templates/personal_info.tmpl 2003-11-24 23:02:18 UTC (rev 35)
+++ templates/personal_info.tmpl 2003-11-24 23:54:16 UTC (rev 36)
@@ -9,7 +9,6 @@
<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
<p>
<form method="post">
-<input type="hidden" name="run" value="<TMPL_VAR NAME=run>" />
<table>
<tr><td>First Name:</td><td><input size=40 name="fname" value="<TMPL_VAR NAME=fname>" /> *</td></tr>
<tr><td>Last Name:</td><td><input size=40 name="lname" value="<TMPL_VAR NAME=lname>" /> *</td></tr>
Modified: templates/proposal.tmpl
===================================================================
--- templates/proposal.tmpl 2003-11-24 23:02:18 UTC (rev 35)
+++ templates/proposal.tmpl 2003-11-24 23:54:16 UTC (rev 36)
@@ -8,7 +8,6 @@
<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
<p>
<form method="post">
-<input type="hidden" name="run" value="<TMPL_VAR NAME=run>" />
<table>
<tr><td>Title:</td><td><input size=40 name="subject" value="<TMPL_VAR NAME=subject>" /></td></tr>
<tr><td>Language:</td><td><select name="language">
Modified: templates/registration.tmpl
===================================================================
--- templates/registration.tmpl 2003-11-24 23:02:18 UTC (rev 35)
+++ templates/registration.tmpl 2003-11-24 23:54:16 UTC (rev 36)
@@ -9,7 +9,6 @@
<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
<p>
<form method="post">
-<input type="hidden" name="run" value="<TMPL_VAR NAME=run>" />
<table>
<tr><td>First Name:</td><td><input size=40 name="fname" value="<TMPL_VAR NAME=fname>" /> *</td></tr>
<tr><td>Last Name:</td><td><input size=40 name="lname" value="<TMPL_VAR NAME=lname>" /> *</td></tr>
Modified: templates/validation.tmpl
===================================================================
--- templates/validation.tmpl 2003-11-24 23:02:18 UTC (rev 35)
+++ templates/validation.tmpl 2003-11-24 23:54:16 UTC (rev 36)
@@ -10,7 +10,6 @@
<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
<p>
<form method="post">
-<input type="hidden" name="run" value="<TMPL_VAR NAME=run>" />
<table>
<tr><td>Email:</td><td><input name="email" value="<TMPL_VAR NAME=email>" /></td></tr>
<tr><td>Validation code:</td><td><input name="authcode" /></td></tr>
Generated at 07:06 on 25 Nov 2003 by mariachi 0.51