RT notifier: parse templates without header correctly
[openxpki.git] / trunk / clients / perl / OpenXPKI-Client-HTML-Mason / t / 20_webserver / 18_csr_ie.t
blobbf4c97ef6134e0e402c5b15b082aeb86a335978f
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 => 17;
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 # IE
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', 'IE');
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', 'example4.example.com');
70 $mech->field('cert_subject_port', '1234');
71 $mech->field('keygen', 'IE');
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', 'IE');
80 $mech->field('additional_info_comment', 'comment');
81 $mech->field('cert_subject_hostname', 'example4.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_IE_PKCS10_TITLE/, 'IE PKCS#10 page');
88 open my $PKCS10, '<', 't/20_webserver/csr.pem.ie';
89 my $pkcs10 = do { # slurp
90     local $INPUT_RECORD_SEPARATOR;
91     <$PKCS10>;
94 $mech->form_name('OpenXPKI');
95 $mech->field('additional_info_phone', '1234');
96 $mech->field('keygen', 'IE');
97 $mech->field('pkcs10', $pkcs10);
98 $mech->field('additional_info_comment', 'comment');
99 $mech->field('cert_subject_hostname', 'example4.example.com');
100 $mech->field('cert_subject_port', '1234');
101 $mech->field('subject_style', '00_tls_basic_style');
102 $mech->field('role', 'Web Server');
103 $mech->submit_form(form_name => 'OpenXPKI');
105 like($mech->response->content, qr/I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_RECEIPT_CONFIRMATION_TITLE/, 'CSR received');
106 like($mech->response->content, qr/I18N_OPENXPKI_PROFILE_TLS_SERVER/, 'TLS server profile');
107 like($mech->response->content, qr/CN=example4.example.com:1234,DC=Test\ Deployment,DC=OpenXPKI,DC=org/, 'Certificate subject');