[Jifty-commit] r4399 - in jifty/trunk: . lib/Jifty/Plugin/OAuth
lib/Jifty/Plugin/OAuth/Model
t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Nov 9 13:32:09 EST 2007
Author: sartak
Date: Fri Nov 9 13:32:06 2007
New Revision: 4399
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm
jifty/trunk/lib/Jifty/Plugin/OAuth/Model/AccessToken.pm
jifty/trunk/t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth/Test.pm
jifty/trunk/t/TestApp-Plugin-OAuth/t/05-protected-resource.t
Log:
r44787 at onn: sartak | 2007-11-07 15:49:58 -0500
More fixes to get protected resource requests going
We might need a WWW::Mechanize::OAuth subclass, so that each get/post will be properly wrapped as an OAuth request
Modified: jifty/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm Fri Nov 9 13:32:06 2007
@@ -250,7 +250,7 @@
abortmsg(undef, "Invalid signature (type: $oauth_params{signature_method})."), return unless $request->verify;
$consumer->made_request(@oauth_params{qw/timestamp nonce/});
- Jifty->web->current_user(BTDT::CurrentUser->new(id => $access_token->auth_as));
+ Jifty->web->current_user(Jifty->app_class('CurrentUser')->new(id => $access_token->auth_as));
}
=head2 get_consumer CONSUMER KEY
Modified: jifty/trunk/lib/Jifty/Plugin/OAuth/Model/AccessToken.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OAuth/Model/AccessToken.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/OAuth/Model/AccessToken.pm Fri Nov 9 13:32:06 2007
@@ -59,9 +59,6 @@
return (0, "Access token has no authorizing user")
if !$self->auth_as;
- return (0, "Request token does not have an authorizing user")
- if !$self->authorized_by;
-
return (0, "Access token expired")
if $self->valid_until < DateTime->now;
Modified: jifty/trunk/t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth/Test.pm
==============================================================================
--- jifty/trunk/t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth/Test.pm (original)
+++ jifty/trunk/t/TestApp-Plugin-OAuth/lib/TestApp/Plugin/OAuth/Test.pm Fri Nov 9 13:32:06 2007
@@ -88,13 +88,15 @@
local $Test::Builder::Level = $Test::Builder::Level + 1;
main::is($r->code, $code, $testname);
- undef $token_obj;
- get_latest_token();
- if ($code == 200 && $url =~ /oauth/) {
- main::ok($token_obj, "Successfully loaded a token object with token ".$token_obj->token.".");
- }
- else {
- main::ok(!$token_obj, "Did not get a token");
+ if ($url =~ /oauth/) {
+ undef $token_obj;
+ get_latest_token();
+ if ($code == 200) {
+ main::ok($token_obj, "Successfully loaded a token object with token ".$token_obj->token.".");
+ }
+ else {
+ main::ok(!$token_obj, "Did not get a token");
+ }
}
return $cmech->content;
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 Fri Nov 9 13:32:06 2007
@@ -5,7 +5,7 @@
use Test::More;
BEGIN {
if (eval { require Net::OAuth::Request; require Crypt::OpenSSL::RSA; 1 }) {
- plan tests => 15;
+ plan tests => 16;
}
else {
plan skip_all => "Net::OAuth isn't installed";
@@ -51,17 +51,8 @@
$umech->content_contains('Logout');
# }}}
# }}}
-# basic working access token {{{
-get_authorized_token();
-response_is(
- code => 200,
- testname => "200 - plaintext signature",
- consumer_secret => 'bar',
- oauth_consumer_key => 'foo',
- oauth_signature_method => 'PLAINTEXT',
-);
-# }}}
# basic protected request {{{
+get_access_token();
response_is(
url => '/nuke/the/whales',
code => 200,
More information about the Jifty-commit
mailing list