Commits

Marcin Kasperski committed 4a713e1

Terminology fix (realm instead of domain)

Comments (0)

Files changed (8)

lib/Passwd/Keyring/KDEWallet.pm

       or croak("Failed to open the KDE wallet");
 }
 
-=head2 set_password(username, password, domain)
+=head2 set_password(username, password, realm)
 
-Sets (stores) password identified by given domain for given user 
+Sets (stores) password identified by given realm for given user 
 
 =cut
 
 sub set_password {
-    my ($self, $user_name, $user_password, $domain) = @_;
+    my ($self, $user_name, $user_password, $realm) = @_;
     $self->_open_if_not_open();
     my $status = $self->{kwallet}->writePassword(
-        $self->{handle}, $self->{group}, "$domain || $user_name", $user_password, $self->{app});
+        $self->{handle}, $self->{group}, "$realm || $user_name", $user_password, $self->{app});
     if($status) { # non-zero means failure
-        croak("Failed to save the password (status $status, user name $user_name, domain $domain, handle $self->{handle}, group $self->{group})");
+        croak("Failed to save the password (status $status, user name $user_name, realm $realm, handle $self->{handle}, group $self->{group})");
     }
 }
 
-=head2 get_password($user_name, $domain)
+=head2 get_password($user_name, $realm)
 
 Reads previously stored password for given user in given app.
 If such password can not be found, returns undef.
 =cut
 
 sub get_password {
-    my ($self, $user_name, $domain) = @_;
+    my ($self, $user_name, $realm) = @_;
     $self->_open_if_not_open();
     my $reply = $self->{kwallet}->readPassword(
-        $self->{handle}, $self->{group}, "$domain || $user_name", $self->{app});
+        $self->{handle}, $self->{group}, "$realm || $user_name", $self->{app});
     # In case of missing passsword we get empty string. I do not know
     # whether it is possible to distinguish missing password from empty password,
     # but empty passwords are exotic enough to ignore.
     return $reply;
 }
 
