test-utils

## test-utils test-utils — Utility routines for libexchange test programs |

## Synopsis

    void                test_main                           (gint argc,
                                                             gchar **argv);
    void                test_quit                           (void);
    void                test_abort_if_http_error            (E2kHTTPStatus status);

    gchar *             test_ask_password                   (const gchar *prompt);
    const gchar *       test_get_password                   (const gchar *user,
                                                             const gchar *host);
    E2kContext *        test_get_context                    (const gchar *uri);
    E2kGlobalCatalog *  test_get_gc                         (const gchar *server);

## Description

## Details

### test_main ()

    void                test_main                           (gint argc,
                                                             gchar **argv);

test-utils.o includes a `main()` function that calls various initialization routines, starts the main loop, and then calls `test_main()`. So `test_main()` is the entry point for a test-utils-using program.

`argc` : | argc
`argv` : | argv

### test_quit ()

    void                test_quit                           (void);

Cleanly quits a test program.

### test_abort_if_http_error ()

    void                test_abort_if_http_error            (E2kHTTPStatus status);

Checks if `status` is an HTTP or libsoup error, and if so, prints the error message and exits.

`status` : | an HTTP status code

### test_ask_password ()

    gchar *             test_ask_password                   (const gchar *prompt);

Prints `prompt` followed by ": " and waits for the user to type a password (with echoing disabled).

`prompt` : | prompt string
Returns : | the password (or `NULL` if stdin is not a tty).

### test_get_password ()

    const gchar *       test_get_password                   (const gchar *user,
                                                             const gchar *host);

Tries to get a password for `user` on `host`, by looking it up in the Evolution password database or by prompting the user.

`user` : | username to get the password for
`host` : | Exchange (or global catalog) server name
Returns : | the password, or `NULL` if it could not be determined.

### test_get_context ()

    E2kContext *        test_get_context                    (const gchar *uri);

Creates an `E2kContext` based on `uri`. If `uri` does not contain a username, the user's local username will be used. If it does not contain a password, `test_get_password()` will be called to get one.

`uri` : | an Exchange HTTP/HTTPS URI
Returns : | the new `E2kContext` (always; if an error occurs, `test_get_context()` will exit the program).

### test_get_gc ()

    E2kGlobalCatalog *  test_get_gc                         (const gchar *server);

Creates an `E2kGlobalCatalog` for the server `server`. `test_get_password()` will be called to get a password.

`server` : | the global catalog server to contact
Returns : | the new `E2kGlobalCatalog` (always; if an error occurs, `test_get_gc()` will exit the program).