| |
63 |
63 |
-user_id [ad_conn user_id] \ |
| |
64 |
64 |
-success |
| |
65 |
65 |
|
| |
66 |
66 |
# Valid unsuccessful log entry |
| |
67 |
67 |
auth::sync::job::create_entry \ |
| |
68 |
68 |
-job_id $job_id \ |
| |
69 |
69 |
-operation "insert" \ |
| |
70 |
70 |
-username "foobar" \ |
| |
71 |
71 |
-user_id [ad_conn user_id] \ |
| |
72 |
72 |
-message "A problem" \ |
| |
73 |
73 |
-element_messages "" |
| |
74 |
74 |
|
| |
75 |
75 |
|
| |
76 |
76 |
# End job |
| |
77 |
77 |
array set job [auth::sync::job::end -job_id $job_id] |
| |
78 |
78 |
|
| |
79 |
79 |
aa_true "Elapsed time less than 30 seconds" {$job(run_time_seconds) < 30} |
| |
80 |
80 |
|
| |
81 |
81 |
aa_log "Elapsed time: $job(run_time_seconds) seconds" |
| |
82 |
82 |
|
| |
83 |
|
aa_false "Not interactive" [template::util::is_true $job(interactive_p)] |
| |
|
83 |
aa_false "Not interactive" [string is true -strict $job(interactive_p)] |
| |
84 |
84 |
|
| |
85 |
85 |
aa_equals "Number of actions" $job(num_actions) 2 |
| |
86 |
86 |
|
| |
87 |
87 |
aa_equals "Number of problems" $job(num_problems) 1 |
| |
88 |
88 |
|
| |
89 |
89 |
aa_false "Log URL nonempty" {$job(log_url) eq ""} |
| |
90 |
90 |
|
| |
91 |
91 |
# Purge not deleting the job |
| |
92 |
92 |
auth::sync::purge_jobs \ |
| |
93 |
93 |
-num_days 1 |
| |
94 |
94 |
|
| |
95 |
95 |
aa_equals "Job still exists" [db_string job_exists_p { select count(*) from auth_batch_job_entries where job_id = :job_id }] 2 |
| |
96 |
96 |
|
| |
97 |
97 |
# Tricking it into deleting the job |
| |
98 |
98 |
aa_log "Updating the job end time" |
| |
99 |
99 |
db_dml update_job { update auth_batch_jobs set job_end_time = to_date('1974-03-27', 'YYYY-MM-DD') where job_id = :job_id } |
| |
100 |
100 |
auth::sync::purge_jobs \ |
| |
101 |
101 |
-num_days 1 |
| |
102 |
102 |
|
| |
103 |
103 |
aa_equals "Job has been purged" [db_string job_exists_p { select count(*) from auth_batch_job_entries where job_id = :job_id }] 0 |
|
| |
343 |
343 |
aa_equals "entry.success_p" $entry(success_p) "t" |
| |
344 |
344 |
aa_log "entry.message = '$entry(message)'" |
| |
345 |
345 |
|
| |
346 |
346 |
if { [aa_true "Entry has user_id set" {[info exists entry(user_id)] && $entry(user_id) ne ""}] } { |
| |
347 |
347 |
set member_state [acs_user::get_user_info \ |
| |
348 |
348 |
-user_id $entry(user_id) -element "member_state"] |
| |
349 |
349 |
aa_equals "User member state is banned" $member_state "banned" |
| |
350 |
350 |
} |
| |
351 |
351 |
|
| |
352 |
352 |
|
| |
353 |
353 |
##### |
| |
354 |
354 |
# |
| |
355 |
355 |
# End job |
| |
356 |
356 |
# |
| |
357 |
357 |
##### |
| |
358 |
358 |
|
| |
359 |
359 |
array set job [auth::sync::job::end -job_id $job_id] |
| |
360 |
360 |
|
| |
361 |
361 |
aa_true "Elapsed time less than 30 seconds" {$job(run_time_seconds) < 30} |
| |
362 |
362 |
|
| |
363 |
|
aa_false "Not interactive" [template::util::is_true $job(interactive_p)] |
| |
|
363 |
aa_false "Not interactive" [string is true -strict $job(interactive_p)] |
| |
364 |
364 |
|
| |
365 |
365 |
aa_equals "Number of actions" $job(num_actions) 6 |
| |
366 |
366 |
|
| |
367 |
367 |
aa_equals "Number of problems" $job(num_problems) 2 |
| |
368 |
368 |
|
| |
369 |
369 |
aa_false "Log URL nonempty" {$job(log_url) eq ""} |
| |
370 |
370 |
|
| |
371 |
371 |
} |
| |
372 |
372 |
} |
| |
373 |
373 |
|
| |
374 |
374 |
aa_register_case \ |
| |
375 |
375 |
-cats {api db} \ |
| |
376 |
376 |
-procs { |
| |
377 |
377 |
acs_user::get |
| |
378 |
378 |
ad_generate_random_string |
| |
379 |
379 |
auth::authority::local |
| |
380 |
380 |
auth::sync::job::action |
| |
381 |
381 |
auth::sync::job::end |
| |
382 |
382 |
auth::sync::job::get_entry |
| |
383 |
383 |
auth::sync::job::snapshot_delete_remaining |
|
| |
494 |
494 |
set num_users_not_banned [db_string select_num { |
| |
495 |
495 |
select count(*) |
| |
496 |
496 |
from cc_users |
| |
497 |
497 |
where authority_id = :authority_id |
| |
498 |
498 |
and member_state != 'banned' |
| |
499 |
499 |
}] |
| |
500 |
500 |
|
| |
501 |
501 |
auth::sync::job::snapshot_delete_remaining \ |
| |
502 |
502 |
-job_id $job_id |
| |
503 |
503 |
|
| |
504 |
504 |
##### |
| |
505 |
505 |
# |
| |
506 |
506 |
# End job |
| |
507 |
507 |
# |
| |
508 |
508 |
##### |
| |
509 |
509 |
|
| |
510 |
510 |
array set job [auth::sync::job::end -job_id $job_id] |
| |
511 |
511 |
|
| |
512 |
512 |
aa_true "Elapsed time less than 30 seconds" {$job(run_time_seconds) < 30} |
| |
513 |
513 |
|
| |
514 |
|
aa_false "Not interactive" [template::util::is_true $job(interactive_p)] |
| |
|
514 |
aa_false "Not interactive" [string is true -strict $job(interactive_p)] |
| |
515 |
515 |
|
| |
516 |
516 |
aa_equals "Number of actions" $job(num_actions) [expr {$num_users_not_banned + 1}] |
| |
517 |
517 |
|
| |
518 |
518 |
aa_equals "Number of problems" $job(num_problems) 0 |
| |
519 |
519 |
|
| |
520 |
520 |
aa_false "Log URL nonempty" {$job(log_url) eq ""} |
| |
521 |
521 |
|
| |
522 |
522 |
} |
| |
523 |
523 |
} |
| |
524 |
524 |
|
| |
525 |
525 |
|
| |
526 |
526 |
aa_register_case \ |
| |
527 |
527 |
-cats {api smoke} \ |
| |
528 |
528 |
-procs { |
| |
529 |
529 |
auth::authority::batch_sync |
| |
530 |
530 |
auth::authority::local |
| |
531 |
531 |
auth::sync::job::get |
| |
532 |
532 |
} \ |
| |
533 |
533 |
sync_batch_for_local { |
| |
534 |
534 |
Test a batch job for the local authority |
|
| |
696 |
696 |
|
| |
697 |
697 |
set new_auth(get_doc_impl_id) [acs_sc::impl::get_id -owner "acs-authentication" -name "HTTPGet"] |
| |
698 |
698 |
|
| |
699 |
699 |
set authority_id [auth::authority::create \ |
| |
700 |
700 |
-array new_auth] |
| |
701 |
701 |
|
| |
702 |
702 |
set job_id [auth::authority::batch_sync -authority_id $authority_id] |
| |
703 |
703 |
|
| |
704 |
704 |
auth::sync::job::get -job_id $job_id -array job |
| |
705 |
705 |
|
| |
706 |
706 |
aa_equals "Number of actions" $job(num_actions) 3 |
| |
707 |
707 |
|
| |
708 |
708 |
aa_equals "Number of problems" $job(num_problems) 3 |
| |
709 |
709 |
|
| |
710 |
710 |
foreach entry_id [auth::sync::job::get_entries -job_id $job_id] { |
| |
711 |
711 |
array unset entry |
| |
712 |
712 |
auth::sync::job::get_entry \ |
| |
713 |
713 |
-entry_id $entry_id \ |
| |
714 |
714 |
-array entry |
| |
715 |
715 |
|
| |
716 |
|
aa_false "Success_p is false" [template::util::is_true $entry(success_p)] |
| |
|
716 |
aa_false "Success_p is false" [string is true -strict $entry(success_p)] |
| |
717 |
717 |
|
| |
718 |
718 |
array unset elm_msgs |
| |
719 |
719 |
array set elm_msgs $entry(element_messages) |
| |
720 |
720 |
|
| |
721 |
721 |
aa_log "entry.operation = '$entry(operation)'" |
| |
722 |
722 |
aa_log "entry.username = '$entry(username)'" |
| |
723 |
723 |
aa_log "entry.message = '$entry(message)'" |
| |
724 |
724 |
aa_log "array names elm_msgs = '[array names elm_msgs]'" |
| |
725 |
725 |
|
| |
726 |
726 |
switch $entry(operation) { |
| |
727 |
727 |
insert { |
| |
728 |
728 |
aa_true "email has a problem (email missing)" [util_sets_equal_p { email } [array names elm_msgs]] |
| |
729 |
729 |
} |
| |
730 |
730 |
update { |
| |
731 |
731 |
aa_true "User does not exist" {$entry(message) ne ""} |
| |
732 |
732 |
} |
| |
733 |
733 |
delete { |
| |
734 |
734 |
aa_false "Message is not empty" {$entry(message) eq ""} |
| |
735 |
735 |
} |
| |
736 |
736 |
} |