RT notifier: parse templates without header correctly
[openxpki.git] / trunk / clients / perl / OpenXPKI-Client-HTML-Mason / t / 20_webserver / 16_csr_serverside.t
blobb94d5f4bac30a72bba1f4d64cc4eb2869230bab3
1 use strict;
2 use warnings;
3 use English;
4 use lib 't/20_webserver/lib';
6 use OpenXPKI::Client::HTML::Mason::Test::Server;
7 use WWW::Mechanize;
8 use URI::Escape;
10 use Test::More;
11 plan tests => 22;
13 my $TEST_PORT = 8099;
14 if ($ENV{MASON_TEST_PORT}) {
15     # just in case someone wants to overwrite the test webserver port
16     # for some reason
17     $TEST_PORT = $ENV{MASON_TEST_PORT};
20 diag("Start page and login");
22 my $server = OpenXPKI::Client::HTML::Mason::Test::Server->new($TEST_PORT);
23 $server->started_ok('Webserver start');
24 my $mech = WWW::Mechanize->new();
26 # login as anonymous
27 my $index_page = $mech->get("http://127.0.0.1:$TEST_PORT/")->content();
28 unlike($index_page, qr/I18N_OPENXPKI_CLIENT_INIT_CONNECTION_FAILED/, 'No connection failed error on start page') or diag "Index: $index_page";
29 like($index_page, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_GET_AUTHENTICATION_STACK_TITLE/, 'Correct title');
31 $mech->form_name('OpenXPKI');
32 $mech->field('auth_stack', 'Anonymous');
33 $mech->click('submit');
34 is($mech->response->code(), '200', 'HTTP 200 OK received');
35 like($mech->response->content, qr/meta http-equiv="refresh"/, 'Redirect page received');
37 my ($session_id) = ($mech->response->content =~ m{__session_id=([0-9a-f]+)}xms);
38 if ($ENV{DEBUG}) {
39     diag "Session ID: $session_id";
42 # go to redirect page
43 $mech->get("http://127.0.0.1:$TEST_PORT/service/index.html?__session_id=$session_id&__role=");
44 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_INTRO_TITLE/, 'Correct title');
46 # Server side key generation
47 ok($mech->follow_link(text => 'I18N_OPENXPKI_HTML_MENU_REQUEST', n => '1'), 'Followed link');
48 ok($mech->follow_link(text => 'I18N_OPENXPKI_HTML_MENU_CERTIFICATE_SIGNING_REQUEST', n => '1'), 'Followed link');
49 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_ROLE_TITLE/, 'Role selection on first page');
50 $mech->form_name('OpenXPKI');
51 $mech->field('role', 'Web Server');
52 $mech->click('__submit');
53 like($mech->response->content, qr/18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_SUBJECT_STYLE_TITLE/, 'Style selection');
55 $mech->form_name('OpenXPKI');
56 $mech->field('subject_style', '00_tls_basic_style');
57 $mech->field('role', 'Web Server');
58 $mech->click('__submit');
59 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_KEYGEN_TITLE/, 'Key generation method');
61 $mech->form_name('OpenXPKI');
62 $mech->field('keygen', 'SERVERSIDE');
63 $mech->field('subject_style', '00_tls_basic_style');
64 $mech->field('role', 'Web Server');
65 $mech->click('__submit');
66 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_SUBJECT_TITLE/, 'Subject');
68 $mech->form_name('OpenXPKI');
69 $mech->field('cert_subject_hostname', 'example2.example.com');
70 $mech->field('cert_subject_port', '1234');
71 $mech->field('keygen', 'SERVERSIDE');
72 $mech->field('subject_style', '00_tls_basic_style');
73 $mech->field('role', 'Web Server');
74 $mech->click('__submit');
75 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_INFO_TITLE/, 'Additional information');
77 $mech->form_name('OpenXPKI');
78 $mech->field('additional_info_phone', '1234');
79 $mech->field('keygen', 'SERVERSIDE');
80 $mech->field('additional_info_comment', 'comment');
81 $mech->field('cert_subject_hostname', 'example2.example.com');
82 $mech->field('cert_subject_port', '1234');
83 $mech->field('subject_style', '00_tls_basic_style');
84 $mech->field('role', 'Web Server');
85 $mech->click('__submit');
86 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_KEYTYPE_TITLE/, 'Private key type');
88 $mech->form_name('OpenXPKI');
89 $mech->field('additional_info_phone', '1234');
90 $mech->field('keygen', 'SERVERSIDE');
91 $mech->field('keytype', 'RSA');
92 $mech->field('additional_info_comment', 'comment');
93 $mech->field('cert_subject_hostname', 'example2.example.com');
94 $mech->field('cert_subject_port', '1234');
95 $mech->field('subject_style', '00_tls_basic_style');
96 $mech->field('role', 'Web Server');
97 $mech->click('__submit');
98 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_KEYPARAMETERS_TITLE/, 'Private key parameters');
100 $mech->form_name('OpenXPKI');
101 $mech->field('additional_info_phone', '1234');
102 $mech->field('keygen', 'SERVERSIDE');
103 $mech->field('keytype', 'RSA');
104 $mech->field('additional_info_comment', 'comment');
105 $mech->field('cert_subject_hostname', 'example2.example.com');
106 $mech->field('cert_subject_port', '1234');
107 $mech->field('subject_style', '00_tls_basic_style');
108 $mech->field('PARAMETER_ENC_ALG', 'aes256');
109 $mech->field('PARAMETER_KEY_LENGTH', '4096');
110 $mech->field('role', 'Web Server');
111 $mech->click('__submit');
112 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_PASSWORD_GENERATION_METHOD_TITLE/, 'Password generation method');
114 $mech->form_name('OpenXPKI');
115 $mech->field('additional_info_phone', '1234');
116 $mech->field('keygen', 'SERVERSIDE');
117 $mech->field('keytype', 'RSA');
118 $mech->field('additional_info_comment', 'comment');
119 $mech->field('cert_subject_hostname', 'example2.example.com');
120 $mech->field('cert_subject_port', '1234');
121 $mech->field('subject_style', '00_tls_basic_style');
122 $mech->field('PARAMETER_ENC_ALG', 'aes256');
123 $mech->field('PARAMETER_KEY_LENGTH', '4096');
124 $mech->field('role', 'Web Server');
125 $mech->field('password_gen', 'generate');
126 $mech->click('__submit');
127 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_PASSWORD_GENERATED_TITLE/, 'Generated password');
128 my ($password) = ($mech->response->content =~ m{ <b> (.+) </b> }xms);
129 if ($ENV{DEBUG}) {
130     diag "Password: $password";
133 $mech->form_name('OpenXPKI');
134 $mech->field('additional_info_phone', '1234');
135 $mech->field('keygen', 'SERVERSIDE');
136 $mech->field('keytype', 'RSA');
137 $mech->field('additional_info_comment', 'comment');
138 $mech->field('cert_subject_hostname', 'example2.example.com');
139 $mech->field('cert_subject_port', '1234');
140 $mech->field('subject_style', '00_tls_basic_style');
141 $mech->field('PARAMETER_ENC_ALG', 'aes256');
142 $mech->field('PARAMETER_KEY_LENGTH', '4096');
143 $mech->field('role', 'Web Server');
144 $mech->field('password_gen', 'generate');
145 $mech->field('password', $password);
146 $mech->click('__submit');
148 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_RECEIPT_CONFIRMATION_TITLE/, 'CSR received');
149 like($mech->response->content, qr/I18N_OPENXPKI_PROFILE_TLS_SERVER/, 'TLS server profile');
150 like($mech->response->content, qr/CN=example2.example.com:1234,DC=Test\ Deployment,DC=OpenXPKI,DC=org/, 'Certificate subject');
151 like($mech->response->content, qr/I18N_OPENXPKI_PROFILE_TLS_SERVER/, 'TLS server profile');
152 like($mech->response->content, qr/CN=example2.example.com:1234,DC=Test\ Deployment,DC=OpenXPKI,DC=org/, 'Certificate subject');