... | ... |
@@ -28,3 +28,4 @@ setup/log/* |
28 | 28 |
setup/latest-build |
29 | 29 |
setup/work/* |
30 | 30 |
setup/build.log |
31 |
+xt/admin.db |
... | ... |
@@ -80,6 +80,8 @@ |
80 | 80 |
|
81 | 81 |
% layout 'common'; |
82 | 82 |
|
83 |
+ <!-- Login Page --> |
|
84 |
+ |
|
83 | 85 |
%= include '/include/header'; |
84 | 86 |
|
85 | 87 |
<div class="container"> |
... | ... |
@@ -13,14 +13,14 @@ |
13 | 13 |
|
14 | 14 |
# Check existence admin user |
15 | 15 |
my $admin_user = app->manager->admin_user; |
16 |
- if (defined $admin_user) { $errors = ['admin user already exists.'] } |
|
16 |
+ if (defined $admin_user) { $errors = ['Admin user already exists.'] } |
|
17 | 17 |
else { |
18 | 18 |
# Validation |
19 | 19 |
my $params = $api->params; |
20 | 20 |
my $rule = [ |
21 | 21 |
password => [ |
22 | 22 |
['not_blank' => 'Password is empty.'], |
23 |
- ['ascii' => 'Password contain invalid character.'], |
|
23 |
+ ['ascii' => 'Password contains invalid character.'], |
|
24 | 24 |
[{'length' => {max => 20}} => 'Password is too long.'] |
25 | 25 |
], |
26 | 26 |
{password_check => [qw/password password2/]} |
... | ... |
@@ -48,6 +48,8 @@ |
48 | 48 |
# Redirect |
49 | 49 |
$self->flash(admin_user_created => 1); |
50 | 50 |
$self->redirect_to('/_login'); |
51 |
+ $self->finish_rendering; |
|
52 |
+ return; |
|
51 | 53 |
} |
52 | 54 |
else { $errors = $vresult->messages } |
53 | 55 |
} |
... | ... |
@@ -19,12 +19,15 @@ my $rep_home = $ENV{GITPREP_REP_HOME} = "$FindBin::Bin/admin"; |
19 | 19 |
|
20 | 20 |
use Gitprep; |
21 | 21 |
|
22 |
-my $app = Gitprep->new; |
|
23 |
-my $t = Test::Mojo->new($app); |
|
24 |
-$t->ua->max_redirects(3); |
|
25 | 22 |
|
26 | 23 |
note '_start page'; |
27 | 24 |
{ |
25 |
+ unlink $db_file; |
|
26 |
+ |
|
27 |
+ my $app = Gitprep->new; |
|
28 |
+ my $t = Test::Mojo->new($app); |
|
29 |
+ $t->ua->max_redirects(3); |
|
30 |
+ |
|
28 | 31 |
# Redirect to _start page |
29 | 32 |
$t->get_ok('/')->content_like(qr/Create Admin User/); |
30 | 33 |
|
... | ... |
@@ -35,4 +38,30 @@ note '_start page'; |
35 | 38 |
$t->post_ok('/_start?op=create', form => {password => ''}) |
36 | 39 |
->content_like(qr/Password is empty/) |
37 | 40 |
; |
41 |
+ |
|
42 |
+ # Password contains invalid character |
|
43 |
+ $t->post_ok('/_start?op=create', form => {password => "\t"}) |
|
44 |
+ ->content_like(qr/Password contains invalid character/) |
|
45 |
+ ; |
|
46 |
+ |
|
47 |
+ # Password contains invalid character |
|
48 |
+ $t->post_ok('/_start?op=create', form => {password => 'a' x 21}) |
|
49 |
+ ->content_like(qr/Password is too long/) |
|
50 |
+ ; |
|
51 |
+ |
|
52 |
+ # Two password don't match |
|
53 |
+ $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'b'}) |
|
54 |
+ ->content_like(qr/Two password/) |
|
55 |
+ ; |
|
56 |
+ |
|
57 |
+ # Create admin user |
|
58 |
+ $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}) |
|
59 |
+ ->content_like(qr/Login Page/); |
|
60 |
+ ; |
|
61 |
+ |
|
62 |
+ # Admin user already exists |
|
63 |
+ $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'}) |
|
64 |
+ ->content_like(qr/Admin user already exists/); |
|
65 |
+ ; |
|
66 |
+ |
|
38 | 67 |
} |