Index: openacs-4/packages/acs-authentication/tcl/acs-authentication-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/Attic/acs-authentication-init.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-authentication/tcl/acs-authentication-init.tcl 27 Aug 2003 15:48:23 -0000 1.1 @@ -0,0 +1,4 @@ +# TODO - remove +apm_watch_all_files acs-authentication +apm_watch_all_files acs-automated-testing +apm_watch_all_files acs-tcl Index: openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl 27 Aug 2003 11:50:48 -0000 1.4 +++ openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl 27 Aug 2003 15:48:23 -0000 1.5 @@ -440,20 +440,23 @@ } } - # TODO: - # Implement parameters + set impl_name [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] + set impl_id [auth::authority::get_element -authority_id $authority_id -element "auth_impl_id"] - set impl_id [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] if { [empty_string_p $impl_id] } { # Invalid authority return {} } + set parameters [auth::driver::get_parameter_values \ + -authority_id $authority_id \ + -impl_id $impl_id] + return [acs_sc::invoke \ -contract "auth_authentication" \ - -impl $impl_id \ + -impl $impl_name \ -operation Authenticate \ - -call_args [list $username $password [list]]] + -call_args [list $username $password $parameters]] } ##### @@ -484,14 +487,18 @@ set authority_id [auth::authority::local] } - # TODO: - # Implement parameters + set impl_name [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_name"] + set impl_id [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_id"] + set parameters [auth::driver::get_parameter_values \ + -authority_id $authority_id \ + -impl_id $impl_id] + return [acs_sc::invoke \ -contract "auth_registration" \ - -impl [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] \ + -impl $impl_name \ -operation Register \ - -call_args [list [list] \ + -call_args [list $parameters \ $username \ $authority_id \ $first_names \ @@ -513,14 +520,19 @@ set authority_id [auth::authority::local] } - # TODO: - # Implement parameters + set impl_name [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_name"] + set impl_id [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_id"] + + set parameters [auth::driver::get_parameter_values \ + -authority_id $authority_id \ + -impl_id $impl_id] + return [acs_sc::invoke \ -contract "auth_registration" \ - -impl [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] \ + -impl $impl_name \ -operation GetElements \ - -call_args [list [list]]] + -call_args [list $parameters]] } @@ -913,14 +925,19 @@ set authority_id [auth::authority::local] } - # TODO: - # Implement parameters + set impl_name [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_name"] + set impl_id [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_id"] + + set parameters [auth::driver::get_parameter_values \ + -authority_id $authority_id \ + -impl_id $impl_id] + return [acs_sc::invoke \ -contract "auth_password" \ - -impl [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] \ + -impl $impl_name \ -operation CanChangePassword \ - -call_args [list [list]]] + -call_args [list $parameters]] } ad_proc -private auth::password::CanRetrievePassword { @@ -936,14 +953,19 @@ set authority_id [auth::authority::local] } - # TODO: - # Implement parameters + set impl_name [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_name"] + set impl_id [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_id"] + + set parameters [auth::driver::get_parameter_values \ + -authority_id $authority_id \ + -impl_id $impl_id] + return [acs_sc::invoke \ -contract "auth_password" \ - -impl [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] \ + -impl $impl_name \ -operation CanRetrievePassword \ - -call_args [list [list]]] + -call_args [list $parameters]] } ad_proc -private auth::password::CanResetPassword { @@ -959,14 +981,18 @@ set authority_id [auth::authority::local] } - # TODO: - # Implement parameters + set impl_name [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_name"] + set impl_id [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_id"] + set parameters [auth::driver::get_parameter_values \ + -authority_id $authority_id \ + -impl_id $impl_id] + return [acs_sc::invoke \ -contract "auth_password" \ - -impl [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] \ + -impl $impl_name \ -operation CanResetPassword \ - -call_args [list [list]]] + -call_args [list $parameters]] } ad_proc -private auth::password::ChangePassword { @@ -988,17 +1014,21 @@ set authority_id [auth::authority::local] } - # TODO: - # Implement parameters + set impl_name [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_name"] + set impl_id [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_id"] + set parameters [auth::driver::get_parameter_values \ + -authority_id $authority_id \ + -impl_id $impl_id] + return [acs_sc::invoke \ -contract "auth_password" \ - -impl [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] \ + -impl $impl_name \ -operation ChangePassword \ -call_args [list $username \ $old_password \ $new_password \ - [list]]] + $parameters]] } ad_proc -private auth::password::RetrievePassword { @@ -1016,15 +1046,19 @@ set authority_id [auth::authority::local] } - # TODO: - # Implement parameters + set impl_name [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_name"] + set impl_id [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_id"] + set parameters [auth::driver::get_parameter_values \ + -authority_id $authority_id \ + -impl_id $impl_id] + return [acs_sc::invoke \ -contract "auth_password" \ - -impl [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] \ + -impl $impl_name \ -operation RetrievePassword \ -call_args [list $username \ - [list]]] + $parameters]] } ad_proc -private auth::password::ResetPassword { @@ -1042,13 +1076,17 @@ set authority_id [auth::authority::local] } - # TODO: - # Implement parameters + set impl_name [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_name"] + set impl_id [auth::authority::get_element -authority_id $authority_id -element "pwd_impl_id"] + set parameters [auth::driver::get_parameter_values \ + -authority_id $authority_id \ + -impl_id $impl_id] + return [acs_sc::invoke \ -contract "auth_password" \ - -impl [auth::authority::get_element -authority_id $authority_id -element "auth_impl_name"] \ + -impl $impl_name \ -operation ResetPassword \ -call_args [list $username \ - [list]]] + $parameters]] } Index: openacs-4/packages/acs-authentication/tcl/driver-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/driver-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-authentication/tcl/driver-procs.tcl 27 Aug 2003 15:48:23 -0000 1.1 @@ -0,0 +1,92 @@ +ad_library { + Procs for driver paramaters service contract implementations. + + @author Simon Carstensen (simon@collaobraid.biz) + @creation-date 2003-08-27 + @cvs-id $Id: driver-procs.tcl,v 1.1 2003/08/27 15:48:23 simonc Exp $ +} + +namespace eval auth {} +namespace eval auth::driver {} + + + +##### +# +# auth::driver +# +##### + +ad_proc -public auth::driver::get_parameters { + {-impl_id:required} +} { + Returns a list of names of parameters for the driver + + @author Simon Carstensen (simon@collaboraid.biz) + @creation-date 2003-08-27 +} { + # Find the contract_name and impl_name + db_1row select_contract_impl_name { + select impl_name as impl, + impl_contract_name as contract + from acs_sc_impls + where impl_id = :impl_id + } + + # Check that it's a contract that we know of, or that it has the GetParameters method + set method_exists_p [db_string select_getparameters_method { + select 1 + from acs_sc_impl_aliases + where impl_id = :impl_id + and impl_operation_name = 'GetParameters' + } -default "0"] + + if { $method_exists_p } { + # call GetParameters on the impl and return that + return [acs_sc::invoke \ + -contract $contract \ + -impl $impl \ + -operation GetParameters] + } else { + # GetParameters method doesn't exist, throw an aa error + aa_true "Does the GetParameter exist?" 0 + } +} + +ad_proc -public auth::driver::get_parameter_values { + {-impl_id:required} + {-authority_id:required} +} { + Gets a list of parameter values ready to be passed to a service contract implementation. + If a parameter doesn't have a value, the value will be the empty string. + + @author Simon Carstensen (simon@collaboraid.biz) + @creation-date 2003-08-27 +} { + return [db_list select_values { + select value + from auth_driver_params + where impl_id = :impl_id + and authority_id = :authority_id + }] +} + +ad_proc -public auth::driver::set_parameter_value { + {-impl_id:required} + {-authority_id:required} + {-parameter:required} + {-value:required} +} { + Updates the parameter value in the database. + + @author Simon Carstensen (simon@collaboraid.biz) + @creation-date 2003-08-27 +} { + db_dml set_parameter { + update auth_driver_params + set value = :value + where key = :parameter + and impl_id = :impl_id + and authority_id = :authority_id + } +} Index: openacs-4/packages/acs-authentication/tcl/test/acs-authentication-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/test/acs-authentication-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-authentication/tcl/test/acs-authentication-procs.tcl 27 Aug 2003 13:10:15 -0000 1.5 +++ openacs-4/packages/acs-authentication/tcl/test/acs-authentication-procs.tcl 27 Aug 2003 15:48:23 -0000 1.6 @@ -429,6 +429,108 @@ } +aa_register_case auth_driver_get_parameters { + Test the auth::driver::get_parameters proc. + + @author Simon Carstensen (simon@collaboraid.biz) +} { + aa_run_with_teardown \ + -rollback \ + -test_code { + set impl_id [db_string select_impl_id { + select auth_impl_id + from auth_authorities + where short_name = 'local' + }] + + set parameters [auth::driver::get_parameters -impl_id $impl_id] + + aa_true "List of parameters should be empty for local authority" [empty_string_p $parameters] + + } +} + +aa_register_case auth_driver_get_parameter_values { + Test the auth::driver::set_parameter_values proc. + + @author Simon Carstensen (simon@collaboraid.biz) +} { + aa_run_with_teardown \ + -rollback \ + -test_code { + db_1row select_vars { + select auth_impl_id as impl_id, + authority_id + from auth_authorities + where short_name = 'local' + } + + set key "foo" + set value "bar" + + db_dml insert_test_parameter { + insert into auth_driver_params( + impl_id, authority_id, key, value + ) values ( + :impl_id, :authority_id, :key, :value + ) + } + + set values [auth::driver::get_parameter_values \ + -impl_id $impl_id \ + -authority_id $authority_id] + + aa_true "Did get_parameter return the correct value?" [string equal $values "bar"] + } +} + +aa_register_case auth_driver_set_parameter_value { + Test the auth::driver::set_parameter_value proc. + + @author Simon Carstensen (simon@collaboraid.biz) +} { + aa_run_with_teardown \ + -rollback \ + -test_code { + + db_1row select_vars { + select auth_impl_id as impl_id, + authority_id + from auth_authorities + where short_name = 'local' + } + + set key "foo" + set value "bar" + + db_dml insert_test_parameter { + insert into auth_driver_params ( + impl_id, authority_id, key, value + ) values ( + :impl_id, :authority_id, :key, :value + ) + } + + set new_value "new_bar" + + auth::driver::set_parameter_value \ + -impl_id $impl_id \ + -authority_id $authority_id \ + -parameter $key \ + -value $new_value + + set actual_value [db_string select_value { + select value + from auth_driver_params + where impl_id = :impl_id + and authority_id = :authority_id + and key = :key + }] + + aa_equals "Value should be $new_value after update" $new_value $actual_value + } +} + ##### # # Helper procs