From 9395985570811ebc864915c4378fe749a429cd93 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Tue, 22 Jun 2010 15:34:17 -0400 Subject: [PATCH] add test for Operation::Auth dispatch --- t/Operation/Auth.t | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/t/Operation/Auth.t b/t/Operation/Auth.t index 2c31eded2..335292535 100644 --- a/t/Operation/Auth.t +++ b/t/Operation/Auth.t @@ -43,6 +43,10 @@ sub callable { return "callable"; } +sub not_callable { + return "not callable"; +} + sub www_verify { return "verify"; } @@ -52,7 +56,7 @@ package main; #---------------------------------------------------------------------------- # Tests -plan tests => 7; # Increment this number for each test you create +plan tests => 10; # Increment this number for each test you create #---------------------------------------------------------------------------- # Test the getInstance method @@ -105,4 +109,32 @@ unlike( "Hidden form elements for login NOT displayed to valid user", ); +# Go back to visitor and test callable dispatch +$session->user({ userId => 1 }); +$session->request->setup_body({ + authType => 'TestAuth', + method => 'callable', +}); +eval { $output = WebGUI::Operation::Auth::www_auth( $session ); }; +like( $output, qr{\bcallable\b}, 'Callable method is callable' ); + +# Test a method not in callable +$session->user({ userId => 1 }); +$session->request->setup_body({ + authType => 'TestAuth', + method => 'not_callable', +}); +my $i18n = WebGUI::International->new($session); +my $error = $i18n->get(1077); +eval { $output = WebGUI::Operation::Auth::www_auth( $session ); }; +like( $output, qr{$error}, 'not_callable method gives error message' ); + +# Test www_ dispatch +$session->user({ userId => 1 }); +$session->request->setup_body({ + authType => 'TestAuth', + method => 'verify', +}); +eval { $output = WebGUI::Operation::Auth::www_auth( $session ); }; +like( $output, qr{verify}, 'www_ callable without being setCallable' );