-=head2 clear_password($user_name, $domain)
+=head2 clear_password($user_name, $realm)
 
 Removes given password (if present)
 
 =cut
 
 sub clear_password {
-    my ($self, $user_name, $domain) = @_;
+    my ($self, $user_name, $realm) = @_;
     $self->_open_if_not_open();
     my $status = $self->{kwallet}->removeEntry(
-        $self->{handle}, $self->{group}, "$domain || $user_name", $self->{app});
+        $self->{handle}, $self->{group}, "$realm || $user_name", $self->{app});
     if($status == 0) {
         return 1;
     } else {
 
 my $USER = 'John';
 my $PASSWORD = 'verysecret';
-my $DOMAIN = 'some simple domain';
+my $REALM = 'some simple realm';
 
-$ring->set_password($USER, $PASSWORD, $DOMAIN);
+$ring->set_password($USER, $PASSWORD, $REALM);
 
 ok( 1, "set_password works" );
 
-is( $ring->get_password($USER, $DOMAIN), $PASSWORD, "get recovers");
+is( $ring->get_password($USER, $REALM), $PASSWORD, "get recovers");
 
-is( $ring->clear_password($USER, $DOMAIN), 1, "clear_password removed one password" );
+is( $ring->clear_password($USER, $REALM), 1, "clear_password removed one password" );
 
-is( $ring->get_password($USER, $DOMAIN), undef, "no password after clear");
+is( $ring->get_password($USER, $REALM), undef, "no password after clear");
 
-is( $ring->clear_password($USER, $DOMAIN), 0, "clear_password again has nothing to clear" );
+is( $ring->clear_password($USER, $REALM), 0, "clear_password again has nothing to clear" );
 
-is( $ring->clear_password("Non user", $DOMAIN), 0, "clear_password for unknown user has nothing to clear" );
-is( $ring->clear_password("$USER", 'non domain'), 0, "clear_password for unknown domain has nothing to clear" );
+is( $ring->clear_password("Non user", $REALM), 0, "clear_password for unknown user has nothing to clear" );
+is( $ring->clear_password("$USER", 'non realm'), 0, "clear_password for unknown realm has nothing to clear" );

t/03-many-sets-and-gets.t

 
 use Passwd::Keyring::KDEWallet;
 
-my $PSEUDO_DOMAIN = 'my@@domain';
-my $OTHER_DOMAIN = 'other domain';
+my $SOME_REALM = 'my@@realm';
+my $OTHER_REALM = 'other realm';
 
 my $ring = Passwd::Keyring::KDEWallet->new(app=>"Passwd::Keyring::KDEWallet", group=>"Unit tests");
 
 ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet',   'new() works' );
 
-$ring->set_password("Paul", "secret-Paul", $PSEUDO_DOMAIN);
-$ring->set_password("Gregory", "secret-Greg", $PSEUDO_DOMAIN);#
-$ring->set_password("Paul", "secret-Paul2", $OTHER_DOMAIN);
-$ring->set_password("Duke", "secret-Duke", $PSEUDO_DOMAIN);
+$ring->set_password("Paul", "secret-Paul", $SOME_REALM);
+$ring->set_password("Gregory", "secret-Greg", $SOME_REALM);#
+$ring->set_password("Paul", "secret-Paul2", $OTHER_REALM);
+$ring->set_password("Duke", "secret-Duke", $SOME_REALM);
 
 ok( 1, "set_password works" );
 
-ok( $ring->get_password("Paul", $PSEUDO_DOMAIN) eq 'secret-Paul', "get works");
+ok( $ring->get_password("Paul", $SOME_REALM) eq 'secret-Paul', "get works");
 
-ok( $ring->get_password("Gregory", $PSEUDO_DOMAIN) eq 'secret-Greg', "get works");
+ok( $ring->get_password("Gregory", $SOME_REALM) eq 'secret-Greg', "get works");
 
-ok( $ring->get_password("Paul", $OTHER_DOMAIN) eq 'secret-Paul2', "get works");
+ok( $ring->get_password("Paul", $OTHER_REALM) eq 'secret-Paul2', "get works");
 
-ok( $ring->get_password("Duke", $PSEUDO_DOMAIN) eq 'secret-Duke', "get works");
+ok( $ring->get_password("Duke", $SOME_REALM) eq 'secret-Duke', "get works");
 
-ok( $ring->clear_password("Paul", $PSEUDO_DOMAIN) eq 1, "clear_password removed 1");
+ok( $ring->clear_password("Paul", $SOME_REALM) eq 1, "clear_password removed 1");
 
-ok( ! defined($ring->get_password("Paul", $PSEUDO_DOMAIN)), "get works");
+ok( ! defined($ring->get_password("Paul", $SOME_REALM)), "get works");
 
-ok( $ring->get_password("Gregory", $PSEUDO_DOMAIN) eq 'secret-Greg', "get works");
+ok( $ring->get_password("Gregory", $SOME_REALM) eq 'secret-Greg', "get works");
 
-ok( $ring->get_password("Paul", $OTHER_DOMAIN) eq 'secret-Paul2', "get works");
+ok( $ring->get_password("Paul", $OTHER_REALM) eq 'secret-Paul2', "get works");
 
-ok( $ring->get_password("Duke", $PSEUDO_DOMAIN) eq 'secret-Duke', "get works");
+ok( $ring->get_password("Duke", $SOME_REALM) eq 'secret-Duke', "get works");
 
 
 # Note: cleanup is performed by test 04, we test passing data to

t/04-recovering-in-sep-prog.t

 
 use Passwd::Keyring::KDEWallet;
 
-my $PSEUDO_DOMAIN = 'my@@domain';
-my $OTHER_DOMAIN = 'other domain';
+my $SOME_REALM = 'my@@realm';
+my $OTHER_REALM = 'other realm';
 
 my $ring = Passwd::Keyring::KDEWallet->new(app=>"Passwd::Keyring::KDEWallet", group=>"Unit tests");
 
 ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet',   'new() works' );
 
-ok( ! defined($ring->get_password("Paul", $PSEUDO_DOMAIN)), "get works");
+ok( ! defined($ring->get_password("Paul", $SOME_REALM)), "get works");
 
-ok( $ring->get_password("Gregory", $PSEUDO_DOMAIN) eq 'secret-Greg', "get works");
+ok( $ring->get_password("Gregory", $SOME_REALM) eq 'secret-Greg', "get works");
 
-ok( $ring->get_password("Paul", $OTHER_DOMAIN) eq 'secret-Paul2', "get works");
+ok( $ring->get_password("Paul", $OTHER_REALM) eq 'secret-Paul2', "get works");
 
-ok( $ring->get_password("Duke", $PSEUDO_DOMAIN) eq 'secret-Duke', "get works");
+ok( $ring->get_password("Duke", $SOME_REALM) eq 'secret-Duke', "get works");
 
-ok( $ring->clear_password("Gregory", $PSEUDO_DOMAIN) eq 1, "clear clears");
+ok( $ring->clear_password("Gregory", $SOME_REALM) eq 1, "clear clears");
 
-ok( ! defined($ring->get_password("Gregory", $PSEUDO_DOMAIN)), "clear cleared");
+ok( ! defined($ring->get_password("Gregory", $SOME_REALM)), "clear cleared");
 
-ok( $ring->get_password("Paul", $OTHER_DOMAIN) eq 'secret-Paul2', "get works");
+ok( $ring->get_password("Paul", $OTHER_REALM) eq 'secret-Paul2', "get works");
 
-ok( $ring->get_password("Duke", $PSEUDO_DOMAIN) eq 'secret-Duke', "get works");
+ok( $ring->get_password("Duke", $SOME_REALM) eq 'secret-Duke', "get works");
 
-ok( $ring->clear_password("Paul", $OTHER_DOMAIN) eq 1, "clear clears");
+ok( $ring->clear_password("Paul", $OTHER_REALM) eq 1, "clear clears");
 
-ok( $ring->clear_password("Duke", $PSEUDO_DOMAIN) eq 1, "clear clears");
+ok( $ring->clear_password("Duke", $SOME_REALM) eq 1, "clear clears");
 
-ok( ! defined($ring->get_password("Paul", $PSEUDO_DOMAIN)), "clear cleared");
-ok( ! defined($ring->get_password("Duke", $PSEUDO_DOMAIN)), "clear cleared");
+ok( ! defined($ring->get_password("Paul", $SOME_REALM)), "clear cleared");
+ok( ! defined($ring->get_password("Duke", $SOME_REALM)), "clear cleared");
 
 
 

t/05-many-sets-and-gets-with-name.t

 
 use Passwd::Keyring::KDEWallet;
 
-my $DOMAIN_A = 'my@@domain';
-my $DOMAIN_B = 'bum trala la';
-my $DOMAIN_C = 'other domain';
+my $REALM_A = 'my@@realm';
+my $REALM_B = 'bum trala la';
+my $REALM_C = 'other realm';
 
 my $USER1 = "Paul Anton";
 my $USER2 = "Gżegąź";
 
 ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet',   'new() works' );
 
-$ring->set_password($USER1, $PWD1, $DOMAIN_B);
-$ring->set_password($USER2, $PWD2, $DOMAIN_B);#
-$ring->set_password($USER1, $PWD1_ALT, $DOMAIN_C);
-$ring->set_password($USER4, $PWD4, $DOMAIN_B);
+$ring->set_password($USER1, $PWD1, $REALM_B);
+$ring->set_password($USER2, $PWD2, $REALM_B);#
+$ring->set_password($USER1, $PWD1_ALT, $REALM_C);
+$ring->set_password($USER4, $PWD4, $REALM_B);
 
 ok( 1, "set_password works" );
 
-ok( $ring->get_password($USER1, $DOMAIN_B) eq $PWD1, "get works");
+ok( $ring->get_password($USER1, $REALM_B) eq $PWD1, "get works");
 
-ok( $ring->get_password($USER2, $DOMAIN_B) eq $PWD2, "get works");
+ok( $ring->get_password($USER2, $REALM_B) eq $PWD2, "get works");
 
-ok( $ring->get_password($USER1, $DOMAIN_C) eq $PWD1_ALT, "get works");
+ok( $ring->get_password($USER1, $REALM_C) eq $PWD1_ALT, "get works");
 
-ok( $ring->get_password($USER4, $DOMAIN_B) eq $PWD4, "get works");
+ok( $ring->get_password($USER4, $REALM_B) eq $PWD4, "get works");
 
-$ring->clear_password($USER1, $DOMAIN_B);
+$ring->clear_password($USER1, $REALM_B);
 ok(1, "clear_password works");
 
-ok( ! defined($ring->get_password($USER1, $DOMAIN_A)), "get works");
+ok( ! defined($ring->get_password($USER1, $REALM_A)), "get works");
 
-ok( ! defined($ring->get_password($USER2, $DOMAIN_A)), "get works");
+ok( ! defined($ring->get_password($USER2, $REALM_A)), "get works");
 
-ok( $ring->get_password($USER2, $DOMAIN_B) eq $PWD2, "get works");
+ok( $ring->get_password($USER2, $REALM_B) eq $PWD2, "get works");
 
-ok( $ring->get_password($USER1, $DOMAIN_C) eq $PWD1_ALT, "get works");
+ok( $ring->get_password($USER1, $REALM_C) eq $PWD1_ALT, "get works");
 
-ok( $ring->get_password($USER4, $DOMAIN_B) eq $PWD4, "get works");
+ok( $ring->get_password($USER4, $REALM_B) eq $PWD4, "get works");
 
-ok( $ring->clear_password($USER2, $DOMAIN_B) eq 1, "clear clears");
+ok( $ring->clear_password($USER2, $REALM_B) eq 1, "clear clears");
 
-ok( ! defined($ring->get_password($USER2, $DOMAIN_A)), "clear cleared");
+ok( ! defined($ring->get_password($USER2, $REALM_A)), "clear cleared");
 
-ok( $ring->get_password($USER1, $DOMAIN_C) eq $PWD1_ALT, "get works");
+ok( $ring->get_password($USER1, $REALM_C) eq $PWD1_ALT, "get works");
 
-ok( $ring->get_password($USER4, $DOMAIN_B) eq $PWD4, "get works");
+ok( $ring->get_password($USER4, $REALM_B) eq $PWD4, "get works");
 
-ok( $ring->clear_password($USER1, $DOMAIN_C) eq 1, "clear clears");
+ok( $ring->clear_password($USER1, $REALM_C) eq 1, "clear clears");
 
-ok( $ring->clear_password($USER4, $DOMAIN_B) eq 1, "clear clears");
+ok( $ring->clear_password($USER4, $REALM_B) eq 1, "clear clears");
 
-ok( ! defined($ring->get_password($USER1, $DOMAIN_C)), "clear cleared");
-ok( ! defined($ring->get_password($USER4, $DOMAIN_B)), "clear cleared");
+ok( ! defined($ring->get_password($USER1, $REALM_C)), "clear cleared");
+ok( ! defined($ring->get_password($USER4, $REALM_B)), "clear cleared");
 
 
 

t/06-recovering-with-app-change.t

 use Passwd::Keyring::KDEWallet;
 
 my $USER = "Herakliusz";
-my $DOMAIN = "test domain";
+my $REALM = "test realm";
 my $PWD = "arcytajne haslo";
 my $PWD2 = "inny sekret";
 
 
     ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet',   'new() works' );
 
-    ok( ! defined($ring->get_password($USER, $DOMAIN)), "initially unset");
+    ok( ! defined($ring->get_password($USER, $REALM)), "initially unset");
 
-    $ring->set_password($USER, $PWD, $DOMAIN);
+    $ring->set_password($USER, $PWD, $REALM);
     ok(1, "set password");
 
-    ok( $ring->get_password($USER, $DOMAIN) eq $PWD, "normal get works");
+    ok( $ring->get_password($USER, $REALM) eq $PWD, "normal get works");
 
     push @cleanups, sub {
-        ok( $ring->clear_password($USER, $DOMAIN) eq 1, "clearing");
+        ok( $ring->clear_password($USER, $REALM) eq 1, "clearing");
     };
 }
 
 
     ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet', 'second new() works' );
 
