Apache-SWIT

 view release on metacpan or  search on metacpan

t/530_subsystem.t  view on Meta::CPAN

my $mf = read_file('Makefile');
like(read_file('blib/conf/startup.pl'), qr/touch/) or ASTU_Wait($mf . $res);
ok(-f 'touched');

ok(-f 't/dual/001_load.t');

append_file('t/dual/001_load.t', <<ENDS);
# \$t->ok_ht_userlist_r(make_url => 1, ht => {
# 		user_list => [ { ht_id => 1, name => 'admin' } ] });
# \$t->ok_ht_userform_r(make_url => 1, ht => {
#		                        username => '', password => '', });
# HT_SEALED_ht_id => '1', name => 'admin', _role_name => 'admin'
ENDS

my $m_str2 = read_file('MANIFEST');
is($m_str2, $m_str);

$res = `make`;
is($?, 0) or ASTU_Wait;

$res = $mt->run_make_install;

t/T/HTError.pm  view on Meta::CPAN

}

package T::HTError;
use base 'Apache::SWIT::HTPage';
use HTML::Tested qw(HTV);
use HTML::Tested::Value::PasswordBox;

sub swit_startup {
	my $rc = shift()->ht_make_root_class;
	$rc->ht_add_widget(HTV."::EditBox", 'name');
	$rc->ht_add_widget(HTV."::PasswordBox", 'password');
	$rc->ht_add_widget(HTV, 'error');
	$rc->ht_add_widget(::HTV."::Form", form => default_value => 'u');
}

sub ht_swit_render {
	my ($class, $r, $root) = @_;
	$root->name("buh");
	return $root;
}

sub ht_swit_validate_die {
	my ($class, $errs, $r, $root) = @_;
	my $res = $root->name eq 'foo' ? "r?error=validate"
			: "r?error=validie&error_uri=" . $r->uri;
	return ($res, 'password');
}

sub ht_swit_update_die {
	my ($class, $msg, $r, $root) = @_;
	return $class->SUPER::swit_die(@_) unless $msg =~ /Hoho/;
	return ("r?error=updateho", "password");
}

sub ht_swit_update {
	my ($class, $r, $root) = @_;
	return [ Apache2::Const::FORBIDDEN() ] if $root->name eq 'FORBID';
	return $class->swit_failure('r?error=failure', 'password')
		if $root->name eq 'fail';
	die "Hoho";
	return "r";
}

1;

t/apache/090_redirect.t  view on Meta::CPAN

like($t->mech->uri, qr#/test/redirect/r#);
like($t->mech->content, qr/hello world/);

$t->redirect_r(make_url => 1, param => { internal => "../cthan" });
is($t->mech->ct, "text/plain");
is($t->mech->status, 200);

T::Test->make_aliases(ht_error => 'T::HTError', another_page => 'T::HTPage');

$t->ok_ht_ht_error_r(make_url => 1, ht => { name => "buh", error => ""
		, password => "" });
$t->ht_ht_error_u(ht => { name => "foo", password => "boo" });

# we should not see password going back. Even if its incorrect.
$t->ok_ht_ht_error_r(ht => { name => "foo", password => ""
		, error => "validate" }) or ASTU_Wait;

$t->ht_ht_error_u(ht => { name => "swid", password => "hru" });
$t->ok_ht_ht_error_r(ht => { name => "swid", error => "updateho"
		, password => "" });

$t->ht_ht_error_u(ht => { name => "bad", password => "hru" });
$t->ok_ht_ht_error_r(ht => { name => "bad", error => "validie"
		, password => "" });

$t->ht_ht_error_u(ht => { name => "fail", password => "hru" });
$t->ok_ht_ht_error_r(ht => { name => "fail", error => "failure"
		, password => "" });

$ENV{SWIT_HAS_APACHE} = 0;
$t = T::Test->new({ session_class => 'Apache::SWIT::Session' });
is($t->redirect_request, undef);

$t->ht_ht_error_u(ht => { name => "bad", password => "hru" });
isnt($t->redirect_request, undef);
is($t->redirect_request->param("error"), "validie");
is($t->redirect_request->param("error_uri"), "/test/ht_error/u");

$t->ok_ht_ht_error_r(ht => { name => "bad", error => "validie"
		, password => "" });
is($t->redirect_request, undef);

$t->ht_ht_error_u(ht => { name => "FORBID", password => "hru" });
isnt($t->redirect_request, undef);

$t->ok_follow_link(text => 'doesnt matter');
is($t->redirect_request, undef);

$t->ht_ht_error_u(ht => { name => "FORBID", password => "hru" });
isnt($t->redirect_request, undef);

$t->ok_get('www/hello.html', 200);
is($t->redirect_request, undef);

$t->ht_ht_error_u(ht => { name => "bad", password => "hru" });
$t->ok_ht_ht_error_r(make_url => 1, ht => { name => "buh", error => ""
		, password => "" });

$t->redirect_u(fields => { v1 => 'space' });
$t->ok_ht_another_page_r(ht => { v1 => '' });

t/templates/ht_error.tt  view on Meta::CPAN

<html>
<body>
[% form %]
[% name %]
[% password %]
[% error %]
<input type="submit" />
</form>
</body>
</html>



( run in 0.523 second using v1.01-cache-2.11-cpan-49f99fa48dc )