Add password for host.
authorjelmer <jelmer@1e5ffdc8-eadd-0310-9daa-9cb4117fe24b>
Mon, 21 Apr 2008 09:37:12 +0000 (09:37 +0000)
committerjelmer <jelmer@1e5ffdc8-eadd-0310-9daa-9cb4117fe24b>
Mon, 21 Apr 2008 09:37:12 +0000 (09:37 +0000)
git-svn-id: file:///home/svn/build-farm/trunk@773 1e5ffdc8-eadd-0310-9daa-9cb4117fe24b

hostdb.pm
tests/hostdb.pl

index 9c07b1f9fecc366d9637cdf091a8590305340d1e..5e3005ed2a9625fd8ccd1709a69456539927e4a5 100644 (file)
--- a/hostdb.pm
+++ b/hostdb.pm
@@ -8,7 +8,7 @@ sub new($)
  {
     my ($class, $filename) = @_;
     
-    my $dbh = DBI->connect("dbi:SQLite:$filename") or die("Unable to open SQLite database $filename: $!");
+    my $dbh = DBI->connect("dbi:SQLite:$filename") or return undef;
     
     my $self = { filename => $filename, dbh => $dbh };
     
@@ -19,15 +19,15 @@ sub provision($)
 {
        my ($self) = @_;
        
-       $self->{dbh}->do("CREATE TABLE host ( name text, owner text, owner_email text, ssh_access int, platform text, permission text );");
+       $self->{dbh}->do("CREATE TABLE host ( name text, owner text, owner_email text, password text, ssh_access int, platform text, permission text );");
 }
 
 sub createhost($$$$$$)
 {
-       my ($self, $name, $platform, $owner, $owner_email, $permission) = @_;
-       my $sth = $self->{dbh}->prepare("INSERT INTO host (name, platform, owner, owner_email, permission) VALUES (?,?,?,?,?)");
+       my ($self, $name, $platform, $owner, $owner_email, $password, $permission) = @_;
+       my $sth = $self->{dbh}->prepare("INSERT INTO host (name, platform, owner, owner_email, password, permission) VALUES (?,?,?,?,?,?)");
        
-       $sth->execute($name, $platform, $owner, $owner_email, $permission);
+       $sth->execute($name, $platform, $owner, $owner_email, $password, $permission);
 }
 
 sub deletehost($$)
index 49faa39c8d4e428cbc40af44fa29fe9bdbc77b47..dc3116852d4f3864a2a9954e09bc9e00a8ae2a49 100755 (executable)
@@ -14,7 +14,7 @@ my $db = new hostdb("foo.sqlite");
 ok($db->provision());
 is_deeply([], $db->{dbh}->selectall_arrayref("SELECT * FROM host"));
 
-ok($db->createhost("gwalcmai", "vax", "jelmer", "jelmer\@example.com", "Yo! Please put me on the buildfarm"));
+ok($db->createhost("gwalcmai", "vax", "jelmer", "jelmer\@example.com", "geheim", "Yo! Please put me on the buildfarm"));
 
 is_deeply([["gwalcmai"]], $db->{dbh}->selectall_arrayref("SELECT name FROM host"));