File: apache.t

package info (click to toggle)
libcgi-untaint-perl 1.26-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 112 kB
  • ctags: 21
  • sloc: perl: 302; makefile: 6
file content (45 lines) | stat: -rw-r--r-- 947 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl -w

use strict;
use CGI;
use CGI::Untaint;

use Test::More tests => 20;

my $data = {
	name => "Tony Bowden",
	age  => 110,
};

package My::Apache::Table;
sub new   { bless $data, shift }
sub name  { shift->{name} }
sub age   { shift->{name} }
sub parms { shift; }

package main;

my %type = (
  name => 'printable',
  age  => 'integer',
);

{
  my $apr = My::Apache::Table->new();
	my %h = (
		args   => CGI::Untaint->new( {}, $apr ),
		noargs => CGI::Untaint->new( $apr ),
	);
	for my $type (sort keys %h) {
		ok my $h = $h{$type}, "*** handler for $type ***";
		isa_ok $h, "CGI::Untaint";
		foreach (keys %type) {
			ok my $res = $h->extract("-as_$type{$_}" => $_), "$type: Extract $_";
			is $res,  $data->{$_}, "$type:  - Correct value";
			is $h->error, '', "$type: No error";
		}
		my $foo = $h->extract(-as_printable => 'foo');
		ok !$foo, "$type: No Foo";
		is $h->error, "No parameter for 'foo'", "$type: No error";
	}
}