mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
A second test case for dns_resolve_impl.
This commit is contained in:
parent
2fc841aacb
commit
1096f7638e
@ -1714,8 +1714,8 @@ router_compare_to_my_exit_policy(const tor_addr_t *addr, uint16_t port)
|
|||||||
|
|
||||||
/** Return true iff my exit policy is reject *:*. Return -1 if we don't
|
/** Return true iff my exit policy is reject *:*. Return -1 if we don't
|
||||||
* have a descriptor */
|
* have a descriptor */
|
||||||
int
|
MOCK_IMPL(int,
|
||||||
router_my_exit_policy_is_reject_star(void)
|
router_my_exit_policy_is_reject_star,(void))
|
||||||
{
|
{
|
||||||
if (!router_get_my_routerinfo()) /* make sure desc_routerinfo exists */
|
if (!router_get_my_routerinfo()) /* make sure desc_routerinfo exists */
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -80,7 +80,7 @@ void check_descriptor_ipaddress_changed(time_t now);
|
|||||||
void router_new_address_suggestion(const char *suggestion,
|
void router_new_address_suggestion(const char *suggestion,
|
||||||
const dir_connection_t *d_conn);
|
const dir_connection_t *d_conn);
|
||||||
int router_compare_to_my_exit_policy(const tor_addr_t *addr, uint16_t port);
|
int router_compare_to_my_exit_policy(const tor_addr_t *addr, uint16_t port);
|
||||||
int router_my_exit_policy_is_reject_star(void);
|
MOCK_DECL(int, router_my_exit_policy_is_reject_star,(void));
|
||||||
MOCK_DECL(const routerinfo_t *, router_get_my_routerinfo, (void));
|
MOCK_DECL(const routerinfo_t *, router_get_my_routerinfo, (void));
|
||||||
extrainfo_t *router_get_my_extrainfo(void);
|
extrainfo_t *router_get_my_extrainfo(void);
|
||||||
const char *router_get_my_descriptor(void);
|
const char *router_get_my_descriptor(void);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
#include "router.h"
|
||||||
|
|
||||||
#define NS_MODULE dns
|
#define NS_MODULE dns
|
||||||
|
|
||||||
@ -382,12 +383,38 @@ NS(test_main)(void *arg)
|
|||||||
|
|
||||||
#define NS_SUBMODULE ASPECT(resolve_impl, non_exit)
|
#define NS_SUBMODULE ASPECT(resolve_impl, non_exit)
|
||||||
|
|
||||||
|
/** Given that Tor instance is not configured as an exit node, we want
|
||||||
|
* dns_resolve_impl() to fail with return value -1.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
NS(router_my_exit_policy_is_reject_star)(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
NS(test_main)(void *arg)
|
NS(test_main)(void *arg)
|
||||||
{
|
{
|
||||||
tt_skip();
|
int retval;
|
||||||
|
int made_pending;
|
||||||
|
|
||||||
|
edge_connection_t *exitconn = create_valid_exitconn();
|
||||||
|
or_circuit_t *on_circ = tor_malloc_zero(sizeof(or_circuit_t));
|
||||||
|
|
||||||
|
TO_CONN(exitconn)->address = tor_strdup("torproject.org");
|
||||||
|
|
||||||
|
NS_MOCK(router_my_exit_policy_is_reject_star);
|
||||||
|
|
||||||
|
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
tt_int_op(retval,==,-1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
tor_free(TO_CONN(exitconn)->address);
|
||||||
|
tor_free(exitconn);
|
||||||
|
tor_free(on_circ);
|
||||||
|
NS_UNMOCK(router_my_exit_policy_is_reject_star);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user