set timeout 40

load_lib "helpers.exp"

global spawn_id

proc expired {} {
    global spawn_id server_id

    start_client expired expired testuser notathena -1m 100
    eof_client expired expired $spawn_id 2

    expect {
	-i $server_id
	-re "rpc_test server: Authen.*failed: .* referenced credentials have expired" { pass "expired" }
	timeout { fail "expired: timeout waiting for expired creds error" }
    }

    flush_server
}
expired

proc overlap {} {
    global spawn_id

    start_client expire 1 testuser notathena 20m 100
    set client1_id $spawn_id
    flush_server
    
    start_client expire 2 testuser notathena 40m 300
    set client2_id $spawn_id
    flush_server
    
    start_client expire 3 testuser notathena 60m 500
    set client3_id $spawn_id
    flush_server
    
    eof_client expire 1 $client1_id 0
    eof_client expire 2 $client2_id 0
    eof_client expire 3 $client3_id 0

    flush_server
}
overlap


