Index: openacs-4/packages/acs-automated-testing/acs-automated-testing.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/acs-automated-testing.info,v diff -u -N -r1.46 -r1.47 --- openacs-4/packages/acs-automated-testing/acs-automated-testing.info 31 Jul 2018 11:49:49 -0000 1.46 +++ openacs-4/packages/acs-automated-testing/acs-automated-testing.info 4 Oct 2018 09:59:41 -0000 1.47 @@ -7,7 +7,7 @@ t t - + OpenACS The interface to the automated testing facilities within OpenACS. 2017-08-06 @@ -19,10 +19,12 @@ OpenACS system. Also provides a UI for managing automatic-rebuild servers as in a test farm. - + + + Index: openacs-4/packages/acs-automated-testing/tcl/aa-test-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/tcl/Attic/aa-test-init.tcl,v diff -u -N --- openacs-4/packages/acs-automated-testing/tcl/aa-test-init.tcl 7 Aug 2017 23:47:46 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ -ad_library { - Server startup initialization code for the acs-automated-testing package - - @author Peter Marklund - @creation-date 4:th of April 2003 - @cvs-id $Id: aa-test-init.tcl,v 1.3 2017/08/07 23:47:46 gustafn Exp $ -} - -# LARS: Moved to aa-test-procs.tcl file. See comment there. - -# Local variables: -# mode: tcl -# tcl-indent-level: 4 -# indent-tabs-mode: nil -# End: Index: openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl,v diff -u -N -r1.77 -r1.78 --- openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 31 Jul 2018 11:49:49 -0000 1.77 +++ openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 4 Oct 2018 09:59:41 -0000 1.78 @@ -150,22 +150,23 @@ constructor destructor } { - Registers a initialisation class to be used by one or more testcases. An - initialisation class can be assigned to a testcase via the - aa_register_case proc.

-

- An initialisation constructor is called once before + Registers a initialization class to be used by one or more testcases. An + initialization class can be assigned to a testcase via the + aa_register_case proc. + + An initialization constructor is called once before running a set of testcases, and the descructor called once upon completion of running a set of testcases.

The idea behind this is that it could be used to perform data intensive operations that shared amongst a set if testcases. For example, mounting an instance of a package. This could be performed by each testcase individually, but this would be highly inefficient if there are any significant number of them. -

