Documented the heretofore undocumented Deactivate Account Template in the Auth modules.

Broke out code scanning tests into their own tests, and required the CODE_COP environment
variable be set before they were run.
Fixed two bugs in the Workflow test, wrong number of tests and inverse test logic.
More Auth template inheritance work.  Almost time to reflect it over to
the LDAP module.
This commit is contained in:
Colin Kuskie 2006-11-24 21:05:44 +00:00
parent 860a71bc5d
commit ee9cae98a8
11 changed files with 385 additions and 201 deletions

View file

@ -3,6 +3,10 @@
from the system, but you do not have to be in the Template Managers group
to edit or add Templates. Those privileges have been transferred to the
Turn On Admin group.
- TESTS: The help labels were broken out from the i18n/label.t test into their own
test. An environment variable, CODE_COP, is used to enable the long
i18n/label.t and help/setHelp.t tests.
- documented the Deactivate Account Template.
7.2.3
- fix: minor bug with new template vars in Auth::createAccount

View file

@ -7,6 +7,13 @@ upgrading from one version to the next, or even between multiple
versions. Be sure to heed the warnings contained herein as they will
save you many hours of grief.
7.3.0
--------------------------------------------------------------------
* The i18n/label.t and help/setHelp.t test now require that you set
an environment variable, CODE_COP to run them. This should make
running the entire test suite prior to SVN commits easier to do
since it won't take so long.
7.2.0
--------------------------------------------------------------------
* NOTE: if you tried to upgrade to 7.2.0 and it failed during the

View file