-    ok( $ring->get_password($USER, $DOMAIN) eq $PWD, "get from another ring with the same data works");
+    ok( $ring->get_password($USER, $REALM) eq $PWD, "get from another ring with the same data works");
 }
 
 # Only app changes
 
     ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet', 'third new() works' );
 
-    ok( $ring->get_password($USER, $DOMAIN) eq $PWD, "get from another ring with changed app but same group works");
+    ok( $ring->get_password($USER, $REALM) eq $PWD, "get from another ring with changed app but same group works");
 }
 
 # Only group changes
 
     ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet', 'third new() works' );
 
-    ok( ! defined($ring->get_password($USER, $DOMAIN)), "changing group forces another password");
+    ok( ! defined($ring->get_password($USER, $REALM)), "changing group forces another password");
 
     # To test whether original won't be spoiled
-    $ring->set_password($USER, $PWD2, $DOMAIN);
+    $ring->set_password($USER, $PWD2, $REALM);
 
     push @cleanups, sub {
-        ok( $ring->clear_password($USER, $DOMAIN) eq 1, "clearing");
+        ok( $ring->clear_password($USER, $REALM) eq 1, "clearing");
     };
 }
 
 
     ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet', 'third new() works' );
 
-    ok( ! defined($ring->get_password($USER, $DOMAIN)), "changing group and app forces another password");
+    ok( ! defined($ring->get_password($USER, $REALM)), "changing group and app forces another password");
 
 }
 
 
     ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet', 'second new() works' );
 
