GroupText.t: fix number of tests
Session/Id.pm: add a method to validate GUIDs, change s/// to tr/// for efficiency. Session.pm: change open to use new Id.pm validation method Scratch.t: Change test from ok to is so that it tells you what the failing ID is. Id.t: Add validation tests in addition to uniqueness tests. Fix the uniqueness test so that it works. Add tests to check the new validation method
This commit is contained in:
parent
41bdf0e28d
commit
f3a1f0f9f2
6 changed files with 65 additions and 8 deletions
|
|
@ -68,8 +68,7 @@ sub generate {
|
|||
my($s,$us)=gettimeofday();
|
||||
my($v)=sprintf("%09d%06d%10d%06d%255s",rand(999999999),$us,$s,$$,$self->session->config->getFilename);
|
||||
my $id = Digest::MD5::md5_base64($v);
|
||||
$id =~ s/\+/_/g;
|
||||
$id =~ s/\//-/g;
|
||||
$id =~ tr{+/}{_-};
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
|
@ -105,6 +104,19 @@ sub session {
|
|||
return $self->{_session};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 valid ( $idString )
|
||||
|
||||
Returns true if $idString is a valid WebGUI guid.
|
||||
|
||||
=cut
|
||||
|
||||
sub valid {
|
||||
my ($self, $idString) = @_;
|
||||
return $idString =~ m/^[A-Za-z0-9_-]{22}$/;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue