Anonymous avatar Anonymous committed 95fa608

Doc improvements\n\nTest for long parameters

Comments (0)

Files changed (4)

 Build.PL
 Changes
+INSTALL
 lib/Passwd/Keyring/KDEWallet.pm
 Makefile.PL
 MANIFEST			This list of files

lib/Passwd/Keyring/KDEWallet.pm

 
     use Passwd::Keyring::KDEWallet;
 
-    my $keyring = Passwd::Keyring::KDEWallet->new(app=>"My beautiful app", group=>"My app web passwords");
+    my $keyring = Passwd::Keyring::KDEWallet->new(
+         app=>"blahblah scraper",
+         group=>"Johnny web scrapers",
+    );
 
-    $keyring->set_password("John", "verysecret", "my-pseudodomain");
-    # And later, on next run maybe
-    my $password = $keyring->get_password("John", "my-pseudodomain");
-    # plus
-    $keyring->clear_password("John", "my-pseudodomain");
+    my $username = "John";  # or get from .ini, or from .argv...
 
-Note: see L<Passwd::Keyring::Auto::KeyringAPI> for detailed comments on
-keyring method semantics (this document is installed with
-Passwd::Keyring::Auto package).
+    my $password = $keyring->get_password($username, "blahblah.com");
+    unless( $password ) {
+        $password = <somehow interactively prompt for password>;
+
+        # securely save password for future use
+        $keyring->set_password($username, "blahblah.com");
+    }
+
+    login_somewhere_using($username, $password);
+    if( password_was_wrong ) {
+        $keyring->clear_password($username, "blahblah.com");
+    }
+
+Note: see L<Passwd::Keyring::Auto::KeyringAPI> for detailed comments
+on keyring method semantics (this document is installed with
+C<Passwd::Keyring::Auto> package).
 
 =head1 SUBROUTINES/METHODS
 
-=head2 new
+=head2 new(app=>'app name', group=>'passwords folder')
 
 Initializes the processing. Croaks if kwallet does not 
 seem to be available.
 
+Handled named parameters: 
+
+- app - symbolic application name (used in "Application .... is asking to open the wallet"
+  KDE Wallet prompt)
+
+- group - name for the password group (used as KDE Wallet folder name)
+
 =cut
 
 sub new {
 #!/usr/bin/perl -w
-#
-# Package maintainer helper. Builds, tests, tags and releases
-# the package to cpan. Nothing interesting, just saves some typing.
 
-use FindBin;
-use autodie qw(:all);
-use Moose::Util::TypeConstraints;
-use Carp;
-use feature 'say';
-
-$Carp::Verbose = 0;
-
-{
-    subtype TagNo
-      => as 'Str'
-      => where { $_ =~ m{^\d+\.\d{2,6}$} }
-      => message { "Expected tag with format 1.23" };
-}
-
-{
-    package RunMe;
-    use Moose;
-    with 'MooseX::Getopt';
-    
-    use Path::Class qw(file);
-    use IPC::System::Simple qw(capturex systemx);
-    use DateTime;
-
-    has tag => (is=>'ro', isa=>'TagNo', required=>1);
-    has force => (is=>'ro', isa=>'Bool', required=>0, default=>0);
-    has noupload => (is=>'ro', isa=>'Bool', required=>0, default=>0);
-
-    sub run {
-        my $self = shift;
-
-        chdir $FindBin::Bin;
-
-        my $dt = DateTime->today->ymd;
-        my $tag = $self->tag;
-
-        say "* Sanity checks";
-
-        # Some sanity checks
-        $self->ensure_regexps_in_file(
-            file(".hg", "hgrc"),
-            qr/^pre-tag *= *python:version_hook/,
-            "Version hook not installed. See version_hook.py");
-        $self->ensure_regexps_in_file(
-            file("MANIFEST.SKIP"),
-            qr/^\^\\\.hg$/,
-            ".hg not skipped. Add it to MANIFEST.SKIP",
-            qr/^\^make_release\\.pl$/,
-            "make_release.pl not skipped. Add it to MANIFEST.SKIP",
-            qr/^\^version_hook\\.py$/,
-            "version_hook.py not skipped. Add it to MANIFEST.SKIP",
-           );
-
-        $self->ensure_regexps_in_file(
-            file("Changes"),
-            qr/^$tag +\d{4}-\d{2}-\d{2} *$/,
-            "No Changes entry. Please add\n\n$tag    $dt\n        Some desc");
-            
-        # Check for uncommited changes
-        my $reply = capturex([0], "hg", "status");
-        if($reply) {
-            die "Uncommited or unmanaged files in module directory.\nCommit everything before release.\nhg status:\n$reply\n";
-        }
-
-
-        say "* Preliminary build";
-
-        # Perform preliminary build and test
-        systemx("perl", "Build.PL");
-        systemx("./Build");
-        systemx("./Build", "distmeta");
-        systemx("./Build", "test");
-        systemx("./Build", "distcheck");
-
-        say "* Tag";
-
-        # Put tag
-        systemx("hg", "tag", 
-                $self->force ? ("-f") : (),
-                $self->tag);
-
-        say "* Sources push";
-
-        # Push changes
-        systemx("hg", "push", "bitbucket");
-
-        say "* Final build and test";
-
-        # Clean, build, and test again
-        systemx("./Build", "distclean");
-        systemx("perl", "Build.PL");
-        systemx("./Build");
-        systemx("./Build", "test");
-        
-        say "* Distro";
-
-        $reply = capturex("./Build", "dist");
-        print $reply;
-        if($reply =~ /^Creating (.*\.tar\.gz)$/m) {
-            my $distro = $1;
-            unless($self->noupload) {
-                print "Uploading $distro\n";
-                systemx("cpan-upload", $distro);
-            } else {
-                print "Remember to do\n    cpan-upload $distro\n";
-            }
-        }
-    }
-
-    sub ensure_regexps_in_file {
-        my $self = shift;
-        my $file = shift;
-        my $rgxp = shift;
-        my $comment = shift;
-        unless( -f $file ) {
-            die "File $file missing. $comment\n";
-        }
-        my @lines = $file->openr()->getlines();
-        while(1) {
-            unless( grep { /$rgxp/ } @lines ) {
-                die "File $file does not contain expected text.\n$comment\n";
-            }
-            $rgxp = shift;
-            $comment = shift;
-            last unless $rgxp;
-        }
-    }
-
-}
-
-my $run_me = RunMe->new_with_options;
-$run_me->run();
+die "Use cpan_make_relase\n";

t/08-verylong-params.t

+#!perl -T
+
+use strict;
+use warnings;
+use Test::Simple tests => 4;
+
+use Passwd::Keyring::KDEWallet;
+
+my $APP = "Passwd::KDEWallet::Keyring unit test 08 ";
+$APP .= "X" x (256 - length($APP));
+my $GROUP = "Passwd::KDEWallet::Keyring unit tests ";
+$GROUP .= "X" x (256 - length($GROUP));
+
+my $USER = "A" x 256;
+my $PWD =  "B" x 256;
+my $DOMAIN = 'C' x 256;
+
+my $ring = Passwd::Keyring::KDEWallet->new(
+    app=>$APP, group=>$GROUP);
+
+ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet',   'new() works with long params' );
+
+$ring->set_password($USER, $PWD, $DOMAIN);
+
+ok( 1, "set_password with long params works" );
+
+ok( $ring->get_password($USER, $DOMAIN) eq $PWD, "get_password with long params works");
+
+ok( $ring->clear_password($USER, $DOMAIN) eq 1, "clear_password with long params works");
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.