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.19 -r1.20
--- openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl	8 Sep 2003 15:59:43 -0000	1.19
+++ openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl	9 Sep 2003 07:42:35 -0000	1.20
@@ -639,6 +639,7 @@
         element_messages {}
         account_status ok
         account_message {}
+        user_id {}
     }
 
     # PHASE II: This needs to be controlled by a parameter
@@ -777,6 +778,7 @@
         update_status update_error
         update_message {}
         element_messages {}
+        user_id {}
     }
 
     # Validate data
@@ -809,7 +811,10 @@
             set $varname $user_info($varname)
         }
     }
+    
+    # We get user_id from validate_user_info above, and set it in the result array so our caller can get it
     set user_id $user_info(user_id)
+    set result(user_id) $user_id
 
     set error_p 0
     with_catch errmsg {
@@ -878,6 +883,7 @@
     array set result {
         delete_status ok
         delete_message {}
+        user_id {}
     }
 
     set user_id [acs_user::get_by_username \
@@ -893,6 +899,8 @@
     # Mark the account banned
     acs_user::ban -user_id $user_id
 
+    set result(user_id) $user_id
+
     return [array get result]
 }
 
@@ -947,7 +955,7 @@
         set user(email) [string tolower $user(email)]
     }
     
-    if { ![exists_and_not_null $user(url)] || ([info exists user(url)] && [string equal $user(url) "http://"]) } {
+    if { ![exists_and_not_null user(url)] || ([info exists user(url)] && [string equal $user(url) "http://"]) } {
         # The user left the default hint for the url
         set user(url) {}
     } elseif { ![util_url_valid_p $user(url)] } {
Index: openacs-4/packages/acs-authentication/tcl/sync-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/sync-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-authentication/tcl/sync-procs.tcl	8 Sep 2003 15:59:43 -0000	1.1
+++ openacs-4/packages/acs-authentication/tcl/sync-procs.tcl	9 Sep 2003 07:42:35 -0000	1.2
@@ -271,6 +271,8 @@
                     if { ![string equal $result(creation_status) "ok"] } {
                         set result(message) $result(creation_message)
                         set success_p 0
+                    } else {
+                        set user_id $result(user_id)
                     }
 
                     # We ignore account_status
@@ -289,6 +291,8 @@
                     if { ![string equal $result(update_status) "ok"] } {
                         set result(message) $result(update_message)
                         set success_p 0
+                    } else {
+                        set user_id $result(user_id)
                     }
                 }
                 "delete" {
@@ -299,6 +303,8 @@
                     if { ![string equal $result(delete_status) "ok"] } {
                         set result(message) $result(delete_message)
                         set success_p 0
+                    } else {
+                        set user_id $result(user_id)
                     }
                 }
             }
Index: openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl	8 Sep 2003 15:59:43 -0000	1.1
+++ openacs-4/packages/acs-authentication/tcl/test/sync-test-procs.tcl	9 Sep 2003 07:42:36 -0000	1.2
@@ -13,11 +13,6 @@
         -rollback \
         -test_code {
             
-
-            # TODO: Add checks that the user info actually look the way it's supposed to ... use the acs_user::get API to verify
-
-
-
             # Start non-interactive job
             
             set job_id [auth::sync::job::start \
@@ -54,32 +49,96 @@
                 -message "A problem" \
                 -element_messages ""
 
+
+            # End job
+            array set job [auth::sync::job::end -job_id $job_id]
+            
+            aa_true "Elapsed time less than 30 seconds" [expr $job(run_time_seconds) < 30]
+
+            aa_log "Elapsed time: $job(run_time_seconds) seconds"
+
+            aa_false "Not interactive" [template::util::is_true $job(interactive_p)]
+
+            aa_equals "Number of actions" $job(num_actions) 2
+
+            aa_equals "Number of problems" $job(num_problems) 1
+            
+            aa_false "Log URL non-empty" [empty_string_p $job(log_url)]
+            
+            
+        }
+}
+
+aa_register_case job_actions {
+    Test starting and ending a batch job
+} {    
+    aa_run_with_teardown \
+        -rollback \
+        -test_code {
+            
+
+            # TODO: Add checks that the user info actually look the way it's supposed to ... use the acs_user::get API to verify
+
+
+
+            # Start non-interactive job
+            
+            set job_id [auth::sync::job::start \
+                            -authority_id [auth::authority::local]]
+                            
+            aa_true "Returns a job_id" [exists_and_not_null job_id]
+
+            #####
+            #
             # Valid insert action
+            #
+            #####
+
             set username1 [ad_generate_random_string]
             set email1 "[ad_generate_random_string]@foo.bar"
+            set first_names1 [ad_generate_random_string]
+            set last_name1 [ad_generate_random_string]
+            set url1 "http://[ad_generate_random_string].com"
             aa_log "--- Valid insert --- auth::sync::job::action -opration insert -username $username1 -email $email1"
             set entry_id [auth::sync::job::action \
                               -job_id $job_id \
                               -operation "insert" \
                               -authority_id [auth::authority::local] \
                               -username $username1 \
-                              -first_names [ad_generate_random_string] \
-                              -last_name [ad_generate_random_string] \
-                              -email $email1]
+                              -first_names $first_names1 \
+                              -last_name $last_name1 \
+                              -email $email1 \
+                              -url $url1]
 
             array unset entry
             auth::sync::job::get_entry \
                 -entry_id $entry_id \
                 -array entry
 
             aa_equals "entry.success_p" $entry(success_p) "t"
-            aa_equals "entry.message" $entry(message) {}
+            aa_equals "entry.message" $entry(message) {} 
             aa_equals "entry.element_messages" $entry(element_messages) {}
             aa_log "entry.user_id = '$entry(user_id)'"
             aa_log "entry.message = '$entry(message)'"
             aa_log "entry.element_messages = '$entry(element_messages)'"
+
+            if { [aa_true "Entry has user_id set" [exists_and_not_null entry(user_id)]] } {
+                acs_user::get -user_id $entry(user_id) -array user
+                
+                aa_equals "user.first_names" $user(first_names) $first_names1
+                aa_equals "user.last_name" $user(last_name) $last_name1
+                aa_equals "user.email" $user(email) [string tolower $email1]
+                aa_equals "user.authority_id" $user(authority_id) [auth::authority::local]
+                aa_equals "user.username" $user(username) $username1
+                aa_equals "user.url" $user(url) $url1
+            }
             
+            #####
+            #
             # Invalid insert action: Reusing username, email
+            #
+            #####
+
             aa_log "--- Invalid insert: reusing username, email --- auth::sync::job::action -opration insert -username $username1 -email $email1"
             set entry_id [auth::sync::job::action \
                               -job_id $job_id \
@@ -88,7 +147,8 @@
                               -username $username1 \
                               -first_names [ad_generate_random_string] \
                               -last_name [ad_generate_random_string] \
-                              -email $email1]
+                              -email $email1 \
+                              -url "http://"]
 
             array unset entry
             auth::sync::job::get_entry \
