#include <fcntl.h>
#define TEST_SOCKET "./auth-client-test"
+#define CLIENT_PROGRESS_TIMEOUT 30
/*
* Types
* Test client
*/
+struct timeout *to_client_progress = NULL;
+
static void test_client_deinit(void)
{
}
string_t *resp_b64;
const char *errormsg = NULL;
+ if (to_client_progress != NULL)
+ timeout_reset(to_client_progress);
+
switch (status) {
case AUTH_REQUEST_STATUS_ABORT:
errormsg = "Abort";
{
struct login_request *login_req = context;
+ if (to_client_progress != NULL)
+ timeout_reset(to_client_progress);
+
if (login_req->status == 0 && !connected) {
i_assert(login_req->error == NULL);
login_req->error = i_strdup("Connection failed");
io_loop_stop(login_req->ioloop);
}
+static void
+test_client_progress_timeout(void *context ATTR_UNUSED)
+{
+ /* Terminate test due to lack of progress */
+ test_assert(FALSE);
+ timeout_remove(&to_client_progress);
+ io_loop_stop(current_ioloop);
+}
+
static int
test_client_auth_simple(const char *mech, const char *username,
const char *password, const char **error_r)
login_req.username = username;
login_req.password = password;
+ to_client_progress = timeout_add(CLIENT_PROGRESS_TIMEOUT*1000,
+ test_client_progress_timeout, NULL);
+
auth_client = auth_client_init(TEST_SOCKET, 2234, debug);
auth_client_set_connect_timeout(auth_client, 1000);
auth_client_connect(auth_client);
*error_r = t_strdup(login_req.error);
auth_client_deinit(&auth_client);
+ timeout_remove(&to_client_progress);
io_loop_destroy(&ioloop);
i_free(login_req.error);