X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Ftext_tradition_user.t;h=a401ebe2b4955235f20243a79253c79c448a4f81;hb=b77f6c1bee7890af1189201ff40eb8005e3e671f;hp=b9810b7ddd6b49d1c46f5944383f1a3525926f8b;hpb=9fef629bd3a741a6d74d130f10056898d504fb47;p=scpubgit%2Fstemmatology.git diff --git a/t/text_tradition_user.t b/t/text_tradition_user.t index b9810b7..a401ebe 100644 --- a/t/text_tradition_user.t +++ b/t/text_tradition_user.t @@ -5,6 +5,7 @@ use warnings; use Test::More 'no_plan'; use File::Temp; +use TryCatch; use_ok('Text::Tradition::Directory'); @@ -21,6 +22,15 @@ my $scope = $user_store->new_scope; ## passwords my $shortpass = 'bloggs'; ok(!$user_store->validate_password($shortpass), '"bloggs" is too short for a password'); +try { + my $dud_user = $user_store->add_user({ username => 'joe', + password => $shortpass }); + ok( 0, "User with short password should not have been created" ); +} catch ( Text::Tradition::Error $e ) { + is( $e->message, "Invalid password - must be at least " + . $user_store->MIN_PASS_LEN . " characters long", + "Attempt to add user with too-short password threw correct error" ); +} ## create user my $new_user = $user_store->add_user({ username => 'fred',