root/alternc/tags/0.9.7/tests/test_demo.pl

Revision 1953, 2.7 kB (checked in by benjamin, 1 year ago)

adding test cases using libtest-www-mechanize-perl

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2
3 #use strict;
4 use WWW::Mechanize;
5
6 use mechdump;
7
8 my $DEBUG=1;
9 my $DESKTOP="http://demo.alternc.org/admin";
10 my $ADMIN_ACCOUNT="admin";
11 my $ADMIN_PASSWORD="admin";
12
13 # We install this domain, this pop account etc. :
14 my $DOMAIN="demo2.alternc.org";
15 my $EMAIL="test";
16 my $POPPASS="coinP4n";
17
18 my $FTPLOGIN="test";
19 my $FTPPASS="p4ncoin";
20 my $FTPFOLD="/";
21
22 # We initialize a mechanize object :
23 $m = WWW::Mechanize->new( agent => '(Mozilla 5.0) AlternC test'  );
24
25 # We get the desktop absolute url :
26 $m->get($DESKTOP);
27
28 # We submit the login/password for the adminisrator account :
29 my $r = $m->submit_form(form_number => 1,
30                         fields => { 'username' => $ADMIN_ACCOUNT, 'password' => $ADMIN_PASSWORD }
31                         );
32 if ($DEBUG) {
33     print "LINKS AFTER LOGIN : \n"; dump_links $m;
34 }
35
36 $m->follow_link(url_regex => qr/menu/i ) || die "Login or password incorrect ...";
37
38 if ($DEBUG) {
39     print "LINKS IN LEFT FRAME : \n"; dump_links $m;
40 }
41
42
43 # For each service, we create one instance of testable one :
44
45
46 # DOMAIN :
47 print "Adding domain $DOMAIN \n";
48 $m->follow_link(url_regex => qr/dom_add/i ) || die "Cannot add a new domain ...";
49 my $r = $m->submit_form(form_number => 1,
50                 fields => { 'newdomain' => $DOMAIN, 'dns' => 1 }
51                 );
52 if (!$r->is_success()) {
53     # Impossible d'ajouter le domaine : la form n'existe pas ...
54     die "Cannot add domain $DOMAIN ...";
55 }
56 print "  done \n";
57
58
59
60 # EMAIL :
61 print "Creating a mail $EMAIL\@$DOMAIN \n";
62 $m->get("menu.php");  # does relative url works ?
63 $m->follow_link(url_regex => qr/mail\_list\.php\?domain\=$DOMAIN/i ) || die "Cannot list mails for domain $DOMAIN ...";
64 $m->follow_link(url_regex => qr/mail\_add\.php\?domain\=$DOMAIN/i ) ||  die "Cannot find the 'add email' link for domain $DOMAIN ...";
65
66 my $r = $m->submit_form(form_number => 1,
67                 fields => { "domain" => $DOMAIN,
68                             "email" => $EMAIL,
69                             "pop" => 1,
70                             "pass" => $POPPASS,
71                             "passconf" => $POPPASS,
72                             "alias" => "",
73                         }
74                 );
75 if (!$r->is_success()) {
76     # Impossible d'ajouter le mail : la form n'existe pas ...
77     die "Cannot add email $EMAIL\@$DOMAIN ...";
78 }
79 print "  done \n";
80
81
82
83 # FTP :
84 print "Creating a ftp account ${ADMIN_ACCOUNT}_${FTPLOGIN} \n";
85 $m->get("menu.php");  # does relative url works ?
86 $m->follow_link(url_regex => qr/ftp\_list\.php/i ) || die "Cannot list ftp accounts ...";
87 $m->follow_link(url_regex => qr/ftp\_add\.php/i ) || die "Cannot find the 'add ftp' link ...";
88 my $r = $m->submit_form(form_number => 1,
89                         fields => { "id" => 0,
90                             "" => $,
91                                 }
92                         );
93 if (!$r->is_success()) {
94     # Impossible d'ajouter le mail : la form n'existe pas ...
95     die "Cannot add email $EMAIL\@$DOMAIN ...";
96 }
97 print "  done \n";
98
99
100
101
102
103 # SQL :
104 # sql_list.php
105
Note: See TracBrowser for help on using the browser.