Additional documentation and tests for various small features
Tomas Doran [Wed, 10 Sep 2008 22:11:23 +0000 (22:11 +0000)]
.shipit
Changes
Todo
lib/Catalyst/Authentication/Credential/HTTP.pm
t/basic.t

diff --git a/.shipit b/.shipit
index b6ab285..391d493 100644 (file)
--- a/.shipit
+++ b/.shipit
@@ -1,6 +1,5 @@
 # auto-generated shipit config file.
-steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest
-#, Commit, Tag, MakeDist
+steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist
 
 svk.tagpattern =  //mirror/Catalyst-Authentication-Credential-HTTP/1.000/tags/%v
 
diff --git a/Changes b/Changes
index 7f9af0e..65893f0 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,10 +1,13 @@
 1.003  2008-09-??
    - Add ability to override the realm name presented for authentication
-     when calling $c->authenticate. Docs and tests for this.
+     when calling $c->authenticate. Documentation and tests for this.
    - Clean up documentation of options inherited from 
-     Catalyst::Authentication::Credential::Password
+     Catalyst::Authentication::Credential::Password.
    - Added an example of calling methods in the credential module from a 
      controller to the POD.
+   - Tests for the authorization_required_message configuration parameter. 
+   - Document use_uri_for configuration option
+   - Document domain option (passed through from $c->authenticate)
 
 1.002  2008-09-03
    - Fix the assumptions that the password field is named password when doing 
diff --git a/Todo b/Todo
index fe959cf..97f4b41 100644 (file)
--- a/Todo
+++ b/Todo
@@ -1,9 +1,5 @@
 . Document md5'd passwords for digest stuff
 . Add deprecation notice to old module.
-. document & test authorization_required_message
-. Test $self->_config->{authorization_required_message} + authorization_required_message = undef does not stamp on body.
 . Split auth headers / do auth methods again, and make authenticate call each in turn.
 . Document / test 'algorithm' config.
-. Test and document use_uri_for config
-
-
+. Test and document use_uri_for config & domain
index 806f355..49e2a23 100644 (file)
@@ -477,15 +477,9 @@ The %auth_info hash can contain a number of keys which control the authenticatio
 Sets the HTTP authentication realm presented to the client. Note this does not alter the
 Catalyst::Authentication::Realm object used for the authentication.
 
-=item password_type
-
-The type of password returned by the user object. Same useage as in 
-L<Catalyst::Authentication::Credential::Password|Catalyst::Authentication::Credential::Password/passwprd_type>
+=item domain
 
-=item password_field
-
-The name of accessor used to retrieve the value of the password field from the user object. Same useage as in 
-L<Catalyst::Authentication::Credential::Password|Catalyst::Authentication::Credential::Password/password_field>
+Array reference to domains used to build the authorization headers.
 
 =back
 
@@ -525,7 +519,7 @@ All configuration is stored in C<< YourApp->config(authentication => { yourrealm
 
 This should be a hash, and it can contain the following entries:
 
-=over 4
+=over
 
 =item type
 
@@ -538,6 +532,21 @@ not the "manual" methods.
 
 Set this to a string to override the default body content "Authorization required.", or set to undef to suppress body content being generated.
 
+=item password_type
+
+The type of password returned by the user object. Same useage as in 
+L<Catalyst::Authentication::Credential::Password|Catalyst::Authentication::Credential::Password/passwprd_type>
+
+=item password_field
+
+The name of accessor used to retrieve the value of the password field from the user object. Same useage as in 
+L<Catalyst::Authentication::Credential::Password|Catalyst::Authentication::Credential::Password/password_field>
+
+=item use_uri_for
+
+If this configuration key has a true value, then the domain(s) for the authorization header will be
+run through $c->uri_for()
+
 =back
 
 =head1 RESTRICTIONS
index a819115..91f2dc9 100644 (file)
--- a/t/basic.t
+++ b/t/basic.t
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use strict;
 use warnings;
-use Test::More tests => 24;
+use Test::More tests => 28;
 use Test::MockObject::Extends;
 use Test::MockObject;
 use Test::Exception;
@@ -113,3 +113,29 @@ is( $body, 'Authorization required.' );
 like( ($res_headers->header('WWW-Authenticate'))[0], qr/realm="myrealm"/, "WWW-Authenticate header set: digest realm overridden");
 like( ($res_headers->header('WWW-Authenticate'))[1], qr/realm="myrealm"/, "WWW-Authenticate header set: basic realm overridden");
 
+# Check authorization_required_message works
+$req_headers->clear;
+$res_headers->clear;
+$c->clear;
+{
+    my $self = new_self( type => 'any', password_type => 'clear',
+        authorization_required_message => 'foobar'
+    );
+    throws_ok {
+        $self->authenticate( $c, $realm );
+    } qr/^ $Catalyst::DETACH $/x, "detached";
+    is( $body, 'foobar', 'Body is supplied auth message');
+}
+
+$req_headers->clear;
+$res_headers->clear;
+$c->clear;
+{
+    my $self = new_self( type => 'any', password_type => 'clear',
+        authorization_required_message => undef
+    );
+    throws_ok {
+        $self->authenticate( $c, $realm );
+    } qr/^ $Catalyst::DETACH $/x, "detached";
+    is( $body, undef, 'Body is not set - user overrode auth message');
+}
\ No newline at end of file