/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2014 Red Hat
SSSD tests: Resolver tests using a fake resolver library
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 <stdarg.h>
#include <stdlib.h>
#include "providers/fail_over_srv.h"
#include "tests/cmocka/common_mock.h"
#include "tests/cmocka/common_mock_resp.h"
struct resolv_ctx {
int foo;
};
/* mock resolver interface. The resolver test is separate */
{
return EOK;
}
struct tevent_req *
enum restrict_family family_order,
enum host_database *db)
{
}
struct resolv_hostent **rhostent)
{
return test_request_recv(req);
}
{
return NULL;
}
struct tevent_context *ev,
struct resolv_ctx *resolv_ctx,
const char *service,
const char *protocol,
const char **discovery_domains)
{
}
struct tevent_req *req,
struct ares_srv_reply **_reply_list,
char **_dns_domain)
{
char *dns_domain;
/* Need to always consume all mocked values */
dns_domain = sss_mock_ptr_type(char *);
if (_reply_list != NULL) {
}
}
if (_dns_domain != NULL) {
}
return test_request_recv(req);
}
{
lowest = *r;
}
}
iter = *r;
}
/* iter points to the lowest prio. Prev points to the item before */
if (prev) {
} else {
}
return lowest;
}
{
struct ares_srv_reply *r;
r = *reply;
return EOK;
}
do {
lowest = pop_lowest_prio(&r);
if (sorted) {
} else {
}
} while (r != NULL);
*reply = sorted_head;
return EOK;
}
struct tevent_context *ev,
struct resolv_ctx *resolv_ctx,
const char *hostname,
enum host_database *host_dbs,
enum restrict_family family_order)
{
}
struct tevent_req *req,
char **_dns_domain)
{
return test_request_recv(req);
}
/* The unit test */
struct test_fo_ctx {
int ttl;
int num_done;
};
{
}
{
struct test_fo_ctx);
return 0;
}
{
return 0;
}
{
bool ok;
"client.sssd.com", "sssd.local");
return 0;
}
{
return 0;
}
/* reply_list and dns_domain must be a talloc context so it can be used as
* talloc_steal argument later
*/
char *dns_domain)
{
}
int port,
const char *name)
{
}
}
struct ares_srv_reply *
{
struct ares_srv_reply *s;
if (s == NULL) {
return NULL;
}
talloc_free(s);
return NULL;
}
return s;
}
int ttl)
{
char *dns_domain;
}
{
}
{
}
{
/* ldap1.sssd.com has lower priority, it must always be first */
/* Mark the server as working and request the service again. The same server
* must be returned */
}
{
/* Must be ldap1 again */
/* Mark it at wrong, next lookup should yield ldap2 */
}
{
/* Must be ldap2 now */
/* Mark is at wrong, next lookup must reach the end of the server list */
}
{
/* No servers are left..*/
/* reset the server status and try again.. */
}
}
{
/* ldap1.sssd.com has lower priority, it must always be first */
/* OK, we made a full circle with the test, done */
}
/* Make sure that two queries more than TTL seconds apart resolve
* into two different lists
*/
{
}
{
true);
}
{
char *dns_domain;
/* Simulate changing the DNS environment. Change the host names */
}
{
char *dns_domain;
/* Try accessing server from a previous iteration. The
* server should be collapsed, but at least we shouldn't crash
*/
/* Must be a different server now */
/* Simulate changing the DNS environment. Change the host names */
}
{
/* Must be a different server now */
}
{
}
{
}
/* Test that running two parallel SRV queries doesn't return an error.
* This is a regression test for https://fedorahosted.org/sssd/ticket/3131
*/
{
true);
}
{
const char *name;
}
}
{
int rv;
int opt;
};
};
/* Set debug level to invalid value so we can decide 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 */
return rv;
}