@ -313,7 +313,7 @@ sub deactivateAccount {
#-------------------------------------------------------------------
=head2 deactivateAccount ( method )
=head2 deactivateAccountConfirm ( method )
Superclass method that performs general functionality for deactivating accounts.

View file

@ -35,6 +35,52 @@ our $HELP = {
related => [
]
},
'login template' => {
title => 'login template title',
body => 'login template body',
isa => [
{
namespace => "Asset_Template",
tag => "template variables"
},
],
variables => [
{
'name' => 'title'
},
{
'name' => 'login.form.header'
},
{
'name' => 'login.form.hidden'
},
{
'name' => 'login.form.username'
},
{
'name' => 'login.form.username.label'
},
{
'name' => 'login.form.password'
},
{
'name' => 'login.form.password.label'
},
{
'name' => 'anonymousRegistration.isAllowed'
},
{
'name' => 'createAccount.url'
},
{
'name' => 'createAccount.label'
},
],
fields => [
],
related => [
]
},
'anonymous registration template' => {
title => 'anon reg template title',
body => 'anon reg template body',
@ -92,6 +138,40 @@ our $HELP = {
related => [
]
},
'deactivate account template' => {
title => 'deactivate account template title',
body => 'deactivate account template body',
isa => [
{
namespace => "Asset_Template",
tag => "template variables"
},
],
variables => [
{
'name' => 'title'
},
{
'name' => 'question'
},
{
'name' => 'yes.label'
},
{
'name' => 'yes.url'
},
{
'name' => 'no.label'
},
{
'name' => 'no.url'
},
],
fields => [
],
related => [
]
},
};
1;

View file

@ -14,6 +14,9 @@ our $HELP = {
{
'name' => 'account.message'
},
{
'name' => 'account.noform'
},
{
'name' => 'account.form.username'
},
@ -32,9 +35,6 @@ our $HELP = {
{
'name' => 'account.form.passwordConfirm.label'
},
{
'name' => 'account.noform'
},
{
'name' => 'account.nofields'
}
@ -47,46 +47,16 @@ our $HELP = {
'webgui authentication login template' => {
title => 'login template title',
body => 'login template body',
isa => [
{
namespace => "Auth",
tag => "login template"
},
],
variables => [
{
'name' => 'login.form.header'
},
{
'name' => 'login.form.hidden'
},
{
'name' => 'login.form.footer'
},
{
'name' => 'login.form.submit'
},
{
'name' => 'login.form.username'
},
{
'name' => 'login.form.username.label'
},
{
'name' => 'login.form.password'
},
{
'name' => 'login.form.password.label'
},
{
'name' => 'title'
},
{
'name' => 'login.message'
},
{
'name' => 'anonymousRegistration.isAllowed'
},
{
'name' => 'createAccount.url'
},
{
'name' => 'createAccount.label'
},
{
'name' => 'recoverPassword.isAllowed'
},
@ -258,6 +228,19 @@ our $HELP = {
}
]
},
'webgui deactivate account template' => {
title => 'deactivate account template title',
body => 'deactivate account template body',
isa => [
{
namespace => "Auth",
tag => "deactivate account template"
},
],
variables => [ ],
fields => [ ],
related => [ ],
},
};
1;

View file

@ -119,6 +119,110 @@ our $I18N = {
lastUpdated => 1149220575,
},
'login template title' => {
message => q|Authentication Login Template|,
lastUpdated => 1164394401
},
'login template body' => {
message => q|<p>The following template variables are available for all Authentication Login templates.
</p>
|,
lastUpdated => 1164394398
},
'login.form.header' => {
message => q|The required form elements that go at the top of the login page.|,
lastUpdated => 1149220294,
},
'login.form.hidden' => {
message => q|Hidden form fields required for form submission|,
lastUpdated => 1149220294,
},
'login.form.footer' => {
message => q|The required form elements that go after the login page form.|,
lastUpdated => 1149220294,
},
'login.form.submit' => {
message => q|The default submit button for the login form.|,
lastUpdated => 1149220294,
},
'login.form.username' => {
message => q|Default username form field|,
lastUpdated => 1149220294,
},
'login.form.username.label' => {
message => q|Default text for username form field|,
lastUpdated => 1149220294,
},
'login.form.password' => {
message => q|Default password form field|,
lastUpdated => 1149220294,
},
'login.form.password.label' => {
message => q|Default text for password form field|,
lastUpdated => 1149220294,
},
'anonymousRegistration.isAllowed' => {
message => q|Flag indicating whether or not anonymous registrations are allowed.|,
lastUpdated => 1149220294,
},
'createAccount.url' => {
message => q|URL for the anonymous registration page|,
lastUpdated => 1149220294,
},
'createAccount.label' => {
message => q|Default label for the anonymous registration link.|,
lastUpdated => 1149220294,
},
'deactivate account template title' => {
message => q|Authentication Deactivate Account Template|,
lastUpdated => 1164394401
},
'deactivate account template body' => {
message => q|<p>The following template variables are available for all Authentication Deactivate account templates.
</p>
|,
lastUpdated => 1164394398
},
'yes.label' => {
message => q|Internationalized label for "Yes".|,
lastUpdated => 1149220294,
},
'no.label' => {
message => q|Internationalized label for "No".|,
lastUpdated => 1149220294,
},
'yes.url' => {
message => q|URL to deactivate the user's account.|,
lastUpdated => 1149220294,
},
'no.url' => {
message => q|URL to leave the user's account alone|,
lastUpdated => 1149220294,
},
'question' => {
message => q|URL to leave the user's account alone|,
lastUpdated => 1149220294,
},
'topicName' => {
message => q|Authentication|,
lastUpdated => 1164338173,

View file

@ -111,51 +111,11 @@ our $I18N = {
lastUpdated => 1071507721
},
'login.form.header' => {
message => q|The required form elements that go at the top of the login page.|,
lastUpdated => 1149220294,
},
'login.form.hidden' => {
message => q|Hidden form fields required for form submission|,
lastUpdated => 1149220294,
},
'title' => {
message => q|Default page title.|,
lastUpdated => 1164335682,
},
'login.form.footer' => {
message => q|The required form elements that go after the login page form.|,
lastUpdated => 1149220294,
},
'login.form.submit' => {
message => q|The default submit button for the login form.|,
lastUpdated => 1149220294,
},
'login.form.username' => {
message => q|Default username form field|,
lastUpdated => 1149220294,
},
'login.form.username.label' => {
message => q|Default text for username form field|,
lastUpdated => 1149220294,
},
'login.form.password' => {
message => q|Default password form field|,
lastUpdated => 1149220294,
},
'login.form.password.label' => {
message => q|Default text for password form field|,
lastUpdated => 1149220294,
},
'login.message' => {
message => q|Any message returned by the system. Usually displays after the form is submitted.|,
lastUpdated => 1149220294,
@ -506,6 +466,18 @@ our $I18N = {
lastUpdated => 1071507752
},
'deactivate account template title' => {
message => q|WebGUI Authentication Deactivate Account Template|,
lastUpdated => 1164394401
},
'deactivate account template body' => {
message => q|<p>The following template variables are available for the WebGUI Authentication Deactivate account templates.
</p>
|,
lastUpdated => 1164394398
},
'topicName' => {
message => q|WebGUI Authentication|,
lastUpdated => 1128919828,

View file

@ -25,6 +25,7 @@ use File::Find;
use Test::More; # increment this value for each test you create
my $numTests = 0;
plan skip_all => 'set CODE_COP to enable this test' unless $ENV{CODE_COP};
my $session = WebGUI::Test->session;
my $lib = WebGUI::Test->lib;

View file

@ -15,7 +15,7 @@ use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Workflow;
use WebGUI::Utility qw/isIn/;
use Test::More tests => 0; # increment this value for each test you create
use Test::More tests => 16; # increment this value for each test you create
my $session = WebGUI::Test->session;
my $wf = WebGUI::Workflow->create($session, {title => 'Title', description => 'Description',
@ -40,8 +40,9 @@ ok(!isIn($wfId, keys %{WebGUI::Workflow->getList($session)}), 'workflow not in e
$wf->set({enabled => 1});
ok($wf->get('enabled'), 'workflow is enabled');
ok(isIn($wfId, keys %{WebGUI::Workflow->getList($session)}), 'workflow in enabled list');
$session->errorHandler->warn('Interesting');
$wf->set({enabled => 0});
ok($wf->get('enabled'), 'workflow is disabled again');
ok(!$wf->get('enabled'), 'workflow is disabled again');
$wf->delete;
ok(!defined WebGUI::Workflow->new($session, $wfId), 'deleted workflow cannot be retrieved');

149
t/i18n/help.t Normal file
View file

@ -0,0 +1,149 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use warnings;
use lib "$FindBin::Bin/../lib"; ##t/lib
use WebGUI::Test;
use WebGUI::Operation::Help;
use WebGUI::International;
use WebGUI::Session;
use Text::Balanced qw(extract_codeblock);
use File::Find;
use Data::Dumper;
#The goal of this test is to verify all the i18n labels in
#the help files. It used to be glommed into the same test as
#the code scanner, but was broken out due to speed issues.
use Test::More; # increment this value for each test you create
my $numTests = 0;
my $session = WebGUI::Test->session;
my $lib = WebGUI::Test->lib;
# put your tests here
my %helpTable;
my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session);
foreach my $helpSet (@helpFileSet) {
my $helpName = $helpSet->[1];
my $help = WebGUI::Operation::Help::_load($session, $helpName);
$helpTable{ $helpName } = $help;
}
##Scan #1, find all labels in the help system. body, title, @fields
## Array of hashes
## each hash will have:
## topic -> which help file it is from
## entry -> which entry in the help file
## tag -> which tag in the entry in the help file
## namespace -> which help file it is form
## label -> which help file it is form
my @helpLabels;
my @sqlLabels;
my @libLabels;
my @objLabels;
@helpLabels = getHelpLabels();
$numTests = scalar(@helpLabels);
plan tests => $numTests;
my $i18n = WebGUI::International->new($session);
foreach my $label ( @helpLabels ) {
ok($i18n->get(@{ $label }{qw(label namespace )} ),
sprintf "label: %s->%s inside %s->%s->%s", @{ $label }{'namespace', 'label', 'topic', 'entry', 'tag', });
}
sub getHelpLabels {
my @helpLabels = ();
foreach my $topic ( keys %helpTable ) {
foreach my $entry ( keys %{ $helpTable{$topic} }) {
##Check the title and body data
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'title',
namespace=>$topic, ##default
label=>$helpTable{$topic}{$entry}{'title'},
};
if (ref $helpTable{$topic}{$entry}{'body'} ne 'CODE') {
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'body',
namespace=>$topic, ##default
label=>$helpTable{$topic}{$entry}{'body'},
};
}
##Add all labels in the fields array
foreach my $field (@{ $helpTable{$topic}{$entry}{fields} }) {
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'fields',
namespace=>$field->{namespace},
label=>$field->{title},
},
{
topic=>$topic,
entry=>$entry,
tag=>'fields',
namespace=>$field->{namespace},
label=>$field->{description},
},;
}
my $variableEntries = getHelpVariables($helpTable{$topic}{$entry}{variables});
foreach my $variable ( @{ $variableEntries } ) {
my $namespace = exists $variable->{namespace} ? $variable->{namespace} : $topic;
my $one = {
topic=>$topic,
entry=>$entry,
tag=>'variables',
namespace=>$namespace,
};
if ($variable->{description}) {
$one->{label} = $variable->{description},
}
else {
$one->{label} = $variable->{name},
}
push @helpLabels, $one;
}
}
}
return @helpLabels;
}
sub getHelpVariables {
my ($variables) = @_; ##An arrayref of variables, possibly with nested variables in loops
my $tmplVars = [];
foreach my $var ( @{ $variables } ) {
if ( exists $var->{variables} ) {
push @{ $tmplVars }, @{ getHelpVariables($var->{variables}) };
delete $var->{variables};
}
push @{ $tmplVars }, $var;
}
return $tmplVars;
}

View file

@ -26,6 +26,7 @@ use Data::Dumper;
use Test::More; # increment this value for each test you create
my $numTests = 0;
plan skip_all => 'set CODE_COP to enable this test' unless $ENV{CODE_COP};
my $session = WebGUI::Test->session;
my $lib = WebGUI::Test->lib;
@ -65,23 +66,14 @@ foreach my $helpSet (@helpFileSet) {
## namespace -> which help file it is form
## label -> which help file it is form
my @helpLabels;
my @sqlLabels;
my @libLabels;
my @objLabels;
@helpLabels = getHelpLabels();
#@sqlLabels = getSQLLabels();
find(\&label_finder_pm, $lib);
find(\&obj_finder_pm, $lib);
$numTests = scalar(@helpLabels)
# + scalar(@sqlLabels)
+ scalar(@libLabels)
$numTests = scalar(@libLabels)
+ scalar(@objLabels)
;
@ -89,19 +81,6 @@ plan tests => $numTests;
my $i18n = WebGUI::International->new($session);
foreach my $label ( @helpLabels ) {
ok($i18n->get(@{ $label }{qw(label namespace )} ),
sprintf "label: %s->%s inside %s->%s->%s", @{ $label }{'namespace', 'label', 'topic', 'entry', 'tag', });
}
#
#foreach my $label ( @sqlLabels ) {
# ok($i18n->get(@{ $label }{qw(label namespace )} ),
# sprintf "label: %s->%s inside %s", @{ $label }{'namespace', 'label', 'file', });
#}
#
##Subroutine calls are now illegal, everything must be done by object methods.
foreach my $label ( @libLabels ) {
ok(0,
sprintf "label: %s->%s inside %s", @{ $label }{'namespace', 'label', 'file', });
@ -164,100 +143,4 @@ sub obj_finder_pm {
}
}
sub getHelpLabels {
my @helpLabels = ();
foreach my $topic ( keys %helpTable ) {
foreach my $entry ( keys %{ $helpTable{$topic} }) {
##Check the title and body data
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'title',
namespace=>$topic, ##default
label=>$helpTable{$topic}{$entry}{'title'},
};
if (ref $helpTable{$topic}{$entry}{'body'} ne 'CODE') {
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'body',
namespace=>$topic, ##default
label=>$helpTable{$topic}{$entry}{'body'},
};
}
##Add all labels in the fields array
foreach my $field (@{ $helpTable{$topic}{$entry}{fields} }) {
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'fields',
namespace=>$field->{namespace},
label=>$field->{title},
},
{
topic=>$topic,
entry=>$entry,
tag=>'fields',
namespace=>$field->{namespace},
label=>$field->{description},
},;
}
my $variableEntries = getHelpVariables($helpTable{$topic}{$entry}{variables});
foreach my $variable ( @{ $variableEntries } ) {
my $namespace = exists $variable->{namespace} ? $variable->{namespace} : $topic;
my $one = {
topic=>$topic,
entry=>$entry,
tag=>'variables',
namespace=>$namespace,
};
if ($variable->{description}) {
$one->{label} = $variable->{description},
}
else {
$one->{label} = $variable->{name},
}
push @helpLabels, $one;
}
}
}
return @helpLabels;
}
sub getHelpVariables {
my ($variables) = @_; ##An arrayref of variables, possibly with nested variables in loops
my $tmplVars = [];
foreach my $var ( @{ $variables } ) {
if ( exists $var->{variables} ) {
push @{ $tmplVars }, @{ getHelpVariables($var->{variables}) };
delete $var->{variables};
}
push @{ $tmplVars }, $var;
}
return $tmplVars;
}
sub getSQLLabels {
my @sqlLabels = ();
foreach my $file (qw/create.sql previousVersion.sql/) {
my $file2 = join '/', '../..', 'docs', $file;
open my $fh, $file2 or
die "Unable to open $file2: $!\n";
local $/;
my $sql = <$fh>;
while ($sql =~ /WebGUI::International::get\(([^\)]+)\)/gs) {
my $args;
($args = $1) =~ tr{\\"}{}d;
my ($label,$namespace) = split ',', $args;
$namespace = "WebGUI" unless $namespace;
push @sqlLabels, {
label => $label,
namespace => $namespace,
file => $file,
};
}
close $fh;
}
return @sqlLabels;
}