From 8dcd511a8b912d740b901226e8ceacf4b5d6a140 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 16 Jul 2009 22:35:49 +0000 Subject: [PATCH] Update tests for modified code, and for CSRF checks. --- t/Shop/Pay.t | 8 ++++---- t/Shop/PayDriver.t | 6 +++++- t/Shop/PayDriver/Ogone.t | 8 +++++++- t/Shop/PayDriver/{PayPal/PayPalStd.t => PayPal.t} | 10 +++++----- t/Shop/ShipDriver.t | 6 +++++- t/Shop/ShipDriver/FlatRate.t | 6 +++++- t/Workflow/Activity/DeleteExpiredSessions.t | 10 +++++----- 7 files changed, 36 insertions(+), 18 deletions(-) rename t/Shop/PayDriver/{PayPal/PayPalStd.t => PayPal.t} (84%) diff --git a/t/Shop/Pay.t b/t/Shop/Pay.t index 5388f4554..e5b8220ed 100644 --- a/t/Shop/Pay.t +++ b/t/Shop/Pay.t @@ -143,10 +143,10 @@ is($newDriver->get('label'), 'Cold, stone hard cash', 'label passed correctly to my $drivers = $pay->getDrivers(); my $defaultPayDrivers = { - 'WebGUI::Shop::PayDriver::Cash' => 'Cash', - 'WebGUI::Shop::PayDriver::ITransact' => 'Credit Card (ITransact)', - 'WebGUI::Shop::PayDriver::PayPal::PayPalStd' => 'PayPal', - 'WebGUI::Shop::PayDriver::Ogone' => 'Ogone', + 'WebGUI::Shop::PayDriver::Cash' => 'Cash', + 'WebGUI::Shop::PayDriver::ITransact' => 'Credit Card (ITransact)', + 'WebGUI::Shop::PayDriver::PayPal' => 'PayPal', + 'WebGUI::Shop::PayDriver::Ogone' => 'Ogone', }; cmp_deeply( $drivers, $defaultPayDrivers, 'getDrivers returns the default PayDrivers'); diff --git a/t/Shop/PayDriver.t b/t/Shop/PayDriver.t index 9a29dbf14..81152e0f0 100644 --- a/t/Shop/PayDriver.t +++ b/t/Shop/PayDriver.t @@ -286,7 +286,7 @@ my @forms = HTML::Form->parse($html, 'http://www.webgui.org'); is (scalar @forms, 1, 'getEditForm generates just 1 form'); my @inputs = $forms[0]->inputs; -is (scalar @inputs, 13, 'getEditForm: the form has 13 controls'); +is (scalar @inputs, 14, 'getEditForm: the form has 14 controls'); my @interestingFeatures; foreach my $input (@inputs) { @@ -298,6 +298,10 @@ foreach my $input (@inputs) { cmp_deeply( \@interestingFeatures, [ + { + name => 'webguiCsrfToken', + type => 'hidden', + }, { name => undef, type => 'submit', diff --git a/t/Shop/PayDriver/Ogone.t b/t/Shop/PayDriver/Ogone.t index d4bbb584f..dc19dc328 100644 --- a/t/Shop/PayDriver/Ogone.t +++ b/t/Shop/PayDriver/Ogone.t @@ -372,7 +372,7 @@ my @forms = HTML::Form->parse($html, 'http://www.webgui.org'); is (scalar @forms, 1, 'getEditForm generates just 1 form'); my @inputs = $forms[0]->inputs; -is (scalar @inputs, 19, 'getEditForm: the form has 19 controls'); +is (scalar @inputs, 20, 'getEditForm: the form has 20 controls'); my @interestingFeatures; foreach my $input (@inputs) { @@ -381,9 +381,15 @@ foreach my $input (@inputs) { push @interestingFeatures, { name => $name, type => $type }; } +diag Dumper \@interestingFeatures; + cmp_deeply( \@interestingFeatures, [ + { + name => 'webguiCsrfToken', + type => 'hidden', + }, { name => undef, type => 'submit', diff --git a/t/Shop/PayDriver/PayPal/PayPalStd.t b/t/Shop/PayDriver/PayPal.t similarity index 84% rename from t/Shop/PayDriver/PayPal/PayPalStd.t rename to t/Shop/PayDriver/PayPal.t index b3d9acb5f..3123c78d4 100644 --- a/t/Shop/PayDriver/PayPal/PayPalStd.t +++ b/t/Shop/PayDriver/PayPal.t @@ -15,7 +15,7 @@ use FindBin; use strict; -use lib "$FindBin::Bin/../../../lib"; +use lib "$FindBin::Bin/../../lib"; use Test::More; use Test::Deep; use JSON; @@ -39,13 +39,13 @@ plan tests => 1 + $tests; my $e; -my $loaded = use_ok('WebGUI::Shop::PayDriver::PayPal::PayPalStd'); +my $loaded = use_ok('WebGUI::Shop::PayDriver::PayPal'); my $storage; SKIP: { -skip 'Unable to load module WebGUI::Shop::PayDriver::PayPal::PayPalStd', $tests unless $loaded; +skip 'Unable to load module WebGUI::Shop::PayDriver::PayPal', $tests unless $loaded; ####################################################################### # @@ -60,10 +60,10 @@ my $options = { receiptMessage => 'Pannenkoeken zijn nog lekkerder met spek', }; -$driver = WebGUI::Shop::PayDriver::PayPal::PayPalStd->create( $session, $options ); +$driver = WebGUI::Shop::PayDriver::PayPal->create( $session, $options ); isa_ok ($driver, 'WebGUI::Shop::PayDriver'); -isa_ok ($driver, 'WebGUI::Shop::PayDriver::PayPal::PayPalStd'); +isa_ok ($driver, 'WebGUI::Shop::PayDriver::PayPal'); is($driver->getName($session), 'PayPal', 'getName returns the human readable name of this driver'); diff --git a/t/Shop/ShipDriver.t b/t/Shop/ShipDriver.t index 75fd33e29..8b0455aa1 100644 --- a/t/Shop/ShipDriver.t +++ b/t/Shop/ShipDriver.t @@ -223,7 +223,7 @@ my @forms = HTML::Form->parse($html, 'http://www.webgui.org'); is (scalar @forms, 1, 'getEditForm generates just 1 form'); my @inputs = $forms[0]->inputs; -is (scalar @inputs, 9, 'getEditForm: the form has 9 controls'); +is (scalar @inputs, 10, 'getEditForm: the form has 10 controls'); my @interestingFeatures; foreach my $input (@inputs) { @@ -235,6 +235,10 @@ foreach my $input (@inputs) { cmp_deeply( \@interestingFeatures, [ + { + name => 'webguiCsrfToken', + type => 'hidden', + }, { name => undef, type => 'submit', diff --git a/t/Shop/ShipDriver/FlatRate.t b/t/Shop/ShipDriver/FlatRate.t index a8322403e..082a7eaef 100644 --- a/t/Shop/ShipDriver/FlatRate.t +++ b/t/Shop/ShipDriver/FlatRate.t @@ -173,7 +173,7 @@ my @forms = HTML::Form->parse($html, 'http://www.webgui.org'); is (scalar @forms, 1, 'getEditForm generates just 1 form'); my @inputs = $forms[0]->inputs; -is (scalar @inputs, 13, 'getEditForm: the form has 13 controls'); +is (scalar @inputs, 14, 'getEditForm: the form has 14 controls'); my @interestingFeatures; foreach my $input (@inputs) { @@ -185,6 +185,10 @@ foreach my $input (@inputs) { cmp_deeply( \@interestingFeatures, [ + { + name => 'webguiCsrfToken', + type => 'hidden', + }, { name => undef, type => 'submit', diff --git a/t/Workflow/Activity/DeleteExpiredSessions.t b/t/Workflow/Activity/DeleteExpiredSessions.t index 1ebd0a98f..8116e3280 100644 --- a/t/Workflow/Activity/DeleteExpiredSessions.t +++ b/t/Workflow/Activity/DeleteExpiredSessions.t @@ -52,6 +52,9 @@ my $origSessionTimeout = $session->setting->get('sessionTimeout'); my $sessionCount = $session->db->quickScalar('select count(*) from userSession'); my $scratchCount = $session->db->quickScalar('select count(*) from userSessionScratch'); +diag $sessionCount; +diag $scratchCount; + my @sessions; foreach (1..2) { @@ -67,14 +70,11 @@ foreach (1..2) { $session->setting->set('sessionTimeout', $origSessionTimeout ); -$sessions[1]->scratch->set('scratch1', 1); -$sessions[3]->scratch->set('scratch3', 3); - my $newSessionCount = $session->db->quickScalar('select count(*) from userSession'); my $newScratchCount = $session->db->quickScalar('select count(*) from userSessionScratch'); is ($newSessionCount, $sessionCount+4, 'all new sessions created correctly'); -is ($newScratchCount, $scratchCount+2, 'two of the new sessions have scratch entries'); +is ($newScratchCount, $scratchCount+4, 'all new user sessions created correctly'); my $instance2 = WebGUI::Workflow::Instance->create($session, { @@ -95,7 +95,7 @@ $newSessionCount = $session->db->quickScalar('select count(*) from userSession') $newScratchCount = $session->db->quickScalar('select count(*) from userSessionScratch'); is ($newSessionCount, $sessionCount+2, 'two of the sessions were deleted'); -is ($newScratchCount, $scratchCount+1, 'one of the new sessions have scratch entries were deleted'); +is ($newScratchCount, $scratchCount+2, 'scratch from both sessions cleaned up'); foreach my $testSession (@sessions) { $testSession->var->end;