test_dyndns.c revision aa3fd6fde3888c0e333cad852ae5b4f671d55f58
/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2013 Red Hat
SSSD tests: Dynamic DNS tests
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <talloc.h>
#include <tevent.h>
#include <errno.h>
#include <popt.h>
#include <unistd.h>
#include <ifaddrs.h>
/* In order to access opaque types */
#include "providers/dp_dyndns.c"
#include "tests/cmocka/common_mock.h"
#include "tests/cmocka/common_mock_be.h"
#include "src/providers/dp_dyndns.h"
#define TESTS_PATH "tests_dyndns"
#define TEST_CONF_DB "test_dyndns_conf.ldb"
#define TEST_DOM_NAME "dyndns_test"
#define TEST_ID_PROVIDER "ldap"
enum mock_nsupdate_states {
};
struct dyndns_test_ctx {
struct sss_test_ctx *tctx;
struct be_nsupdate_ctx *update_ctx;
enum mock_nsupdate_states state;
int child_status;
int child_retval;
};
static struct dyndns_test_ctx *dyndns_test_ctx;
{
int err;
switch (dyndns_test_ctx->state) {
case MOCK_NSUPDATE_OK:
err = 0;
break;
case MOCK_NSUPDATE_ERR:
err = 1;
break;
case MOCK_NSUPDATE_TIMEOUT:
err = 2;
sleep(3);
break;
default:
err = 255;
break;
}
}
{
char *name;
char *straddr;
struct sockaddr_in *sa;
straddr = sss_mock_ptr_type(char *);
goto fail;
}
goto fail;
}
if (ifap_prev) {
} else {
}
goto fail;
}
/* Do not alocate directly on ifap->ifa_addr to
* avoid alignment warnings */
goto fail;
}
/* convert straddr into ifa_addr */
goto fail;
}
}
return 0;
fail:
return -1;
}
{
}
{
struct dyndns_test_ctx *ctx =
}
{
if (ifname) {
}
}
void dyndns_test_get_ifaddr(void **state)
{
struct sss_iface_addr *addrlist;
char straddr[128];
/* There must be only one address with the correct value */
}
void dyndns_test_get_multi_ifaddr(void **state)
{
struct sss_iface_addr *addrlist;
struct sss_iface_addr *sss_if_addr;
char straddr[128];
/* ip addresses are returned in different order */
/* ip addresses are returned in different order */
}
void dyndns_test_get_ifaddr_enoent(void **state)
{
&addrlist);
}
void dyndns_test_ok(void **state)
{
struct tevent_req *req;
discard_const("test message"), false);
/* Wait until the test finishes with EOK */
}
void dyndns_test_error(void **state)
{
struct tevent_req *req;
discard_const("test message"), false);
/* Wait until the test finishes with EIO (child error) */
}
void dyndns_test_timeout(void **state)
{
struct tevent_req *req;
discard_const("test message"), false);
/* Wait until the test finishes with EIO (child error) */
/* The event queue may not be empty. We need to make sure that all events
* are processed. Unfortunately, tevent_loop_wait() contains a bug that
* prevents exiting the loop even if there are no remaining events, thus
* we have to use tevent_loop_once().
*
* FIXME: use tevent_loop_wait() when the bug is fixed
*/
}
void dyndns_test_timer(void *pvt)
{
static int ncalls = 0;
ncalls++;
if (ncalls == 1) {
} else if (ncalls == 2) {
}
}
void dyndns_test_interval(void **state)
{
/* Wait until the timer hits */
}
/* Testsuite setup and teardown */
static int dyndns_test_setup(void **state)
{
struct sss_test_conf_param params[] = {
{ "dyndns_update", "true" },
{ "dyndns_refresh_interval", "2" },
};
return 0;
}
static int dyndns_test_simple_setup(void **state)
{
return 0;
}
static int dyndns_test_teardown(void **state)
{
return 0;
}
{
int rv;
int no_cleanup = 0;
int opt;
struct poptOption long_options[] = {
_("Do not delete the test database after a test run"), NULL },
};
const struct CMUnitTest tests[] = {
/* Utility functions unit test */
/* Dynamic DNS update unit tests*/
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
/* Even though normally the tests should clean up after themselves
* they might not after a failed run. Remove the old db to be sure */
if (rv == 0 && !no_cleanup) {
}
return rv;
}