@@ -107,16 +167,26 @@
             aa_log "entry.message = '$entry(message)'"
             aa_log "entry.element_messages = '$entry(element_messages)'"
             
+            #####
+            #
             # Valid update action
+            #
+            #####
+
+            set email2 "[ad_generate_random_string]@foo.bar"
+            set first_names2 [ad_generate_random_string]
+            set last_name2 [ad_generate_random_string]
+            set url2 "http://[ad_generate_random_string].com"
             aa_log "--- Valid update --- auth::sync::job::action -opration update -username $username1"
             set entry_id [auth::sync::job::action \
                               -job_id $job_id \
                               -operation "update" \
                               -authority_id [auth::authority::local] \
                               -username $username1 \
-                              -first_names [ad_generate_random_string] \
-                              -last_name [ad_generate_random_string] \
-                              -email "[ad_generate_random_string]@foo.bar"]
+                              -first_names $first_names2 \
+                              -last_name $last_name2 \
+                              -email $email2 \
+                              -url $url2]
 
             array unset entry
             auth::sync::job::get_entry \
@@ -130,8 +200,23 @@
             aa_log "entry.message = '$entry(message)'"
             aa_log "entry.element_messages = '$entry(element_messages)'"
 
+            if { [aa_true "Entry has user_id set" [exists_and_not_null entry(user_id)]] } {
+                acs_user::get -user_id $entry(user_id) -array user
+                
+                aa_equals "user.first_names" $user(first_names) $first_names2
+                aa_equals "user.last_name" $user(last_name) $last_name2
+                aa_equals "user.email" $user(email) [string tolower $email2]
+                aa_equals "user.authority_id" $user(authority_id) [auth::authority::local]
+                aa_equals "user.username" $user(username) $username1
+                aa_equals "user.url" $user(url) $url2
+            }
 
-            # Invalid insert action: Missing first_names, last_name invalid, email invalid
+            #####
+            #
+            # Invalid insert action: Missing first_names, last_name invalid, email, url invalid
+            #
+            #####
+
             set username2 [ad_generate_random_string]
             aa_log "--- Invalid insert --- auth::sync::job::action -opration update -username $username2"
             set entry_id [auth::sync::job::action \
@@ -141,7 +226,8 @@
                               -username $username2 \
                               -first_names {} \
                               -last_name {<b>Foobar</b>} \
-                              -email "not_an_email"]
+                              -email "not_an_email" \
+                              -url "NotAURL"]
 
             array unset entry
             auth::sync::job::get_entry \
@@ -155,7 +241,7 @@
                 array unset elm_msgs
                 array set elm_msgs $entry(element_messages)
                 aa_log "array names elm_msgs = '[array names elm_msgs]'"
-                aa_true "first_names, last_name, email have problems" [util_sets_equal_p { first_names last_name email } [array names elm_msgs]]
+                aa_true "first_names, last_name, email, url have problems" [util_sets_equal_p { first_names last_name email url } [array names elm_msgs]]
             }
 
             # End job
@@ -165,13 +251,12 @@
 
             aa_false "Not interactive" [template::util::is_true $job(interactive_p)]
 
-            aa_equals "Number of actions" $job(num_actions) 6
+            aa_equals "Number of actions" $job(num_actions) 4
 
-            aa_equals "Number of problems" $job(num_problems) 3
-            
+            aa_equals "Number of problems" $job(num_problems) 2
+           
             aa_false "Log URL non-empty" [empty_string_p $job(log_url)]
             
-            
         }
 }