Skip to content

Commit 46f5be9

Browse files
committed
Merge commit 'daniel/master'
* commit 'daniel/master': Added install instructions, some more regression tests, and a few minor improvements to search testing and connection testing.
2 parents d8b002d + 175fdf4 commit 46f5be9

File tree

7 files changed

+240
-13
lines changed

7 files changed

+240
-13
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Sakoader Install instructions
2+
-----------------------------
3+
4+
1) You may well need to install a number of perl modules if they are not
5+
already installed on your system in order to make SlingPerl work:
6+
7+
$ perl -MCPAN -e shell
8+
cpan> install Crypt::SSLeay
9+
cpan> install GD::Graph
10+
cpan> install Getopt::Long
11+
cpan> install HTTP::DAV
12+
cpan> install JSON
13+
cpan> install LWP::UserAgent
14+
cpan> install MIME::Base64
15+
cpan> install Pod::Usage
16+
cpan> install Term::ANSIColor
17+
cpan> install Text::CSV
18+
cpan> install Time::HiRes

slingtests/osgikernel/testscripts/SlingPerl/Sling/Connection.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,11 @@ sub invite {
185185
my $res = Sling::Request::request( \$connection,
186186
Sling::ConnectionUtil::invite_setup( $connection->{ 'BaseURL' }, $invite, $types ) );
187187
my $success = Sling::ConnectionUtil::invite_eval( $res );
188+
my $authn = $connection->{ 'Authn' };
189+
my $username = $$authn->{ 'Username' };
188190
my $message = "Invitation: ";
189-
$message .= ( $success ? "issued " : "was not issued " ) . "to \"$invite\"";
191+
$message .= ( $success ? "issued " : "was not issued " ) .
192+
"to \"$invite\" by \"$username\".";
190193
$connection->set_results( "$message", $res );
191194
return $success;
192195
}