+ Better to let the acs-automated-testing infrastructure call the init_class code to set the package up, run all the tests, then call the descructor to unmount the package. + @author Peter Harper @creation-date 04 November 2001 @@ -220,7 +221,7 @@ # the constructor has exported. # ad_proc -private _${package_key}__i_$init_class_id {} " - aa_log \"Running \\\"$init_class_id\\\" initialisation class constructor\" + aa_log \"Running \\\"$init_class_id\\\" initialization class constructor\" $constructor " ad_proc -private _${package_key}__d_$init_class_id {} " @@ -546,7 +547,7 @@ ad_proc -public aa_export_vars { args } { - Called from a initialisation class constructor or a component to + Called from a initialization class constructor or a component to explicitly export the specified variables to the current testcase. You need to call aa_export_vars before you create the variables. @@ -588,7 +589,7 @@ set aa_run_quietly_p $quiet_p # - # Work out the list of initialisation classes. + # Work out the list of initialization classes. # set testcase_ids {} if {$testcase_id ne ""} { @@ -639,8 +640,8 @@ } } # - # Run each initialisation script. Keep a list of the exported variables - # by each initialisation script so each testcase (and destructor) can + # Run each initialization script. Keep a list of the exported variables + # by each initialization script so each testcase (and destructor) can # correctly upvar to gain visibility of them. # if {[info exists classes]} { @@ -663,7 +664,7 @@ } # - # Run each initialisation destructor script. + # Run each initialization destructor script. # if {[info exists classes]} { foreach initpair [array names classes] { @@ -859,10 +860,21 @@ #global aa_testcase_id #global aa_package_key - if {$::aa_run_quietly_p} { - return + # + # When aa_run_quietly_p exists, we run inside the testing + # environment. + # + if {[info exists ::aa_run_quietly_p]} { + if {$::aa_run_quietly_p} { + return + } + aa_log_result "log" $log_notes + } else { + # + # Use plain ns_log reporting + # + ns_log notice "aa_log: $log_notes" } - aa_log_result "log" $log_notes } ad_proc -public aa_error { @@ -898,7 +910,7 @@ global aa_error_level # - # If logging is happened whilst in a initialisation class, store the log + # If logging is happened whilst in a initialization class, store the log # entry, but don't write it to the database. Individual testcase will make # their own copies of these log entries. # @@ -1689,11 +1701,11 @@ @return The user_info dict returned by auth::create_user. Contains the additional keys email and password. } { - set username "__test_user_[ad_generate_random_string]" - set email "${username}@test.test" - set password [ad_generate_random_string] + set username "__test_user_[ad_generate_random_string]" + set email "${username}@test.test" + set password [ad_generate_random_string] set first_names [ad_generate_random_string] - set last_name [ad_generate_random_string] + set last_name [ad_generate_random_string] set user_info [auth::create_user \ -user_id $user_id \ @@ -1703,7 +1715,8 @@ -last_name $last_name \ -password $password \ -secret_question [ad_generate_random_string] \ - -secret_answer [ad_generate_random_string]] + -secret_answer [ad_generate_random_string] \ + -authority_id [auth::authority::get_id -short_name "acs_testing"]] if { [dict get $user_info creation_status] ne "ok" } { # Could not create user Index: openacs-4/packages/acs-automated-testing/tcl/authority-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/tcl/authority-init.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-automated-testing/tcl/authority-init.tcl 4 Oct 2018 09:59:41 -0000 1.1 @@ -0,0 +1,23 @@ +ad_library { + Server startup initialization code for the "acs_testing" authority. + + @author Gustaf Neumann + @creation-date 2018-10-04 +} + +# +# Make sure, the needed service contracts are defined: +# +acs::test::auth::install + +# +# Refresh the alias wrappers, in case acs-service-contract-init.tcl +# was run before us. +# +acs_sc_update_alias_wrappers + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: Index: openacs-4/packages/acs-automated-testing/tcl/authority-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/tcl/authority-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-automated-testing/tcl/authority-procs.tcl 4 Oct 2018 09:59:41 -0000 1.1 @@ -0,0 +1,133 @@ +ad_library { + + Provide a simply authority named "acs_testing" for creating test + users during runs of the regression test. This is needed, when a + site/sub-site runs a registry which does e.g. a synchronized + registry, where no additional accounts can be created. + + @author Gustaf Neumann + @creation-date 2018-10-04 +} + +namespace eval acs::test::auth {} +namespace eval acs::test::auth::registration {} + +##### +# +# acs::test::auth +# +##### + +ad_proc -private acs::test::auth::install {} { + + Register the service contract implementations for the acs_testing + authority and update the authority accordingly. Do nothing, when + the registry exists already. + +} { + set authority_name acs_testing + + if {[auth::authority::get_id -short_name $authority_name] eq ""} { + ns_log notice "create authority $authority_name" + + set register_impl_id [acs_sc::impl::get_id \ + -owner acs-authentication \ + -name acs_testing \ + -contract auth_registration] + if {$register_impl_id eq ""} { + acs::test::auth::registration::register_impl + set register_impl_id [acs_sc::impl::get_id \ + -owner acs-authentication \ + -name acs_testing \ + -contract auth_registration] + ns_log notice "create authority $authority_name => register_impl_id $register_impl_id" + } + + set auth_impl_id [acs_sc::impl::get_id -owner acs-authentication -name local -contract auth_authentication] + set pwd_impl_id [acs_sc::impl::get_id -owner acs-authentication -name local -contract auth_password] + set user_info_impl_id [acs_sc::impl::get_id -owner acs-authentication -name local -contract auth_user_info] + + db_transaction { + array set row [list \ + short_name $authority_name \ + pretty_name "ACS Automated Testing" \ + auth_impl_id $auth_impl_id \ + pwd_impl_id $pwd_impl_id \ + register_impl_id $register_impl_id \ + user_info_impl_id $user_info_impl_id \ + ] + auth::authority::create -array row + } + } +} + +ad_proc -private acs::test::auth::registration::register_impl {} { + + Register the 'acs_testing' implementation of the + 'auth_registration' service contract. We just implement + "Register" new and reuse the implementations for "GetElements" and + "GetParameters" + + @return impl_id of the newly created implementation. +} { + ns_log notice "create registration::register_impl sc" + + set spec { + contract_name "auth_registration" + owner "acs-authentication" + name "acs_testing" + pretty_name "ACS Automated Testing" + aliases { + GetElements auth::local::registration::GetElements + Register acs::test::auth::registration::Register + GetParameters auth::local::registration::GetParameters + } + } + return [acs_sc::impl::new_from_spec -spec $spec] +} + + +ad_proc -private acs::test::auth::registration::Register { + parameters + username + authority_id + first_names + last_name + screen_name + email + url + password + secret_question + secret_answer +} { + + Implements the "Register" operation of the auth_registration + service contract for the acs testing authority. This is in essence + a simplified version of the "local" authority without the + notifications and confirmation options. + +} { + set result { + creation_status "ok" + creation_message {} + element_messages {} + account_status "ok" + account_message {} + generated_pwd_p 0 + } + dict set result password $password + + # + # Set user's password + # + set user_id [acs_user::get_by_username -authority_id $authority_id -username $username] + ad_change_password $user_id $password + + return $result +} + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: