[Jifty-commit] r4275 - in jifty/trunk: . t/TestApp-Plugin-OAuth/etc t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Oct 20 00:54:38 EDT 2007


Author: sartak
Date: Sat Oct 20 00:54:38 2007
New Revision: 4275

Added:
   jifty/trunk/t/TestApp-Plugin-OAuth/t/03-authorize.t
Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/META.yml
   jifty/trunk/t/TestApp-Plugin-OAuth/etc/config.yml
   jifty/trunk/t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth/Dispatcher.pm

Log:
 r43921 at onn:  sartak | 2007-10-20 00:54:31 -0400
 Dispatcher and config fixes, start adding a new test file


Modified: jifty/trunk/META.yml
==============================================================================
--- jifty/trunk/META.yml	(original)
+++ jifty/trunk/META.yml	Sat Oct 20 00:54:38 2007
@@ -2,7 +2,7 @@
 build_requires: 
   ExtUtils::MakeMaker: 6.11
 distribution_type: module
-generated_by: Module::Install version 0.670
+generated_by: Module::Install version 0.67
 license: Perl
 meta-spec: 
   url: http://module-build.sourceforge.net/META-spec-v1.3.html
@@ -24,6 +24,7 @@
   Cache::FileCache: 0
   Chart::Base: 0
   Class::Accessor::Named: 0
+  Crypt::OpenSSL::RSA: 0
   DBD::SQLite: 0
   Devel::Cover: 0
   Devel::EvalContext: 0
@@ -31,6 +32,7 @@
   Devel::Events::Generator::Objects: 0
   Devel::Events::Handler::ObjectTracker: 0
   Devel::Size: 0
+  Digest::HMAC_SHA1: 0
   GD: 0
   GD::Graph: 0
   Image::Info: 0
@@ -38,6 +40,10 @@
   Module::CoreList: 0
   Module::Install::Admin: 0.50
   Module::Refresh: 0.09
+  Net::OAuth::AccessTokenRequest: 0.04
+  Net::OAuth::ProtectedResourceRequest: 0.04
+  Net::OAuth::Request: 0.04
+  Net::OAuth::RequestTokenRequest: 0.04
   Net::OpenID::Consumer: 0
   Net::Server::Fork: 0
   Net::Server::PreFork: 0

Modified: jifty/trunk/t/TestApp-Plugin-OAuth/etc/config.yml
==============================================================================
--- jifty/trunk/t/TestApp-Plugin-OAuth/etc/config.yml	(original)
+++ jifty/trunk/t/TestApp-Plugin-OAuth/etc/config.yml	Sat Oct 20 00:54:38 2007
@@ -28,6 +28,7 @@
     - AdminUI: {}
     - OAuth: {}
     - Authentication::Password: {}
+    - SkeletonApp: {}
 
   PubSub: 
     Backend: Memcached

Modified: jifty/trunk/t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth/Dispatcher.pm
==============================================================================
--- jifty/trunk/t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth/Dispatcher.pm	(original)
+++ jifty/trunk/t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth/Dispatcher.pm	Sat Oct 20 00:54:38 2007
@@ -3,14 +3,12 @@
 use warnings;
 use Jifty::Dispatcher -base;
 
-my @always_allowed = qw{
-    login
-    signup
-    oauth/request_token
-    oauth/access_token
+my @login_required = qw{
+    oauth/authorize
 };
-my $always_allowed = join '|', map {"^$_"} @always_allowed;
-$always_allowed = qr/$always_allowed/;
+
+my $login_required = join '|', map {"^$_"} @login_required;
+$login_required = qr/$login_required/;
 
 before '*' => run {
     if (Jifty->web->current_user->id) {
@@ -18,7 +16,7 @@
         $top->child( _('Pick!')    => url => '/pick' );
         $top->child( _('Choices')  => url => '/choices' );
     }
-    elsif ($1 !~ $always_allowed) {
+    elsif ($1 =~ $login_required) {
         tangent 'login';
     }
 };

Added: jifty/trunk/t/TestApp-Plugin-OAuth/t/03-authorize.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Plugin-OAuth/t/03-authorize.t	Sat Oct 20 00:54:38 2007
@@ -0,0 +1,54 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+use lib 't/lib';
+use Jifty::SubTest;
+
+use TestApp::Plugin::OAuth::Test;
+
+if (eval { require Net::OAuth::Request; 1 }) {
+    plan tests => 7;
+}
+else {
+    plan skip_all => "Net::OAuth isn't installed";
+}
+
+use Jifty::Test::WWW::Mechanize;
+
+my $server  = Jifty::Test->make_server;
+isa_ok($server, 'Jifty::Server');
+my $URL     = $server->started_ok;
+$mech    = Jifty::Test::WWW::Mechanize->new();
+$url     = $URL . '/oauth/request_token';
+
+# create some consumers {{{
+my $consumer = Jifty::Plugin::OAuth::Model::Consumer->new(current_user => Jifty::CurrentUser->superuser);
+my ($ok, $msg) = $consumer->create(
+    consumer_key => 'foo',
+    secret       => 'bar',
+    name         => 'FooBar industries',
+    url          => 'http://foo.bar.example.com',
+    rsa_key      => $pubkey,
+);
+ok($ok, $msg);
+
+my $rsaless = Jifty::Plugin::OAuth::Model::Consumer->new(current_user => Jifty::CurrentUser->superuser);
+($ok, $msg) = $rsaless->create(
+    consumer_key => 'foo2',
+    secret       => 'bar2',
+    name         => 'Backwater.org',
+    url          => 'http://backwater.org',
+);
+ok($ok, $msg);
+# }}}
+# get a request token as a known consumer (PLAINTEXT) {{{
+response_is(
+    code                   => 200,
+    testname               => "200 - plaintext signature",
+    consumer_secret        => 'bar',
+    oauth_consumer_key     => 'foo',
+    oauth_signature_method => 'PLAINTEXT',
+);
+# }}}
+


More information about the Jifty-commit mailing list