slingtests/osgikernel/testscripts/SlingPerl/Sling/Search.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ sub search {
7878
my $message = Sling::Print::dateTime .
7979
" Searching for \"$searchTerm\": Search OK. Found $hits hits. Time $timeElapse seconds.";
8080
$search->set_results( $hits, $message, $res, $timeElapse );
81-
return 1;
81+
return $hits;
8282
}
8383
else {
8484
my $message = Sling::Print::dateTime . " Searching for \"$searchTerm\": Search failed!";
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/perl
2+
3+
package Tests::Authn;
4+
5+
#{{{imports
6+
use strict;
7+
use lib qw ( .. );
8+
use Sling::Authn;
9+
use Sling::User;
10+
use Test::More;
11+
#}}}
12+
13+
#{{{sub run_regression_test
14+
15+
=pod
16+
17+
=head2 run_regression_test
18+
19+
Run regression tests for the authn object.
20+
21+
=cut
22+
23+
sub run_regression_test {
24+
my ( $authn, $verbose, $log ) = @_;
25+
# test user name:
26+
my $test_user = "testing_user_$$";
27+
# test user pass:
28+
my $test_pass = "pass";
29+
# test properties:
30+
my @test_properties;
31+
# Sling user1 object:
32+
my $user = new Sling::User( $authn, $verbose, $log );
33+
34+
my $super_user = $$authn->{ 'Username' };
35+
my $super_pass = $$authn->{ 'Password' };
36+
37+
# Run tests:
38+
ok( defined $user,
39+
"Authn Test: Sling User Object successfully created." );
40+
41+
# Add two users:
42+
ok( $user->add( $test_user . "_1", $test_pass, \@test_properties ),
43+
"Authn Test: User \"$test_user\" added successfully." );
44+
ok( $user->exists( $test_user . "_1" ),
45+
"Authn Test: User \"$test_user\" exists." );
46+
ok( $user->add( $test_user . "_2", $test_pass, \@test_properties ),
47+
"Authn Test: User \"$test_user\" added successfully." );
48+
ok( $user->exists( $test_user . "_2" ),
49+
"Authn Test: User \"$test_user\" exists." );
50+
51+
ok( $$authn->switch_user( $test_user . "_1", $test_pass, "basic", 1 ),
52+
"Authn Test: Successfully switched to user: \"" . $test_user . "_1\" with basic auth" );
53+
ok( $$authn->switch_user( $test_user . "_2", $test_pass, "form", 1 ),
54+
"Authn Test: Successfully switched to user: \"" . $test_user . "_2\" with form auth" );
55+
ok( $$authn->switch_user( $super_user, $super_pass, "basic", 1 ),
56+
"Authn Test: Successfully switched back to user: \"" . $super_user . "_1\" with basic auth" );
57+
58+
ok( $user->delete( $test_user . "_1" ),
59+
"Authn Test: User \"" . $test_user . "_1\" deleted successfully." );
60+
ok( ! $user->exists( $test_user . "_1" ),
61+
"Authn Test: User \"" . $test_user . "_1\" should no longer exist." );
62+
ok( $user->delete( $test_user . "_2" ),
63+
"Authn Test: User \"" . $test_user . "_2\" deleted successfully." );
64+
ok( ! $user->exists( $test_user . "_2" ),
65+
"Authn Test: User \"" . $test_user . "_2\" should no longer exist." );
66+
}
67+
#}}}
68+
69+
1;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/perl
2+
3+
package Tests::Content;
4+
5+
#{{{imports
6+
use strict;
7+
use lib qw ( .. );
8+
use Sling::Content;
9+
use Test::More;
10+
#}}}
11+
12+
#{{{sub run_regression_test
13+
14+
=pod
15+
16+
=head2 run_regression_test
17+
18+
Run regression tests for the content object.
19+
20+
=cut
21+
22+
sub run_regression_test {
23+
my ( $authn, $verbose, $log ) = @_;
24+
# test content name:
25+
my $test_content = "testing_content_$$";
26+
# test properties:
27+
my @test_properties;
28+
# Sling content object:
29+
my $content = new Sling::Content( $authn, $verbose, $log );
30+
31+
# Run tests:
32+
ok( defined $content,
33+
"Content Test: Sling Content Object successfully created." );
34+
ok( $content->add( $test_content, \@test_properties ),
35+
"Content Test: Content \"$test_content\" added successfully." );
36+
ok( $content->exists( $test_content ),
37+
"Content Test: Content \"$test_content\" exists." );
38+
ok( ! $content->exists( "missing_$test_content" ),
39+
"Content Test: Content \"missing_$test_content\" should not exist." );
40+
ok( $content->delete( $test_content ),
41+
"Content Test: Content \"$test_content\" deleted successfully." );
42+
ok( ! $content->exists( $test_content ),
43+
"Content Test: Content \"$test_content\" should no longer exist." );
44+
}
45+
#}}}
46+
47+
1;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/perl
2+
3+
package Tests::Search;
4+
5+
#{{{imports
6+
use strict;
7+
use lib qw ( .. );
8+
use Sling::Search;
9+
use Test::More;
10+
#}}}
11+
12+
#{{{sub run_regression_test
13+
14+
=pod
15+
16+
=head2 run_regression_test
17+
18+
Run regression tests for the search object.
19+
20+
=cut
21+
22+
sub run_regression_test {
23+
my ( $authn, $verbose, $log ) = @_;
24+
# test search word:
25+
my $test_search = "testing_search_$$";
26+
# test properties:
27+
my @test_properties = ( "search=$test_search" );
28+
# Sling user object:
29+
my $search = new Sling::Search( $authn, $verbose, $log );
30+
# Sling content object:
31+
my $content = new Sling::Content( $authn, $verbose, $log );
32+
# test content location:
33+
my $test_content = "testing_content_$$";
34+
35+
# Run tests:
36+
ok( defined $search,
37+
"Search Test: Sling Search Object successfully created." );
38+
ok( defined $content,
39+
"Search Test: Sling Content Object successfully created." );
40+
41+
# Add content:
42+
ok( $content->add( $test_content, \@test_properties ),
43+
"Search Test: Content \"$test_content\" added successfully." );
44+
ok( $content->exists( $test_content ),
45+
"Search Test: Content \"$test_content\" exists." );
46+
47+
# Perform searches:
48+
ok( $search->search( $test_search ) == 1,
49+
"Search Test: Search \"$test_search\" matched 1 item." );
50+
ok( $search->search( "missing_" . $test_search . "_missing" ) == 0,
51+
"Search Test: Search \"missing_" . "$test_search" . "_missing\" matched 0 items." );
52+
53+
# Delete content:
54+
ok( $content->delete( $test_content ),
55+
"Search Test: Content \"$test_content\" deleted successfully." );
56+
ok( ! $content->exists( $test_content ),
57+
"Search Test: Content \"$test_content\" should no longer exist." );
58+
}
59+
#}}}
60+
61+
1;

slingtests/osgikernel/testscripts/SlingPerl/regression_test.pl

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ =head1 OPTIONS
1111
Usage: perl regression_test.pl [-OPTIONS [-MORE_OPTIONS]] [--] [PROGRAM_ARG1 ...]
1212
The following options are accepted:
1313
14-
--all or -a - run all regression tests.
15-
--group or -g - run group regression tests.
14+
--all - run all regression tests.
15+
--authn - run authentication regression tests.
16+
--content - run content regression tests.
17+
--group - run group regression tests.
1618
--help or -? - view the script synopsis and options.
1719
--log or -L (log) - Log script output to specified log file.
1820
--man or -M - view the full script documentation.
1921
--pass or -p (password) - Password of system super user.
20-
--site or -s - run site regression tests.
21-
--superuser or -S (username) - User ID of system super user.
22+
--site - run site regression tests.
23+
--superuser or -u (username) - User ID of system super user.
2224
--threads or -t (threads) - Defines number of parallel processes
2325
to have running regression tests.
2426
--url or -U (URL) - URL for system being tested against.
25-
--user or -u - run user regression tests.
27+
--user - run user regression tests.
2628
--verbose or -v or -vv or -vvv - Increase verbosity of output.
2729
2830
Options may be merged together. -- stops processing of options.
@@ -53,19 +55,25 @@ =head1 Example Usage
5355
use Pod::Usage;
5456
use Sling::Authn;
5557
use Sling::URL;
58+
use Tests::Authn;
59+
use Tests::Content;
5660
use Tests::Group;
61+
use Tests::Search;
5762
use Tests::Site;
5863
use Tests::User;
5964
#}}}
6065

6166
#{{{options parsing
6267
my $all_tests;
68+
my $authn_test;
69+
my $content_test;
6370
my $group_test;
6471
my $help;
6572
my $log;
6673
my $man;
6774
my $numberForks = 1;
6875
my $password;
76+
my $search_test;
6977
my $site_test;
7078
my $url;
7179
my $username;
@@ -74,16 +82,19 @@ =head1 Example Usage
7482

7583
GetOptions (
7684
"all" => \$all_tests,
77-
"group|g" => \$group_test,
85+
"authn" => \$authn_test,
86+
"content" => \$content_test,
87+
"group" => \$group_test,
7888
"help|?" => \$help,
7989
"log|L=s" => \$log,
8090
"man|M" => \$man,
8191
"pass|p=s" => \$password,
82-
"site|s" => \$site_test,
83-
"superuser|S=s" => \$username,
92+
"search" => \$search_test,
93+
"site" => \$site_test,
94+
"superuser|u=s" => \$username,
8495
"threads|t=i" => \$numberForks,
8596
"url|U=s" => \$url,
86-
"user|u" => \$user_test,
97+
"user" => \$user_test,
8798
"verbose|v+" => \$verbose
8899
) or pod2usage(2);
89100

@@ -97,16 +108,25 @@ =head1 Example Usage
97108

98109
my $auth; # Just use default auth
99110

100-
my @all_tests_list = ( "Group", "Site", "User" );
111+
my @all_tests_list = ( "Authn", "Content", "Group", "Search", "Site", "User" );
101112
my @tests_selected = ();
102113

103114
if ( $all_tests ) {
104115
@tests_selected = @all_tests_list;
105116
}
106117
else {
118+
if ( $authn_test ) {
119+
push ( @tests_selected, "Authn" );
120+
}
121+
if ( $content_test ) {
122+
push ( @tests_selected, "Content" );
123+
}
107124
if ( $group_test ) {
108125
push ( @tests_selected, "Group" );
109126
}
127+
if ( $search_test ) {
128+
push ( @tests_selected, "Search" );
129+
}
110130
if ( $site_test ) {
111131
push ( @tests_selected, "Site" );
112132
}
@@ -130,9 +150,18 @@ =head1 Example Usage
130150
for ( my $j = $i ; $j < @tests_selected ; $j += $numberForks ) {
131151
my $test = $tests_selected[ $j ];
132152
my $authn = new Sling::Authn( $url, $username, $password, $auth, $verbose, $log );
133-
if ( $test =~ /^Group$/ ) {
153+
if ( $test =~ /^Authn$/ ) {
154+
Tests::Authn::run_regression_test( \$authn, $verbose, $log );
155+
}
156+
elsif ( $test =~ /^Content$/ ) {
157+
Tests::Content::run_regression_test( \$authn, $verbose, $log );
158+
}
159+
elsif ( $test =~ /^Group$/ ) {
134160
Tests::Group::run_regression_test( \$authn, $verbose, $log );
135161
}
162+
elsif ( $test =~ /^Search$/ ) {
163+
Tests::Search::run_regression_test( \$authn, $verbose, $log );
164+
}
136165
elsif ( $test =~ /^Site$/ ) {
137166
Tests::Site::run_regression_test( \$authn, $verbose, $log );
138167
}

0 commit comments

Comments
 (0)