[Jifty-commit] r4864 - in jifty/trunk: .

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Jan 15 22:56:25 EST 2008


Author: sartak
Date: Tue Jan 15 22:56:25 2008
New Revision: 4864

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/t/TestApp-Plugin-OAuth/t/05-protected-resource.t

Log:
 r50445 at onn:  sartak | 2008-01-15 22:55:42 -0500
 More tests. Looking good!


Modified: jifty/trunk/t/TestApp-Plugin-OAuth/t/05-protected-resource.t
==============================================================================
--- jifty/trunk/t/TestApp-Plugin-OAuth/t/05-protected-resource.t	(original)
+++ jifty/trunk/t/TestApp-Plugin-OAuth/t/05-protected-resource.t	Tue Jan 15 22:56:25 2008
@@ -5,7 +5,7 @@
 use Test::More;
 BEGIN {
     if (eval { require Net::OAuth::Request; require Crypt::OpenSSL::RSA; 1 }) {
-        plan tests => 19;
+        plan tests => 27;
     }
     else {
         plan skip_all => "Net::OAuth isn't installed";
@@ -59,6 +59,8 @@
     consumer_secret        => 'bar',
     oauth_consumer_key     => 'foo',
     oauth_signature_method => 'PLAINTEXT',
+    oauth_token            => 'please',
+    token_secret           => 'letmein',
 );
 $cmech->content_contains("Login with a password", "redirected to login");
 $cmech->content_lacks("Press the shiny red button", "did NOT get to a protected page");
@@ -78,4 +80,38 @@
 );
 $cmech->content_contains("Press the shiny red button", "got to a protected page");
 # }}}
+# without OAuth parameters, no access {{{
+$cmech->get_ok('/nuke/the/whales');
 
+$cmech->content_contains("Login with a password", "current_user unset");
+$cmech->content_lacks("Press the shiny red button", "did NOT get to a protected page");
+# }}}
+# access tokens last for more than one hit {{{
+response_is(
+    url                    => '/nuke/the/whales',
+    code                   => 200,
+    testname               => "200 - protected resource request",
+    consumer_secret        => 'bar',
+    oauth_consumer_key     => 'foo',
+    oauth_signature_method => 'PLAINTEXT',
+    oauth_token            => $token_obj->token,
+    token_secret           => $token_obj->secret,
+);
+$cmech->content_contains("Press the shiny red button", "got to a protected page");
+# }}}
+# expired access token {{{
+$token_obj->set_valid_until(DateTime->now->subtract(days => 1));
+
+response_is(
+    url                    => '/nuke/the/whales',
+    code                   => 200,
+    testname               => "200 - protected resource request",
+    consumer_secret        => 'bar',
+    oauth_consumer_key     => 'foo',
+    oauth_signature_method => 'PLAINTEXT',
+    oauth_token            => $token_obj->token,
+    token_secret           => $token_obj->secret,
+);
+$cmech->content_contains("Login with a password", "redirected to login");
+$cmech->content_lacks("Press the shiny red button", "did NOT get to a protected page");
+# }}}


More information about the Jifty-commit mailing list