-    ok( $ring->get_password($USER, $DOMAIN) eq $PWD, "get original after changes in other group works");
+    ok( $ring->get_password($USER, $REALM) eq $PWD, "get original after changes in other group works");
 }
 
 # Cleanup
 
 my $UGLY_NAME = "Joh ## no ^^ »ąćęłóśż«";
 my $UGLY_PWD =  "«tajne hasło»";
-my $UGLY_DOMAIN = '«do»–main';
+my $UGLY_REALM = '«do»–main';
 
 my $ring = Passwd::Keyring::KDEWallet->new(app=>"Passwd::KDEWallet::Keyring unit tests", group=>"Ugly chars");
 
 ok( defined($ring) && ref $ring eq 'Passwd::Keyring::KDEWallet',   'new() works' );
 
-$ring->set_password($UGLY_NAME, $UGLY_PWD, $UGLY_DOMAIN);
+$ring->set_password($UGLY_NAME, $UGLY_PWD, $UGLY_REALM);
 
 ok( 1, "set_password with ugly chars works" );
 
-ok( $ring->get_password($UGLY_NAME, $UGLY_DOMAIN) eq $UGLY_PWD, "get works with ugly characters");
+ok( $ring->get_password($UGLY_NAME, $UGLY_REALM) eq $UGLY_PWD, "get works with ugly characters");
 
-ok( $ring->clear_password($UGLY_NAME, $UGLY_DOMAIN) eq 1, "clear clears");
+ok( $ring->clear_password($UGLY_NAME, $UGLY_REALM) eq 1, "clear clears");
 

t/08-verylong-params.t

 
 my $USER = "A" x 256;
 my $PWD =  "B" x 256;
-my $DOMAIN = 'C' x 256;
+my $REALM = '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);
+$ring->set_password($USER, $PWD, $REALM);
 
 ok( 1, "set_password with long params works" );
 
-ok( $ring->get_password($USER, $DOMAIN) eq $PWD, "get_password with long params works");
+ok( $ring->get_password($USER, $REALM) eq $PWD, "get_password with long params works");
 
-ok( $ring->clear_password($USER, $DOMAIN) eq 1, "clear_password with long params works");
+ok( $ring->clear_password($USER, $REALM) eq 1, "clear_password with long params works");