summaryrefslogtreecommitdiff
path: root/rt/t/web/install.t
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-07-09 22:32:26 -0700
committerIvan Kohler <ivan@freeside.biz>2015-07-09 22:32:26 -0700
commit026dc7ad72ba972f230b6709e31fa64397d75ad4 (patch)
treec5af1a7ac9154744afc3660e9a9405892f2bb50b /rt/t/web/install.t
parent07b4bc84d1078f7390221d766cdb3142513db4b0 (diff)
parent1c538bfabc2cd31f27067505f0c3d1a46cba6ef0 (diff)
merge RT 4.2.11 and Header changes to disable RT javascript, RT#34237
Diffstat (limited to 'rt/t/web/install.t')
-rw-r--r--rt/t/web/install.t173
1 files changed, 173 insertions, 0 deletions
diff --git a/rt/t/web/install.t b/rt/t/web/install.t
new file mode 100644
index 000000000..e33e58b16
--- /dev/null
+++ b/rt/t/web/install.t
@@ -0,0 +1,173 @@
+use strict;
+use warnings;
+use File::Spec;
+
+$ENV{RT_TEST_WEB_HANDLER} = 'plack+rt-server';
+use RT::Test
+ tests => undef,
+ nodb => 1,
+ server_ok => 1;
+
+my $dbname = 'rt4test_install_xxx';
+my $rtname = 'rttestname';
+my $domain = 'rttes.com';
+my $password = 'newpass';
+my $correspond = 'reply@example.com';
+my $comment = 'comment@example.com';
+
+# use bin/rt to fake sendmail to make sure the file exists
+my $sendmail = File::Spec->catfile( $RT::BinPath, 'rt' );
+my $owner = 'root@localhost';
+
+unlink File::Spec->catfile( $RT::VarPath, $dbname );
+
+my ( $url, $m ) = RT::Test->started_ok;
+$m->warning_like(qr/If this is a new installation of RT/,
+ "Got startup warning");
+
+my ($port) = $url =~ /:(\d+)/;
+$m->get_ok($url);
+
+is( $m->uri, $url . '/Install/index.html', 'install page' );
+$m->select( 'Lang', 'zh-cn' );
+$m->click('ChangeLang');
+$m->content_contains( Encode::decode("UTF-8",'语言'), 'select chinese' );
+
+$m->click('Run');
+$m->content_contains( Encode::decode("UTF-8",'数据库'), 'select db type in chinese' );
+
+$m->back;
+$m->select( 'Lang', 'en' );
+$m->click('ChangeLang');
+$m->content_contains( 'Select another language', 'back to english' );
+
+$m->click('Run');
+
+is( $m->uri, $url . '/Install/DatabaseType.html', 'db type page' );
+my $select_type = $m->current_form->find_input('DatabaseType');
+my @possible_types = $select_type->possible_values;
+ok( @possible_types, 'we have at least 1 db type' );
+
+SKIP: {
+ skip 'no mysql found', 7 unless grep { /mysql/ } @possible_types;
+ $m->select( 'DatabaseType', 'mysql' );
+ $m->click;
+ for my $field (qw/Name Host Port Admin AdminPassword User Password/) {
+ ok( $m->current_form->find_input("Database$field"),
+ "db mysql has field Database$field" );
+ }
+ $m->back;
+}
+
+SKIP: {
+ skip 'no pg found', 8 unless grep { /Pg/ } @possible_types;
+ $m->select( 'DatabaseType', 'Pg' );
+ $m->click;
+ for my $field (
+ qw/Name Host Port Admin AdminPassword User Password/)
+ {
+ ok( $m->current_form->find_input("Database$field"),
+ "db Pg has field Database$field" );
+ }
+ $m->back;
+}
+
+$m->select( 'DatabaseType', 'SQLite' );
+$m->click;
+
+is( $m->uri, $url . '/Install/DatabaseDetails.html', 'db details page' );
+$m->field( 'DatabaseName' => $dbname );
+$m->submit_form( fields => { DatabaseName => $dbname } );
+$m->content_contains( 'Connection succeeded', 'succeed msg' );
+$m->content_contains(
+qq{$dbname already exists, but does not contain RT&#39;s tables or metadata. The &#39;Initialize Database&#39; step later on can insert tables and metadata into this existing database. if this is acceptable, click &#39;Customize Basic&#39; below to continue customizing RT.},
+ 'more db state msg'
+);
+$m->click;
+
+is( $m->uri, $url . '/Install/Basics.html', 'basics page' );
+$m->click;
+$m->content_contains(
+ 'You must enter an Administrative password',
+ "got password can't be empty error"
+);
+
+for my $field (qw/rtname WebDomain WebPort Password/) {
+ ok( $m->current_form->find_input($field), "has field $field" );
+}
+is( $m->value('WebPort'), $port, 'default port' );
+$m->field( 'rtname' => $rtname );
+$m->field( 'WebDomain' => $domain );
+$m->field( 'Password' => $password );
+$m->click;
+
+is( $m->uri, $url . '/Install/Sendmail.html', 'mail page' );
+for my $field (qw/SendmailPath OwnerEmail/) {
+ ok( $m->current_form->find_input($field), "has field $field" );
+}
+
+$m->field( 'OwnerEmail' => '' );
+$m->click;
+$m->content_contains( "doesn&#39;t look like an email address",
+ 'got email error' );
+
+$m->field( 'SendmailPath' => '/fake/path/sendmail' );
+$m->click;
+$m->content_contains( "/fake/path/sendmail doesn&#39;t exist",
+ 'got sendmail error' );
+
+$m->field( 'SendmailPath' => $sendmail );
+$m->field( 'OwnerEmail' => $owner );
+$m->click;
+
+is( $m->uri, $url . '/Install/Global.html', 'global page' );
+for my $field (qw/CommentAddress CorrespondAddress/) {
+ ok( $m->current_form->find_input($field), "has field $field" );
+}
+
+$m->click;
+is( $m->uri, $url . '/Install/Initialize.html', 'init db page' );
+$m->back;
+
+is( $m->uri, $url . '/Install/Global.html', 'global page' );
+$m->field( 'CorrespondAddress' => 'reply' );
+$m->click;
+$m->content_contains( "doesn&#39;t look like an email address",
+ 'got email error' );
+$m->field( 'CommentAddress' => 'comment' );
+$m->click;
+$m->content_contains( "doesn&#39;t look like an email address",
+ 'got email error' );
+
+$m->field( 'CorrespondAddress' => 'reply@example.com' );
+$m->field( 'CommentAddress' => 'comment@example.com' );
+$m->click;
+
+is( $m->uri, $url . '/Install/Initialize.html', 'init db page' );
+$m->click;
+
+is( $m->uri, $url . '/Install/Finish.html', 'finish page' );
+$m->click;
+
+is( $m->uri, $url . '/', 'home page' );
+$m->login( 'root', $password );
+$m->content_contains( 'RT at a glance', 'logged in with newpass' );
+
+RT->LoadConfig;
+my $config = RT->Config;
+
+is( $config->Get('DatabaseType'), 'SQLite', 'DatabaseType in config' );
+is( $config->Get('DatabaseName'), $dbname, 'DatabaseName in config' );
+is( $config->Get('rtname'), $rtname, 'rtname in config' );
+is( $config->Get('WebDomain'), $domain, 'WebDomain email in config' );
+is( $config->Get('WebPort'), $port, 'WebPort email in config' );
+is( $config->Get('SendmailPath'), $sendmail, 'SendmailPath in config' );
+is( $config->Get('OwnerEmail'), $owner, 'OwnerEmail in config' );
+is( $config->Get('CorrespondAddress'),
+ $correspond, 'correspond address in config' );
+is( $config->Get('CommentAddress'), $comment, 'comment address in config' );
+
+unlink File::Spec->catfile( $RT::VarPath, $dbname );
+
+undef $m;
+done_testing;