password callback working
[scpubgit/Object-Remote.git] / xt / local-sudo.t
index b1a7fa6..c1f3d3a 100644 (file)
@@ -1,13 +1,24 @@
+use IO::Prompter; # dies, utterly, if loaded after strictures, no idea why
 use strictures 1;
 use Test::More;
 use lib 'xt/lib';
 
 use Object::Remote;
+use Object::Remote::Connector::LocalSudo;
+
 
 my $user = $ENV{TEST_SUDOUSER}
     or plan skip_all => q{Requires TEST_SUDOUSER to be set};
 
-my $remote = TestFindUser->new::on($user . '@');
+my $pw;
+
+my $connector = Object::Remote::Connector::LocalSudo->new(
+  password_callback => sub {
+    $pw ||= prompt 'Sudo password', -echo => '*';
+  }
+);
+
+my $remote = TestFindUser->new::on($connector->connect($user));
 my $remote_user = $remote->user;
 like $remote_user, qr/^\d+$/, 'returned an int';
 isnt $remote_user, $<, 'ran as different user';