Merge commit 'v7.10.23' into WebGUI8. Tests need fixing.
This commit is contained in:
commit
a2a821822d
72 changed files with 578 additions and 132 deletions
|
|
@ -1,5 +1,20 @@
|
|||
7.10.23
|
||||
- fixed #12225: Stock asset, multiple instances on a page
|
||||
- fixed #12229: Indexed thingy data has gateway url prepended to it
|
||||
- fixed #12195: Visitor group by scratch membership shared among all Visitors (Dale Trexel)
|
||||
- fixed #12227: Corrected AssetReport such that OrderBy works correctly.
|
||||
- fixed #12238: Old template attachement in search template slows down sites
|
||||
- fixed #12239: Still get cart error message after removing extra recurring items from the cart
|
||||
- fixed #12240: Empty Extend Calendar Recurrance version tags
|
||||
- fixed #12241: Account Shop
|
||||
- fixed #12246: Layout inherits mobileStyleTemplateId and mobileTemplateId from parent Layouts
|
||||
- fixed #12246: added extra_www_add_properties as properties fix-up hook in child for www_add
|
||||
- fixed #12231: Thingy reindex fails on upgrade
|
||||
- fixed #12245: Encrypt Login and Display Message on Login conflict
|
||||
- fixed #12211: Recurring Item error message in Cart
|
||||
|
||||
7.10.22
|
||||
- rfe #12223: Add dateTime type to content profiling (metadata)
|
||||
- rfe #12223: Add date type to content profiling (metadata)
|
||||
- rfe #12207: Thingy. Field_name info returned by www_editThingDataSaveViaAjax
|
||||
- fixed #12206: Bad Subscription Groups in Duplicated Threads
|
||||
- fixed #12208: replacements don't work
|
||||
|
|
|
|||
|
|
@ -31,6 +31,12 @@ save you many hours of grief.
|
|||
Account Macro template
|
||||
Admin Toggle Macro template
|
||||
|
||||
7.10.23
|
||||
--------------------------------------------------------------------
|
||||
* The default_search2 template had a bad template attachment pointing to
|
||||
an old WebGUI CSS Snippet called /webgui.css. Any attachment with that
|
||||
URL will be removed from ALL templates in the Search namespace.
|
||||
|
||||
7.10.21
|
||||
--------------------------------------------------------------------
|
||||
* WebGUI now depends on Kwargs.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# WebGUI Legal Information #
|
||||
####################################################################
|
||||
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation. All rights
|
||||
WebGUI is Copyright 2001-2011 Plain Black Corporation. All rights
|
||||
reserved.
|
||||
|
||||
WebGUI Content Engine, WebGUI Runtime Environment, and Plain Black
|
||||
|
|
|
|||
Binary file not shown.
BIN
docs/upgrades/packages-7.10.23/stockdatatmpl000000001.wgpkg
Normal file
BIN
docs/upgrades/packages-7.10.23/stockdatatmpl000000001.wgpkg
Normal file
Binary file not shown.
141
docs/upgrades/upgrade_7.10.22-7.10.23.pl
Normal file
141
docs/upgrades/upgrade_7.10.22-7.10.23.pl
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
our ($webguiRoot);
|
||||
|
||||
BEGIN {
|
||||
$webguiRoot = "../..";
|
||||
unshift (@INC, $webguiRoot."/lib");
|
||||
}
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
|
||||
|
||||
my $toVersion = '7.10.23';
|
||||
my $quiet; # this line required
|
||||
|
||||
|
||||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
fixBadTemplateAttachments($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
#sub exampleFunction {
|
||||
# my $session = shift;
|
||||
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
|
||||
# # and here's our code
|
||||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub fixBadTemplateAttachments {
|
||||
my $session = shift;
|
||||
print "\tRemove template attachements in search templates that refer to an old, deleted CSS snippet... " unless $quiet;
|
||||
# and here's our code
|
||||
use WebGUI::Asset::Template;
|
||||
my $get_template = WebGUI::Asset::Template->getIsa($session);
|
||||
TEMPLATE: while (1) {
|
||||
my $template = eval {$get_template->()};
|
||||
next TEMPLATE if Exception::Class->caught;
|
||||
last TEMPLATE unless $template;
|
||||
next TEMPLATE unless $template->get('namespace') eq 'Search';
|
||||
$template->removeAttachments(['^/(webgui.css);']);
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add a package to the import node
|
||||
sub addPackage {
|
||||
my $session = shift;
|
||||
my $file = shift;
|
||||
|
||||
print "\tUpgrading package $file\n" unless $quiet;
|
||||
# Make a storage location for the package
|
||||
my $storage = WebGUI::Storage->createTemp( $session );
|
||||
$storage->addFileFromFilesystem( $file );
|
||||
|
||||
# Import the package into the import node
|
||||
my $package = eval {
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
$node->importPackage( $storage, {
|
||||
overwriteLatest => 1,
|
||||
clearPackageFlag => 1,
|
||||
setDefaultTemplate => 1,
|
||||
} );
|
||||
};
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub start {
|
||||
my $configFile;
|
||||
$|=1; #disable output buffering
|
||||
GetOptions(
|
||||
'configFile=s'=>\$configFile,
|
||||
'quiet'=>\$quiet
|
||||
);
|
||||
my $session = WebGUI::Session->open($webguiRoot,$configFile);
|
||||
$session->user({userId=>3});
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Upgrade to ".$toVersion});
|
||||
return $session;
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub finish {
|
||||
my $session = shift;
|
||||
updateTemplates($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->commit;
|
||||
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".time().")");
|
||||
$session->close();
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub updateTemplates {
|
||||
my $session = shift;
|
||||
return undef unless (-d "packages-".$toVersion);
|
||||
print "\tUpdating packages.\n" unless ($quiet);
|
||||
opendir(DIR,"packages-".$toVersion);
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my $newFolder = undef;
|
||||
foreach my $file (@files) {
|
||||
next unless ($file =~ /\.wgpkg$/);
|
||||
# Fix the filename to include a path
|
||||
$file = "packages-" . $toVersion . "/" . $file;
|
||||
addPackage( $session, $file );
|
||||
}
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
@ -872,6 +872,7 @@
|
|||
"r" : "r_printable",
|
||||
"Spacer" : "Spacer",
|
||||
"SpectreCheck" : "SpectreCheck",
|
||||
"TwitterLogin" : "TwitterLogin",
|
||||
"Thumbnail" : "Thumbnail",
|
||||
"TwitterLogin" : "TwitterLogin",
|
||||
"User" : "User",
|
||||
|
|
|
|||
|
|
@ -1427,6 +1427,28 @@ sub getImportNode {
|
|||
return WebGUI::Asset->newById($session, "PBasset000000000000002");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getInheritableProperties ( )
|
||||
|
||||
Returns a hash (list) of properties that should be inherited from a parent when creating an asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub getInheritableProperties {
|
||||
my $self = shift;
|
||||
return (
|
||||
parentId => $self->getId,
|
||||
groupIdView => $self->get("groupIdView"),
|
||||
groupIdEdit => $self->get("groupIdEdit"),
|
||||
ownerUserId => $self->get("ownerUserId"),
|
||||
encryptPage => $self->get("encryptPage"),
|
||||
styleTemplateId => $self->get("styleTemplateId"),
|
||||
printableStyleTemplateId => $self->get("printableStyleTemplateId"),
|
||||
isHidden => $self->get("isHidden"),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -2749,15 +2771,8 @@ sub www_add {
|
|||
}
|
||||
my %properties = (
|
||||
%prototypeProperties,
|
||||
parentId => $self->getId,
|
||||
groupIdView => $self->get("groupIdView"),
|
||||
groupIdEdit => $self->get("groupIdEdit"),
|
||||
ownerUserId => $self->get("ownerUserId"),
|
||||
encryptPage => $self->get("encryptPage"),
|
||||
styleTemplateId => $self->get("styleTemplateId"),
|
||||
printableStyleTemplateId => $self->get("printableStyleTemplateId"),
|
||||
isHidden => $self->get("isHidden"),
|
||||
className=>$class,
|
||||
$self->getInheritableProperties,
|
||||
assetId=>"new",
|
||||
url=>scalar($self->session->form->param("url")),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -637,15 +637,15 @@ sub prepare {
|
|||
|
||||
$style->setRawHeadTags($headBlock);
|
||||
|
||||
my %props = ( type => 'text/css', rel => 'stylesheet' );
|
||||
foreach my $sheet ( @{ $self->getAttachments('stylesheet') } ) {
|
||||
my %props = ( type => 'text/css', rel => 'stylesheet' );
|
||||
$style->setLink($sheet->{url}, \%props);
|
||||
}
|
||||
|
||||
my $doScripts = sub {
|
||||
my ($type, $body) = @_;
|
||||
my %props = ( type => 'text/javascript' );
|
||||
foreach my $script ( @{ $self->getAttachments($type) } ) {
|
||||
my %props = ( type => 'text/javascript' );
|
||||
$style->setScript($script->{url}, \%props, $body);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -226,6 +226,21 @@ sub getCollateral {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getInheritableProperties ( )
|
||||
|
||||
Extend the base class to include the mobileStyleTemplateId.
|
||||
|
||||
=cut
|
||||
|
||||
override getInheritableProperties => sub {
|
||||
my $self = shift;
|
||||
my %properties = super();
|
||||
$properties{mobileStyleTemplateId} = $self->mobileStyleTemplateId;
|
||||
return %properties;
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStyleTemplateId
|
||||
|
|
|
|||
|
|
@ -139,9 +139,8 @@ sub getTemplateVars {
|
|||
$rules->{'whereClause'} .= qq{$prop $op $value};
|
||||
}
|
||||
|
||||
if($rules->{'whereClause'}) {
|
||||
$rules->{'joinClass'} = $settings->{className};
|
||||
}
|
||||
# Always join to the class, asset and assetData are excluded by getLineageSql
|
||||
$rules->{'joinClass'} = $settings->{className};
|
||||
|
||||
#Build the order by condition
|
||||
my $order = $settings->{order};
|
||||
|
|
|
|||
|
|
@ -1383,7 +1383,7 @@ around groupIdView => sub {
|
|||
my $instance_data = {
|
||||
workflowId => 'xR-_GRRbjBojgLsFx3dEMA',
|
||||
className => 'WebGUI::Asset',
|
||||
methodName => 'newById',
|
||||
methodName => 'newPending',
|
||||
parameters => $self->getId,
|
||||
};
|
||||
my $instance = WebGUI::Workflow::Instance->create($self->session, $instance_data);
|
||||
|
|
|
|||
|
|
@ -393,6 +393,21 @@ sub getContentLastModifiedBy {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getInheritableProperties ( )
|
||||
|
||||
Extend the base class to include the mobileTemplateId.
|
||||
|
||||
=cut
|
||||
|
||||
override getInheritableProperties => sub {
|
||||
my $self = shift;
|
||||
my %properties = super();
|
||||
$properties{mobileTemplateId} = $self->mobileTemplateId;
|
||||
return %properties;
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_view
|
||||
|
||||
Extend the base method to handle caching and ad rotation.
|
||||
|
|
@ -437,4 +452,3 @@ override www_view => sub {
|
|||
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -1056,7 +1056,7 @@ sub getFieldValue {
|
|||
# TODO: The otherThing field type is probably also handled by getFormPlugin, so the elsif below can probably be
|
||||
# safely removed. However, this requires more testing than I can provide right now, so for now this stays the
|
||||
# way it was.
|
||||
elsif ($field->{fieldType} =~ m/^otherthing/x) {
|
||||
elsif ($fieldType =~ m/^otherthing/x) {
|
||||
my $otherThingId = $field->{fieldType};
|
||||
$otherThingId =~ s/^otherThing_//x;
|
||||
my $tableName = 'Thingy_'.$otherThingId;
|
||||
|
|
@ -1603,11 +1603,11 @@ sub indexThing {
|
|||
return unless $thing;
|
||||
my $index = WebGUI::Search::Index->new($self);
|
||||
$index->addRecord(
|
||||
url => $self->getUrl($self->getThingUrl($thing)),
|
||||
groupIdView => $thing->{groupIdView},
|
||||
title => $thing->{label},
|
||||
subId => $thing->{thingId},
|
||||
keywords => join(' ', @{$thing}{qw/label editScreenTitle editInstructions searchScreenTitle searchDescription/}),
|
||||
url => $self->session->url->append($self->get('url'), $self->getThingUrl($thing)),
|
||||
);
|
||||
##Easy update of all thingData fields for this thing. This is in lieu of deleting all records
|
||||
##And rebuilding them all.
|
||||
|
|
@ -1679,7 +1679,7 @@ sub indexThingData {
|
|||
|| $self->getTitle;
|
||||
$index->addRecord(
|
||||
assetId => $self->getId,
|
||||
url => $self->getUrl('func=viewThingData;thingId='. $thing->{thingId} . ';thingDataId='. $thingData->{thingDataId}),
|
||||
url => $session->url->append($self->get('url'), 'func=viewThingData;thingId='. $thing->{thingId} . ';thingDataId='. $thingData->{thingDataId}),
|
||||
groupIdView => $thing->{groupIdView},
|
||||
title => $title,
|
||||
subId => $thing->{thingId} . '-' . $thingData->{thingDataId},
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ package WebGUI::Asset;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use Tie::IxHash;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -380,7 +379,7 @@ sub www_editMetaDataField {
|
|||
label=>$i18n->get(486),
|
||||
hoverHelp=>$i18n->get('Data Type description'),
|
||||
value=>$fieldInfo->{fieldType} || "text",
|
||||
types=> [ qw /text integer yesNo selectBox radioList checkList dateTime/ ]
|
||||
types=> [ qw /text integer yesNo selectBox radioList checkList date/ ]
|
||||
);
|
||||
|
||||
my $default = ref WebGUI::Asset->assetName eq 'ARRAY'
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use WebGUI::Shop::AddressBook;
|
|||
use WebGUI::Inbox;
|
||||
use WebGUI::Friends;
|
||||
use WebGUI::Deprecate;
|
||||
use URI;
|
||||
|
||||
# Profile field name for the number of times the showMessageOnLogin has been
|
||||
# seen.
|
||||
|
|
@ -1209,13 +1210,7 @@ sub www_login {
|
|||
$u->karma($self->session->setting->get("karmaPerLogin"),"Login","Just for logging in.") if ($self->session->setting->get("useKarma"));
|
||||
$self->_logLogin($uid,"success");
|
||||
|
||||
if ($self->session->setting->get('encryptLogin')) {
|
||||
my $currentUrl = $self->session->url->page(undef,1);
|
||||
$currentUrl =~ s/^https:/http:/;
|
||||
$self->session->response->setRedirect($currentUrl);
|
||||
}
|
||||
|
||||
# Run on login
|
||||
# Run on login
|
||||
my $command = $self->session->config->get("runOnLogin");
|
||||
if ($command ne "") {
|
||||
WebGUI::Macro::process($self->session,\$command);
|
||||
|
|
@ -1223,7 +1218,6 @@ sub www_login {
|
|||
$self->session->log->warn($error) if $error;
|
||||
}
|
||||
|
||||
|
||||
# Set the proper redirect
|
||||
if ( $self->session->setting->get( 'showMessageOnLogin' )
|
||||
&& $self->user->get( $LOGIN_MESSAGE_SEEN )
|
||||
|
|
@ -1242,6 +1236,11 @@ sub www_login {
|
|||
$self->session->response->setRedirect($self->session->setting->get("redirectAfterLoginUrl"));
|
||||
$self->session->scratch->delete("redirectAfterLogin");
|
||||
}
|
||||
elsif ($self->session->setting->get('encryptLogin')) {
|
||||
my $currentUrl = $self->session->url->page(undef,1);
|
||||
$currentUrl =~ s/^https:/http:/;
|
||||
$self->session->response->setRedirect($currentUrl);
|
||||
}
|
||||
|
||||
# Get open version tag. This is needed if we want
|
||||
# to reclaim a version right after login (singlePerUser and siteWide mode)
|
||||
|
|
@ -1308,18 +1307,27 @@ sub www_showMessageOnLogin {
|
|||
|
||||
# Add the link to continue
|
||||
my $session = $self->session;
|
||||
my $redirectUrl = $self->session->form->get( 'returnUrl' )
|
||||
|| $self->session->setting->get("redirectAfterLoginUrl")
|
||||
|| $self->session->scratch->get( 'redirectAfterLogin' )
|
||||
|| $self->session->url->getBackToSiteURL
|
||||
my $redirectUrl = $session->form->get( 'returnUrl' )
|
||||
|| $session->setting->get("redirectAfterLoginUrl")
|
||||
|| $session->scratch->get( 'redirectAfterLogin' )
|
||||
|| $session->url->getBackToSiteURL
|
||||
;
|
||||
|
||||
$output .= '<p><a href="' . $redirectUrl . '">' . $i18n->get( 'showMessageOnLogin return' )
|
||||
. '</a></p>'
|
||||
;
|
||||
|
||||
if ($session->setting->get('encryptLogin') && ( ! $redirectUrl =~ /^http/)) {
|
||||
##A scheme-less URL has been supplied. We need to make it an absolute one
|
||||
##with a non-encrypted scheme. Otherwise the user will stay in SSL mode.
|
||||
##We assume that the user put the gateway URL into their URL.
|
||||
my $uri = URI->new_abs($redirectUrl, $session->url->getSiteURL);
|
||||
$uri->scheme('http');
|
||||
$redirectUrl = $uri->as_string;
|
||||
}
|
||||
|
||||
# No matter what, we won't be redirecting after this
|
||||
$self->session->scratch->delete( 'redirectAfterLogin' );
|
||||
$session->scratch->delete( 'redirectAfterLogin' );
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1115,12 +1115,19 @@ Membership will always be false if no IpFilter has been set
|
|||
|
||||
id of the user to check for membership
|
||||
|
||||
=head3 sessionId
|
||||
|
||||
id of the session to check for user data. If no sessionId is passed in, then the
|
||||
group's session will be used to find one.
|
||||
|
||||
|
||||
=cut
|
||||
|
||||
sub hasIpUser {
|
||||
my $self = shift;
|
||||
my $userId = shift;
|
||||
my $session = $self->session;
|
||||
my $userId = shift;
|
||||
my $userSessionId = shift || $session->getId;
|
||||
|
||||
my $IpFilter = $self->ipFilter();
|
||||
return 0 unless ($IpFilter && $userId);
|
||||
|
|
@ -1128,9 +1135,9 @@ sub hasIpUser {
|
|||
$IpFilter =~ s/\s//g;
|
||||
my @filters = split /;/, $IpFilter;
|
||||
|
||||
my @ips = $session->db->buildArray(
|
||||
q{ select lastIP from userSession where expires > ? and userId = ? }
|
||||
,[ time(), $userId ]
|
||||
my @ips = $session->db->buildArray(
|
||||
q{ select lastIP from userSession where expires > ? and userId = ? and sessionId=?}
|
||||
,[ time(), $userId, $userSessionId, ]
|
||||
);
|
||||
|
||||
foreach my $ip (@ips) {
|
||||
|
|
@ -1231,7 +1238,7 @@ sub hasLDAPUser {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 hasScratchUser ( userId )
|
||||
=head2 hasScratchUser ( userId, [ $sessionId ] )
|
||||
|
||||
Determine if the user passed in is a member of this group via session scratch
|
||||
variable settings and this group's scratchFilter.
|
||||
|
|
@ -1242,12 +1249,18 @@ If no scratchFilter has been set for this group, membership will always be false
|
|||
|
||||
id of the user to check for membership
|
||||
|
||||
=head3 sessionId
|
||||
|
||||
id of the session for the user being checked for membership. If no sessionId is passed in, then the
|
||||
group's session will be used to find one.
|
||||
|
||||
=cut
|
||||
|
||||
sub hasScratchUser {
|
||||
my $self = shift;
|
||||
my $userId = shift;
|
||||
my $session = $self->session;
|
||||
my $userId = shift;
|
||||
my $userSessionId = shift || $self->session;
|
||||
|
||||
my $scratchFilter = $self->scratchFilter();
|
||||
return 0 unless ($scratchFilter && $userId);
|
||||
|
|
@ -1256,7 +1269,7 @@ sub hasScratchUser {
|
|||
my @filters = split /;/, $scratchFilter;
|
||||
|
||||
my @scratchClauses = ();
|
||||
my @scratchPlaceholders = ( $userId, time() );
|
||||
my @scratchPlaceholders = ( $userSessionId, $userId, time() );
|
||||
foreach my $filter (@filters) {
|
||||
my ($name, $value) = split /=/, $filter;
|
||||
push @scratchClauses, "(s.name=? AND s.value=?)";
|
||||
|
|
@ -1270,6 +1283,7 @@ sub hasScratchUser {
|
|||
from
|
||||
userSession u, userSessionScratch s
|
||||
where
|
||||
u.sessionId = ? AND
|
||||
u.sessionId=s.sessionId AND
|
||||
u.userId = ? AND
|
||||
u.expires > ? AND
|
||||
|
|
@ -1297,6 +1311,7 @@ sub hasUser {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $user = shift || WebGUI::User->new($session,3); #Check the admin account if no user is passed in
|
||||
my $uSessionId = $user->session->getId;
|
||||
my $gid = $self->getId;
|
||||
my $db = $session->db;
|
||||
|
||||
|
|
@ -1383,9 +1398,9 @@ sub hasUser {
|
|||
my $groupToCheck = __PACKAGE__->new($session,$groupIdInGroup);
|
||||
### Check the 'has' method for each of the 'other' group methods available for this user
|
||||
### perform checks in a least -> most expensive manner. If we find the user, stow the cache and return true
|
||||
if( $groupToCheck->hasIpUser($uid)
|
||||
if( $groupToCheck->hasIpUser($uid, $uSessionId)
|
||||
|| $groupToCheck->hasKarmaUser($uid)
|
||||
|| $groupToCheck->hasScratchUser($uid)
|
||||
|| $groupToCheck->hasScratchUser($uid, $uSessionId)
|
||||
|| $groupToCheck->hasDatabaseUser($uid)
|
||||
|| $groupToCheck->hasLDAPUser($uid)
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ sub getRequestedUrl {
|
|||
|
||||
=head2 getSiteURL ( )
|
||||
|
||||
Returns a constructed site url. The returned value can be overridden using the setSiteURL function.
|
||||
Returns a constructed site url without the gateway. The returned value can be overridden using the setSiteURL function.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
|||
|
|
@ -819,10 +819,6 @@ sub updateFromForm {
|
|||
$item->update({shippingAddressId => $itemAddressId});
|
||||
}
|
||||
}
|
||||
if ($self->hasMixedItems) {
|
||||
my $i18n = WebGUI::International->new($self->session, "Shop");
|
||||
$self->error($i18n->get('mixed items warning'));
|
||||
}
|
||||
|
||||
my @cartItemIds = $form->process('remove_item', 'checkList');
|
||||
foreach my $cartItemId (@cartItemIds) {
|
||||
|
|
@ -830,6 +826,12 @@ sub updateFromForm {
|
|||
$item->remove if ! Exception::Class->caught();
|
||||
}
|
||||
|
||||
##Remove the items BEFORE we check to see if there are duplicates.
|
||||
if ($self->hasMixedItems) {
|
||||
my $i18n = WebGUI::International->new($self->session, "Shop");
|
||||
$self->error($i18n->get('mixed items warning'));
|
||||
}
|
||||
|
||||
##Visitor cannot have an address book, or set a payment gateway, so skip the rest of this.
|
||||
return 1 if $session->user->isVisitor;
|
||||
|
||||
|
|
@ -1085,6 +1087,10 @@ sub www_view {
|
|||
return $session->style->userStyle($template->process(\%var));
|
||||
}
|
||||
|
||||
if ($self->hasMixedItems) {
|
||||
$self->error($i18n->get('mixed items warning'));
|
||||
}
|
||||
|
||||
my %var = (
|
||||
%{$self->get},
|
||||
formHeader => WebGUI::Form::formHeader($session, { extras => q|id="wgCartId"|, })
|
||||
|
|
@ -1108,7 +1114,6 @@ sub www_view {
|
|||
shippableItemsInCart => $self->requiresShipping,
|
||||
);
|
||||
|
||||
|
||||
# get the shipping address
|
||||
my $address = eval { $self->getShippingAddress };
|
||||
if (my $e = WebGUI::Error->caught("WebGUI::Error::ObjectNotFound") && $self->shippingAddressId) {
|
||||
|
|
|
|||
|
|
@ -981,20 +981,17 @@ sub isInGroup {
|
|||
### Check stow before we check the cache. Stow is in memory and much faster
|
||||
my $stow = $session->stow->get("isInGroup", { noclone => 1 }) || {};
|
||||
return $stow->{$uid}->{$gid} if (exists $stow->{$uid}->{$gid});
|
||||
|
||||
|
||||
### Don't bother checking File Cache if we already have a stow for this group.
|
||||
### We can find what we need there and save ourselves a bunch of time
|
||||
my $cache = undef;
|
||||
my $groupMembers = undef;
|
||||
unless ($stow->{$uid}->{$gid}) {
|
||||
$groupMembers = $session->cache->get("groupMembers".$gid) || {};
|
||||
#If we have this user's membership cached, return what we have stored
|
||||
if (exists $groupMembers->{$uid}) {
|
||||
return $groupMembers->{$uid}->{isMember} if (!$self->isVisitor);
|
||||
return $groupMembers->{$uid}->{$session->getId}->{isMember} #Include the session check for visitors
|
||||
}
|
||||
}
|
||||
|
||||
my $cache = undef;
|
||||
my $groupMembers = $session->cache->get("groupMembers".$gid) || {};
|
||||
#If we have this user's membership cached, return what we have stored
|
||||
if (exists $groupMembers->{$uid}) {
|
||||
return $groupMembers->{$uid}->{isMember} if (!$self->isVisitor);
|
||||
return $groupMembers->{$uid}->{$session->getId}->{isMember} if exists $groupMembers->{$uid}->{$session->getId}; #Include the session check for visitors
|
||||
}
|
||||
|
||||
### Instantiate the group
|
||||
my $group = WebGUI::Group->new($session,$gid);
|
||||
if ( !$group ) {
|
||||
|
|
@ -1004,7 +1001,7 @@ sub isInGroup {
|
|||
|
||||
#Check the group for membership
|
||||
my $isInGroup = $group->hasUser($self);
|
||||
|
||||
|
||||
#Write what we found to file cache
|
||||
$group->cacheGroupings( $self, $isInGroup, $groupMembers );
|
||||
return $isInGroup;
|
||||
|
|
|
|||
|
|
@ -194,7 +194,13 @@ sub processRecurrence {
|
|||
$event->generateRecurrence($d);
|
||||
}
|
||||
|
||||
$versionTag->commit;
|
||||
##If nothing needed to happen, then don't keep the tag around.
|
||||
if ($versionTag->getAssetCount > 0) {
|
||||
$versionTag->commit;
|
||||
}
|
||||
else {
|
||||
$versionTag->rollback;
|
||||
}
|
||||
return $time_limit ? 1 : 0;
|
||||
} ## end sub processRecurrence
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ sub execute {
|
|||
if ($versionTag->getAssetCount) {
|
||||
# if there's only one asset in the tag, we might as well give them a direct link to it
|
||||
my $asset = $versionTag->getAssets->[0];
|
||||
$urlOfSingleAsset = "\n\n".$self->session->url->getSiteURL().$asset->getUrl("func=view;revision=".$asset->get("revisionDate"));
|
||||
$urlOfSingleAsset = $self->session->url->getSiteURL().$asset->getUrl("func=view;revision=".$asset->get("revisionDate"));
|
||||
}
|
||||
my $var = {
|
||||
message => $self->get('message'),
|
||||
|
|
|
|||
|
|
@ -99,6 +99,12 @@ our $I18N = {
|
|||
lastUpdated => 1230844137,
|
||||
},
|
||||
|
||||
'Return to Account' => {
|
||||
message => q{Return to Account},
|
||||
context => q{label for templates that want to provide a link back to the main account page},
|
||||
lastUpdated => 1230844137,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ checkModule("XML::FeedPP", 0.40 );
|
|||
checkModule("XML::FeedPP::MediaRSS", 0.02 );
|
||||
checkModule("JSON", 2.12 );
|
||||
checkModule("JSON::Any", 1.22 );
|
||||
checkModule("Config::JSON", '1.5000' );
|
||||
checkModule("JSON::PP", 0.00 );
|
||||
checkModule("Config::JSON", "1.3.1" );
|
||||
checkModule("Text::CSV_XS", "0.64" );
|
||||
checkModule("Net::CIDR::Lite", 0.20 );
|
||||
checkModule("Finance::Quote", 1.15 );
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ user will be set to. It can be overridden in the import file for
|
|||
specific users.
|
||||
|
||||
You can specify a unique expiration date for a group by adding it
|
||||
after the group ID, seperated by a colon. The date/time should be in
|
||||
after the group ID, separated by a colon. The date/time should be in
|
||||
"YYYY-MM-DD HH:NN:SS" format.
|
||||
|
||||
groupId:2000-01-01 01:00:00,groupId2:2001-01-02 02:00:00
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -162,9 +162,6 @@ $storage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg'))
|
|||
$storage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('littleTextFile'));
|
||||
my $attachment_loop = $post1->getTemplateVars()->{attachment_loop};
|
||||
|
||||
use Data::Dumper;
|
||||
diag Dumper($attachment_loop);
|
||||
|
||||
my @extensions = map { [ $_->{filename}, $_->{extension} ] } @{ $attachment_loop };
|
||||
|
||||
cmp_bag(
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ use lib "$FindBin::Bin/../../lib";
|
|||
use Test::MockTime qw/:all/; ##Must be loaded before all other code
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 3; # increment this value for each test you create
|
||||
use Test::More tests => 5; # increment this value for each test you create
|
||||
use WebGUI::Asset::Wobject::Layout;
|
||||
use WebGUI::Asset::Template;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -64,4 +65,25 @@ set_relative_time(-100);
|
|||
$snip1 = $snip1->addRevision({ title => 'titular', }, 18);
|
||||
is $page->getContentLastModifiedBy, $revised_user1->userId, '... check that a new revision tracks';
|
||||
|
||||
# inheriting mobileStyleTemplateId and mobileTemplateId; from ``Mobile template is not being inherited (#12246)''
|
||||
|
||||
my $importNode = WebGUI::Asset::Template->getImportNode($session);
|
||||
my $template1 = $importNode->addChild({className=>"WebGUI::Asset::Template"});
|
||||
my $template2 = $importNode->addChild({className=>"WebGUI::Asset::Template"});
|
||||
WebGUI::Test->addToCleanup($template1, $template2);
|
||||
|
||||
my $mobileStyleTemplateId = $template1->getId;
|
||||
my $mobileTemplateId = $template2->getId;
|
||||
$page->update({ mobileStyleTemplateId => $mobileStyleTemplateId, mobileTemplateId => $mobileTemplateId });
|
||||
my $url = $page->get('url') . '/layout_child_test';
|
||||
my $html = WebGUI::Test->getPage($page, "www_add", {
|
||||
userId => 3,
|
||||
formParams => {
|
||||
class => 'WebGUI::Asset::Wobject::Layout',
|
||||
url => $page->get('url') . '/layout_child_test',
|
||||
},
|
||||
});
|
||||
|
||||
like $html, qr/name="mobileTemplateId" value="$mobileTemplateId"/, 'child PageLayout inherited parents mobileTempaleId';
|
||||
like $html, qr/name="mobileStyleTemplateId" value="$mobileStyleTemplateId"/, 'child PageLayout inherited parents mobileStyleTempaleId';
|
||||
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ is $session->db->quickScalar('select count(*) from assetIndex where assetId=?',[
|
|||
|
||||
my $record;
|
||||
|
||||
$record = $session->db->quickHashRef('select * from assetIndex where assetId=?',[$thingy->getId]);
|
||||
$record = $session->db->quickHashRef('select * from assetIndex where assetId=? AND subId IS NOT NULL',[$thingy->getId]);
|
||||
cmp_deeply(
|
||||
$record,
|
||||
superhashof({
|
||||
subId => 'THING_RECORD',
|
||||
url => $thingy->getUrl('func=search;thingId=THING_RECORD'),
|
||||
url => $session->url->append($thingy->get('url'), 'func=search;thingId=THING_RECORD'),
|
||||
title => 'Label',
|
||||
groupIdView => 2,
|
||||
keywords => all(
|
||||
|
|
@ -165,7 +165,7 @@ cmp_deeply(
|
|||
score => ignore(),
|
||||
synopsis => ignore(),
|
||||
title => 'Label', ##From the Thing's label
|
||||
url => $thingy->getUrl('func=viewThingData;thingId='.$thingId.';thingDataId=THING_DATA'),
|
||||
url => $session->url->append($thingy->get('url'), 'func=viewThingData;thingId='.$thingId.';thingDataId=THING_DATA'),
|
||||
}
|
||||
],
|
||||
'Checking indexed data for the thingData'
|
||||
|
|
@ -214,7 +214,7 @@ cmp_deeply(
|
|||
score => ignore(),
|
||||
synopsis => ignore(),
|
||||
title => '8/16/2001', ##From viewScreenTitle, which is $birthday in user's preferred date format
|
||||
url => $thingy->getUrl('func=viewThingData;thingId='.$thingId.';thingDataId=THING_DATA'),
|
||||
url => $session->url->append($thingy->get('url'), 'func=viewThingData;thingId='.$thingId.';thingDataId=THING_DATA'),
|
||||
}
|
||||
],
|
||||
'Checking indexed data for the thingData'
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@ use WebGUI::Session;
|
|||
use Test::Deep;
|
||||
use Scope::Guard;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
#plan tests => 9; # Increment this number for each test you create
|
||||
plan skip_all => 'Test server for LDAP down'; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
|
@ -41,11 +47,6 @@ $ldapGroup->set( "ldapGroupProperty", "member" );
|
|||
$ldapGroup->set( "ldapRecursiveProperty", "uid" );
|
||||
WebGUI::Test->addToCleanup($ldapGroup);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 9; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test Login of existing user
|
||||
my $user = WebGUI::User->create( $session );
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ my ($redirect, $response, $url);
|
|||
# Get the site's base URL
|
||||
my $baseUrl = 'http://localhost/';
|
||||
|
||||
my $httpAuthUrl = 'http://' . $USERNAME . ':' . $IDENTIFIER . '@' . $session->config->get('sitename')->[0];
|
||||
# $httpAuthUrl .= ':8000'; # no easy way to automatically find this
|
||||
$httpAuthUrl .= $session->config->get('gateway');
|
||||
|
||||
# Make an asset we can login on
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
my $node = WebGUI::Test->asset;
|
||||
|
|
@ -74,7 +78,6 @@ my $asset = $asset->cloneFromDb;
|
|||
# Tests
|
||||
|
||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->config );
|
||||
plan tests => 40; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# no form: Test logging in on a normal page sends the user back to the same page
|
||||
|
|
@ -263,3 +266,12 @@ $mech->submit_form_ok(
|
|||
);
|
||||
$mech->base_is( $assetUrl, "We don't get redirected" );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# HTTP basic auth
|
||||
$mech = Test::WWW::Mechanize->new;
|
||||
$mech->get( $httpAuthUrl );
|
||||
$mech->content_contains( "Hello, $USERNAME", "We are greeted by name" );
|
||||
$mech->get( $httpAuthUrl . $asset->get('url') );
|
||||
$mech->content_contains( "ARTICLE", "We are shown the article" );
|
||||
|
||||
done_testing;
|
||||
|
|
|
|||
47
t/Group.t
47
t/Group.t
|
|
@ -70,26 +70,6 @@ my @ipTests = (
|
|||
},
|
||||
);
|
||||
|
||||
my @ldapTests = (
|
||||
{
|
||||
dn => 'uid=Byron Hadley,o=shawshank',
|
||||
comment => 'bad dn for group',
|
||||
expect => 0,
|
||||
},
|
||||
{
|
||||
dn => 'uid=Andy Dufresne,o=shawshank',
|
||||
comment => 'good dn for group',
|
||||
expect => 1,
|
||||
},
|
||||
{
|
||||
dn => 'uid=Bogs Diamond,o=shawshank',
|
||||
comment => 'another good dn for group',
|
||||
expect => 1,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
plan tests => (173 + (scalar(@scratchTests) * 2) + scalar(@ipTests)); # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->cache->remove('myTestKey');
|
||||
|
|
@ -633,14 +613,16 @@ WebGUI::Test->addToCleanup(@sessionBank);
|
|||
|
||||
#isInGroup test
|
||||
foreach my $scratchTest (@scratchTests) {
|
||||
is($scratchTest->{user}->isInGroup($gS->getId), $scratchTest->{expect}, $scratchTest->{comment});
|
||||
is($scratchTest->{user}->isInGroup($gS->getId), $scratchTest->{expect}, $scratchTest->{comment});
|
||||
}
|
||||
|
||||
$session->cache->remove("isInGroup");
|
||||
|
||||
#hasScratchUser test
|
||||
foreach my $scratchTest (@scratchTests) {
|
||||
is($gS->hasScratchUser($scratchTest->{user}->getId), $scratchTest->{expect}, $scratchTest->{comment}." - hasScratchUser");
|
||||
foreach my $idx (0..$#scratchTests) {
|
||||
my $scratchTest = $scratchTests[$idx];
|
||||
my $sessionId = $sessionBank[$idx]->getId;
|
||||
is($gS->hasScratchUser($scratchTest->{user}->getId, $sessionId), $scratchTest->{expect}, $scratchTest->{comment}." - hasScratchUser");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -658,7 +640,7 @@ cmp_bag(
|
|||
|
||||
{ ##Add scope to force cleanup
|
||||
|
||||
note "Checking for user Visitor session leak";
|
||||
note "Checking for user Visitor session leak with scratch";
|
||||
|
||||
my $remoteSession = WebGUI::Test->newSession;
|
||||
$remoteSession->user({userId => 1});
|
||||
|
|
@ -673,13 +655,13 @@ cmp_bag(
|
|||
my $localSession = WebGUI::Test->newSession;
|
||||
WebGUI::Test->addToCleanup($localScratchGroup, $remoteSession, $localSession);
|
||||
$localSession->user({userId => 1});
|
||||
$remoteSession->scratch->set('local','ok');
|
||||
$localSession->scratch->set('local','ok');
|
||||
$localScratchGroup->clearCaches;
|
||||
|
||||
ok $localSession->user->isInGroup($localScratchGroup->getId), 'Local Visitor is in the scratch group';
|
||||
|
||||
$remoteSession->stow->delete('isInGroup');
|
||||
ok !$remoteSession->user->isInGroup($localScratchGroup->getId), 'Remove Visitor is not in the scratch group, even though a different Visitor passed';
|
||||
ok !$remoteSession->user->isInGroup($localScratchGroup->getId), 'Remote Visitor is not in the scratch group, even though a different Visitor passed';
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -702,8 +684,9 @@ foreach my $idx (0..$#ipTests) {
|
|||
##Name this user for convenience
|
||||
$tcps[$idx]->username("tcp$idx");
|
||||
|
||||
##Assign this user to this test to be fetched later
|
||||
$ipTests[$idx]->{user} = $tcps[$idx];
|
||||
##Assign this user and session to this test to be fetched later
|
||||
$ipTests[$idx]->{user} = $tcps[$idx];
|
||||
$ipTests[$idx]->{session} = $sessionBank[$idx];
|
||||
}
|
||||
WebGUI::Test->addToCleanup(@tcps);
|
||||
|
||||
|
|
@ -725,7 +708,7 @@ cmp_bag(
|
|||
);
|
||||
|
||||
is_deeply(
|
||||
[ (map { $gI->hasIpUser($_->{user}->getId) } @ipTests) ],
|
||||
[ (map { $gI->hasIpUser($_->{user}->getId, $_->{session}->getId) } @ipTests) ],
|
||||
[ (map { $_->{expect} } @ipTests) ],
|
||||
'hasIpUsers for group with IP filter'
|
||||
);
|
||||
|
|
@ -736,7 +719,7 @@ foreach my $ipTest (@ipTests) {
|
|||
|
||||
{ ##Add scope to force cleanup
|
||||
|
||||
note "Checking for user Visitor session leak";
|
||||
note "Checking for user Visitor session leak via IP address";
|
||||
|
||||
my $remoteSession = WebGUI::Test->newSession;
|
||||
$remoteSession->request->env->{REMOTE_ADDR} = '191.168.1.1';
|
||||
|
|
@ -757,7 +740,8 @@ foreach my $ipTest (@ipTests) {
|
|||
ok $localSession->user->isInGroup($localIpGroup->getId), 'Local Visitor is in the group';
|
||||
|
||||
$remoteSession->stow->delete('isInGroup');
|
||||
ok !$remoteSession->user->isInGroup($localIpGroup->getId), 'Remove Visitor is not in the group, even though a different Visitor passed';
|
||||
$localIpGroup->clearCaches;
|
||||
ok !$remoteSession->user->isInGroup($localIpGroup->getId), 'Remote Visitor is not in the group, even though a different Visitor passed';
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -858,5 +842,6 @@ ok(
|
|||
"registered users: don't get the users in both groups",
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -20,27 +20,49 @@ use WebGUI::Group;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $session1 = WebGUI::Test->session;
|
||||
my $session2 = WebGUI::Session->open(WebGUI::Test::root, WebGUI::Test::file);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
### Updates by DRT test that group membership is restricted by user session
|
||||
### ...specifically for Visitors to have separate scratch group memberships
|
||||
|
||||
plan tests => 5; # Increment this number for each test you create
|
||||
plan tests => 14; # Increment this number for each test you create
|
||||
|
||||
my $group = WebGUI::Group->new($session, 'new');
|
||||
my $group = WebGUI::Group->new($session1, 'new');
|
||||
WebGUI::Test->addToCleanup($group);
|
||||
$group->scratchFilter("itchy=test_value");
|
||||
is( $group->scratchFilter(), "itchy=test_value",'Group->scratchFilter is properly set and retrieved');
|
||||
$group->groupCacheTimeout(0);
|
||||
is( $group->groupCacheTimeout(), 0, 'set groupCacheTimeout to 0');
|
||||
|
||||
$session->user({userId => 1});
|
||||
ok( !$session->user->isInGroup($group->getId), 'Visitor is NOT in the group BEFORE scratch value is set');
|
||||
$session->scratch->set('itchy', 'test_value');
|
||||
is ($group->hasScratchUser($session->user->getId), 1, 'Group->hasScratchUser correctly returns 1 immediately after scratch is set');
|
||||
$session1->user({userId => 1});
|
||||
$session2->user({userId => 1});
|
||||
|
||||
##Simulate another page view by clearing stow, which is volatile
|
||||
$session->stow->deleteAll;
|
||||
$session->scratch->delete('itchy');
|
||||
is ($group->hasScratchUser($session->user->getId), 0, 'after clearing scratch, user is not in the group any longer');
|
||||
### Test group membership before scratch is set
|
||||
### NOTE: test hasScratchUser first, because isInGroup sets stow & cache
|
||||
is ($group->hasScratchUser($session1->user->getId,$session1->user->session->getId), 0, 'Group->hasScratchUser correctly returns 0 for Visitor 1 before scratch is set');
|
||||
is ($group->hasScratchUser($session2->user->getId,$session2->user->session->getId), 0, 'Group->hasScratchUser correctly returns 0 for Visitor 2 before scratch is set');
|
||||
ok( !$session1->user->isInGroup($group->getId), 'user1->isInGroup correctly returns 0 before scratch is set');
|
||||
ok( !$session2->user->isInGroup($group->getId), 'user2->isInGroup correctly returns 0 before scratch is set');
|
||||
|
||||
### Test group membership after scratch is set
|
||||
### Clear stow, which is volatile, to simulate new page view
|
||||
$session1->stow->deleteAll;
|
||||
$session2->stow->deleteAll;
|
||||
$session1->scratch->set('itchy', 'test_value');
|
||||
is ($group->hasScratchUser($session1->user->getId,$session1->user->session->getId), 1, 'Group->hasScratchUser correctly returns 1 for Visitor 1 after scratch for Visitor 1 is set');
|
||||
is ($group->hasScratchUser($session2->user->getId,$session2->user->session->getId), 0, 'Group->hasScratchUser correctly returns 0 for Visitor 2 after scratch for Visitor 1 is set');
|
||||
ok( $session1->user->isInGroup($group->getId), 'user1->isInGroup correctly returns 1 after scratch for Visitor 1 is set');
|
||||
ok( !$session2->user->isInGroup($group->getId), 'user2->isInGroup correctly returns 0 after scratch for Visitor 1 is set');
|
||||
|
||||
### Test group membership after scratch is deleted
|
||||
### Clear stow, which is volatile, to simulate new page view
|
||||
$session1->stow->deleteAll;
|
||||
$session2->stow->deleteAll;
|
||||
$session1->scratch->delete('itchy');
|
||||
is ($group->hasScratchUser($session1->user->getId,$session1->user->session->getId), 0, 'Group->hasScratchUser for Visitor 1 correctly returns 0 after clearing scratch for Visitor 1');
|
||||
is ($group->hasScratchUser($session2->user->getId,$session2->user->session->getId), 0, 'Group->hasScratchUser for Visitor 2 correctly returns 0 after clearing scratch for Visitor 1');
|
||||
ok( !$session1->user->isInGroup($group->getId), 'user1->isInGroup correctly returns 0 after scratch for Visitor 1 is deleted');
|
||||
ok( !$session2->user->isInGroup($group->getId), 'user2->isInGroup correctly returns 0 after scratch for Visitor 1 is deleted');
|
||||
|
|
|
|||
101
t/Group/ldap_groups.t
Normal file
101
t/Group/ldap_groups.t
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Utility;
|
||||
|
||||
use WebGUI::User;
|
||||
use WebGUI::Group;
|
||||
use WebGUI::Cache;
|
||||
|
||||
use Test::More skip_all => 'Disabled until the test LDAP server is rejuvenated';
|
||||
use Test::Deep;
|
||||
|
||||
my @ldapTests = (
|
||||
{
|
||||
dn => 'uid=Byron Hadley,o=shawshank',
|
||||
comment => 'bad dn for group',
|
||||
expect => 0,
|
||||
},
|
||||
{
|
||||
dn => 'uid=Andy Dufresne,o=shawshank',
|
||||
comment => 'good dn for group',
|
||||
expect => 1,
|
||||
},
|
||||
{
|
||||
dn => 'uid=Bogs Diamond,o=shawshank',
|
||||
comment => 'another good dn for group',
|
||||
expect => 1,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
################################################################
|
||||
#
|
||||
# LDAP specific group properties
|
||||
# These tests have to be done on an isolated group that will NEVER
|
||||
# have getGroups called on it
|
||||
#
|
||||
################################################################
|
||||
|
||||
my $ldapProps = WebGUI::Test->getSmokeLDAPProps();
|
||||
$session->db->setRow('ldapLink', 'ldapLinkId', $ldapProps, $ldapProps->{ldapLinkId});
|
||||
my $ldap = WebGUI::LDAPLink->new($session, $ldapProps->{ldapLinkId});
|
||||
is($ldap->getValue("ldapLinkId"),$ldapProps->{ldapLinkId},'ldap link created properly');
|
||||
WebGUI::Test->addToCleanup($ldap);
|
||||
|
||||
my @shawshank;
|
||||
|
||||
foreach my $idx (0..$#ldapTests) {
|
||||
$shawshank[$idx] = WebGUI::User->new($session, "new");
|
||||
$shawshank[$idx]->username("shawshank$idx");
|
||||
$shawshank[$idx]->authMethod("LDAP");
|
||||
my $auth = $shawshank[$idx]->authInstance;
|
||||
$auth->saveParams($shawshank[$idx]->getId,$shawshank[$idx]->authMethod,{
|
||||
connectDN => $ldapTests[$idx]->{dn},
|
||||
ldapConnection => $ldap->getValue("ldapLinkId"),
|
||||
ldapUrl => $ldap->getValue("ldapUrl"),
|
||||
});
|
||||
}
|
||||
|
||||
WebGUI::Test->addToCleanup(@shawshank);
|
||||
|
||||
my $lGroup = WebGUI::Group->new($session, 'new');
|
||||
|
||||
$lGroup->ldapGroup('cn=Convicts,o=shawshank');
|
||||
is($lGroup->ldapGroup(), 'cn=Convicts,o=shawshank', 'ldapGroup set and fetched correctly');
|
||||
|
||||
$lGroup->ldapGroupProperty('member');
|
||||
is($lGroup->ldapGroupProperty(), 'member', 'ldapGroup set and fetched correctly');
|
||||
|
||||
$lGroup->ldapLinkId($ldapProps->{ldapLinkId});
|
||||
is($lGroup->ldapLinkId(),$ldapProps->{ldapLinkId}, 'ldapLinkId set and fetched correctly');
|
||||
|
||||
is_deeply(
|
||||
[ (map { $lGroup->hasLDAPUser($_->getId) } @shawshank) ],
|
||||
[0, 1, 1],
|
||||
'shawshank user 2, and 3 found in lGroup users from LDAP'
|
||||
);
|
||||
|
||||
$lGroup->ldapRecursiveProperty('LDAP recursive property');
|
||||
is($lGroup->ldapRecursiveProperty(), 'LDAP recursive property', 'ldapRecursiveProperty set and fetched correctly');
|
||||
|
||||
$lGroup->ldapRecursiveFilter('LDAP recursive filter');
|
||||
is($lGroup->ldapRecursiveFilter(), 'LDAP recursive filter', 'ldapRecursiveFilter set and fetched correctly');
|
||||
|
||||
$lGroup->delete;
|
||||
|
||||
done_testing;
|
||||
|
||||
|
|
@ -50,7 +50,8 @@ plan tests => 9; # Increment this number for each test you create
|
|||
#
|
||||
###########################################################################
|
||||
|
||||
{
|
||||
SKIP: {
|
||||
skip "Test LDAP server is down", 3;
|
||||
my $ldapProps = WebGUI::Test->getSmokeLDAPProps();
|
||||
$session->db->setRow('ldapLink', 'ldapLinkId', $ldapProps, $ldapProps->{ldapLinkId});
|
||||
my $ldap = WebGUI::LDAPLink->new($session, $ldapProps->{ldapLinkId});
|
||||
|
|
@ -68,7 +69,8 @@ plan tests => 9; # Increment this number for each test you create
|
|||
#
|
||||
###########################################################################
|
||||
|
||||
{
|
||||
SKIP: {
|
||||
skip "Test LDAP server is down", 4;
|
||||
my $ldapProps = WebGUI::Test->getSmokeLDAPProps();
|
||||
$ldapProps->{identifier} = 'hadley';
|
||||
$session->db->setRow('ldapLink', 'ldapLinkId', $ldapProps, $ldapProps->{ldapLinkId});
|
||||
|
|
|
|||
1
t/SQL.t
1
t/SQL.t
|
|
@ -224,6 +224,7 @@ SKIP: {
|
|||
|
||||
}
|
||||
|
||||
$session->db->dbh->do('DROP TABLE IF EXISTS testTable');
|
||||
$session->db->dbh->do('CREATE TABLE testTable (myIndex int(8) NOT NULL default 0, message CHAR(64), myKey varchar(32), PRIMARY KEY(myIndex))');
|
||||
|
||||
my @tableData = (
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ use Kwargs;
|
|||
use URI;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
WebGUI::Test->originalConfig('templateParsers');
|
||||
$session->config->addToArray('templateParsers', 'WebGUI::Asset::Template::TemplateToolkit');
|
||||
|
||||
my $act = WebGUI::Workflow::Activity->newByPropertyHashRef(
|
||||
$session, {
|
||||
|
|
|
|||
58
t/templateAttachments.t
Normal file
58
t/templateAttachments.t
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 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::Session;
|
||||
use Data::Dumper;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::Macro;
|
||||
|
||||
#The goal of this test is to find template attachments that do not resolve.
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
my $numTests = 0;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
# put your tests here
|
||||
|
||||
$numTests = $session->db->quickScalar('select count(distinct(assetId)) from template');
|
||||
|
||||
my $getATemplate = WebGUI::Asset::Template->getIsa($session);
|
||||
|
||||
WebGUI::Test->originalConfig('extrasURL');
|
||||
$session->config->set('extrasURL', '');
|
||||
|
||||
TEMPLATE: while (my $templateAsset = $getATemplate->()) {
|
||||
my $bad_attachments = 0;
|
||||
foreach my $attachment (@{ $templateAsset->getAttachments }) {
|
||||
my $url = $attachment->{url};
|
||||
WebGUI::Macro::process($session, \$url);
|
||||
my $url_exists = 0;
|
||||
if ($attachment->{url} =~ /\^Extras/) {
|
||||
##File system path for /extras, adjust the URL for that.
|
||||
$url = $session->config->get('extrasPath') . $url;
|
||||
$url_exists = -e $url;
|
||||
}
|
||||
else {
|
||||
my $asset = eval { WebGUI::Asset->newByUrl($session, $url) };
|
||||
$url_exists = defined $asset;
|
||||
}
|
||||
ok $url_exists, sprintf "%s: %s (%s) has a bad attachment url: %s", $templateAsset->getTitle, $templateAsset->getId, $templateAsset->getUrl, $attachment->{url};
|
||||
}
|
||||
}
|
||||
|
||||
done_testing;
|
||||
Loading…
Add table
Add a link
Reference in a new issue