5 ## configure test environment
7 my $base = 't/instance';
10 config_dir
=> "$base/etc/openxpki",
11 var_dir
=> "$base/var/openxpki",
12 config_file
=> "$base/etc/openxpki/config.xml",
13 socket_file
=> "/var/tmp/openxpki-client-test.socket",
22 our $INSTANCE = "$PWD/t/tc1";
23 our $CONFIG = "openxpki.conf";
24 our $OUTPUT = "t/html_output";
26 $INSTANCE = $ENV{INSTANCE
} if (exists $ENV{INSTANCE
});
28 $ENV{DOCUMENT_ROOT
} = "$PWD/htdocs"; ## comp_path
29 $ENV{OPENXPKI_SOCKET_FILE
} = "$PWD/t/tc1/var/openxpki/openxpki.socket";
31 ## this is for the caching itself
34 $XML::Simple
::PREFERRED_PARSER
= "XML::Parser";
36 our $XS = XML
::Simple
->new (ForceArray
=> 1,
38 SuppressEmpty
=> undef,
45 my $path = $keys->{PATH
};
46 my $page = $keys->{PAGE
};
48 my @list = split "\/", $path;
50 foreach my $item (@list)
52 push @path, [ split ":", $item ];
55 foreach my $item (@path)
57 return $count if (not exists $page->{$item->[0]});
58 $page = $page->{$item->[0]};
59 if (defined $item->[1])
61 return -$count if (not exists $page->[$item->[1]]);
62 $page = $page->[$item->[1]];
66 if (exists $keys->{VALUE
})
68 return $count if (ref $page);
69 return -$count if ($keys->{VALUE
} ne $page);
71 if (exists $keys->{REGEX
})
73 return $count if (ref $page);
74 return -$count if ($page !~ /^.*$keys->{REGEX}.*$/);
82 return 1 if (not exists $page->{html
}->[0]->{body
}->[0]->{div
}->[0]->{div
}->[1]->{form
}->[0]->{input
}->[0]);
83 $page = $page->{html
}->[0]->{body
}->[0]->{div
}->[0]->{div
}->[1]->{form
}->[0]->{input
}->[0];
84 return 2 if ($page->{type
} ne "hidden");
85 return 3 if ($page->{name
} ne "__session_id");
86 return 4 if (length $page->{value
} < 16);
93 return undef if (0 != check_session_id
($page));
94 return $page->{html
}->[0]->{body
}->[0]->{div
}->[0]->{div
}->[1]->{form
}->[0]->{input
}->[0]->{value
};
101 print STDERR Dumper
($page);
107 my $filename = $keys->{FILENAME
};
108 my $data = $keys->{DATA
};
110 ## strip off http header
111 $data =~ s/^.*\r\n\r\n//s;
113 return 1 if (not open FD
, ">$OUTPUT/$filename");
114 return 2 if (not print FD
$data);
115 return 3 if (not close FD
);
121 my $filename = shift;
122 return $XS->XMLin ("$OUTPUT/$filename");