Only STRICT synchronizations are allowed now.
This orphans --rsync.arguments-recursive, so it has been deprecated and
no-op'd as well.
Fixes #80.
"rsync": {
"enabled": true,
"priority": 50,
- "strategy": "root-except-ta",
"retry": {
"count": 2,
"interval": 5
Other configuration options can be configured exclusively at the JSON
configuration file:
.P
+
.B rsync.program
.RS 4
Name of the program needed to invoke an rsync file transfer. The default value
is "rsync".
.RE
.P
-.B rsync.arguments-recursive
-.RS 4
-Arguments needed by
-.B rsync.program
-to perform a recursive rsync. The arguments are specified as a JSON string
-array; its default value is:
-[ "--recursive", "--delete", "--times", "--contimeout=20", "--timeout=15",
-"$REMOTE", "$LOCAL" ]
-.P
-FORT will replace "$REMOTE" with the remote URL it needs to download, and
-"$LOCAL" with the target local directory where the file is supposed to be
-dropped.
-.P
-If \fBrsync.program\fR set is \fIrsync\fR (default value), see more about its
-arguments and behavior at \fIrsync(1)\fR.
-.RE
-.P
+
.B rsync.arguments-flat
.RS 4
Arguments needed by
arguments and behavior at \fIrsync(1)\fR.
.RE
.P
+
+.B rsync.arguments-recursive
+.RS 4
+Deprecated; does nothing.
+.RE
+.P
+
.B incidences
.RS 4
A listing of actions to be performed by validation upon encountering certain
.RS 4
.br
- Literally invoke an rsync command (see \fBrsync.program\fR and
-\fBrsync.arguments-recursive\fR), which will download the files into
+\fBrsync.arguments-flat\fR), which will download the files into
\fB--local-repository\fR.
.br
- Fetch the RRDP Update Notification file (which implies an HTTP request) and
.B \-\-rsync.strategy=(\fIstrict\fR|\fIroot\fR|\fIroot-except-ta\fR)
.RS 4
-\fIrsync\fR download strategy; states the way rsync URLs are approached during
-downloads. It can have one of three values:
-.IR strict ", "
-.IR root ", "
-.IB "root-except-ta" "(default value)" \fR. \fR
-.P
-.I strict
-.RS 4
-In order to enable this strategy, FORT must be compiled using the flag:
-ENABLE\_STRICT\_STRATEGY. e.g.
-\fB $ make FORT_FLAGS='-DENABLE_STRICT_STRATEGY'\fR
-.P
-RSYNC every repository publication point separately. Only skip publication
-points that have already been downloaded during the current validation cycle.
-(Assuming each synchronization is recursive.)
-.P
-For example, suppose the validator gets certificates whose caRepository access
-methods (in their Subject Information Access extensions) point to the following
-publication points:
-.P
-1. rsync://rpki.example.com/foo/bar/
-.br
-2. rsync://rpki.example.com/foo/qux/
-.br
-3. rsync://rpki.example.com/foo/bar/
-.br
-4. rsync://rpki.example.com/foo/corge/grault/
-.br
-5. rsync://rpki.example.com/foo/corge/
-.br
-6. rsync://rpki.example.com/foo/corge/waldo/
-.P
-A validator following the `strict` strategy would download `bar`, download
-`qux`, skip `bar`, download `corge/grault`, download `corge` and skip
-`corge/waldo`.
-.P
-This is the slowest, but also the strictly correct sync strategy.
-.RE
-.P
-.I root
-.RS 4
-For each publication point found, guess the root of its repository and RSYNC
-that instead. Then skip any subsequent children of said root.
-.P
-(To guess the root of a repository, the validator counts four slashes, and
-prunes the rest of the URL.)
-.P
-Reusing the caRepository URLs from the `strict` strategy (above) as example, a
-validator following the `root` strategy would download
-`rsync://rpki.example.com/foo`, and then skip everything else.
-.P
-Assuming that the repository is specifically structured to be found within as
-few roots as possible, and they contain minimal RPKI-unrelated noise files, this
-is the fastest synchronization strategy. At time of writing, this is true for
-all the current official repositories.
-.RE
-.P
-.I root-except-ta
-.RS 4
-Synchronizes the root certificate (the one pointed by the TAL) in 'strict' mode,
-and once it's validated, synchronizes the rest of the repository in 'root' mode.
-.P
-Useful if you want 'root', but the root certificate is separated from the rest
-of the repository. Also useful if you don't want the validator to download the
-entire repository without first confirming the integrity and legitimacy of the
-root certificate.
-.RE
+Deprecated; does nothing.
.RE
.P
"rsync": {
"enabled": true,
"priority": 50,
- "strategy": "root-except-ta",
"retry": {
"count": 2,
"interval": 5
},
"program": "rsync",
- "arguments-recursive": [
- "--recursive",
- "--delete",
- "--times",
- "--contimeout=20",
- "--timeout=15",
- "$REMOTE",
- "$LOCAL"
- ],
"arguments-flat": [
"--times",
"--contimeout=20",
fort_SOURCES += config/mode.c config/mode.h
fort_SOURCES += config/incidences.h config/incidences.c
fort_SOURCES += config/output_format.h config/output_format.c
-fort_SOURCES += config/rsync_strategy.h config/rsync_strategy.c
fort_SOURCES += config/str.c config/str.h
fort_SOURCES += config/string_array.h config/string_array.c
fort_SOURCES += config/types.h
*/
unsigned int priority;
/* Synchronization download strategy. */
- enum rsync_strategy strategy;
+ char *strategy;
/* Retry conf, utilized on errors */
struct {
/* Maximum number of retries on error */
}, {
.id = 3002,
.name = "rsync.strategy",
- .type = >_rsync_strategy,
+ .type = >_string,
.offset = offsetof(struct rpki_config, rsync.strategy),
- .doc = "RSYNC download strategy",
+ .doc = "Deprecated; does nothing.",
+ .deprecated = true,
}, {
.id = 3003,
.name = "rsync.retry.count",
.name = "rsync.arguments-recursive",
.type = >_string_array,
.offset = offsetof(struct rpki_config, rsync.args.recursive),
- .doc = "RSYNC program arguments that will trigger a recursive RSYNC",
+ .doc = "Deprecated; does nothing.",
.availability = AVAILABILITY_JSON,
/* Unlimited */
.max = 0,
static void
set_default_values(void)
{
- static char const *recursive_rsync_args[] = {
- "--recursive",
- "--delete",
- "--times",
- "--contimeout=20",
- "--timeout=15",
- "--max-size=20MB",
- "$REMOTE",
- "$LOCAL",
- };
-
+ static char const *recursive_rsync_args[] = { "<deprecated>" };
static char const *flat_rsync_args[] = {
"--times",
"--contimeout=20",
* duplicates.
*/
- string_array_init(&rpki_config.server.address, NULL, 0);
- rpki_config.server.port = pstrdup("323");
- rpki_config.server.backlog = SOMAXCONN;
- rpki_config.server.interval.validation = 3600;
- rpki_config.server.interval.refresh = 3600;
- rpki_config.server.interval.retry = 600;
- rpki_config.server.interval.expire = 7200;
- rpki_config.server.deltas_lifetime = 2;
-
rpki_config.tal = NULL;
rpki_config.local_repository = pstrdup("/tmp/fort/repository");
rpki_config.shuffle_tal_uris = false;
rpki_config.work_offline = false;
rpki_config.daemon = false;
+ string_array_init(&rpki_config.server.address, NULL, 0);
+ rpki_config.server.port = pstrdup("323");
+ rpki_config.server.backlog = SOMAXCONN;
+ rpki_config.server.interval.validation = 3600;
+ rpki_config.server.interval.refresh = 3600;
+ rpki_config.server.interval.retry = 600;
+ rpki_config.server.interval.expire = 7200;
+ rpki_config.server.deltas_lifetime = 2;
+
rpki_config.rsync.enabled = true;
rpki_config.rsync.priority = 50;
- rpki_config.rsync.strategy = RSYNC_ROOT_EXCEPT_TA;
+ rpki_config.rsync.strategy = pstrdup("<deprecated>");
rpki_config.rsync.retry.count = 1;
rpki_config.rsync.retry.interval = 4;
rpki_config.rsync.program = pstrdup("rsync");
string_array_init(&rpki_config.rsync.args.recursive,
recursive_rsync_args, ARRAY_LEN(recursive_rsync_args));
- /* By default, has a higher priority than rsync */
rpki_config.http.enabled = true;
+ /* Higher priority than rsync by default */
rpki_config.http.priority = 60;
rpki_config.http.retry.count = 1;
rpki_config.http.retry.interval = 4;
rpki_config.asn1_decode_max_stack = 4096; /* 4kB */
rpki_config.stale_repository_period = 43200; /* 12 hours */
rpki_config.init_tals = false;
+ rpki_config.init_tal0s = false;
rpki_config.thread_pool.server.max = 20;
rpki_config.thread_pool.validation.max = 5;
return rpki_config.rsync.priority;
}
-enum rsync_strategy
-config_get_rsync_strategy(void)
-{
- return rpki_config.rsync.strategy;
-}
-
unsigned int
config_get_rsync_retry_count(void)
{
}
struct string_array const *
-config_get_rsync_args(bool is_ta)
-{
- switch (rpki_config.rsync.strategy) {
- case RSYNC_ROOT:
- return &rpki_config.rsync.args.recursive;
- case RSYNC_ROOT_EXCEPT_TA:
- return is_ta
- ? &rpki_config.rsync.args.flat
- : &rpki_config.rsync.args.recursive;
- case RSYNC_STRICT:
- return &rpki_config.rsync.args.flat;
- default:
- break;
- }
-
- pr_crit("Invalid rsync strategy: '%u'", rpki_config.rsync.strategy);
+config_get_rsync_args(void)
+{
+ return &rpki_config.rsync.args.flat;
}
bool
#include "config/log_conf.h"
#include "config/mode.h"
#include "config/output_format.h"
-#include "config/rsync_strategy.h"
#include "config/string_array.h"
#include "config/types.h"
char const *config_get_http_ca_path(void);
bool config_get_rsync_enabled(void);
unsigned int config_get_rsync_priority(void);
-enum rsync_strategy config_get_rsync_strategy(void);
unsigned int config_get_rsync_retry_count(void);
unsigned int config_get_rsync_retry_interval(void);
char *config_get_rsync_program(void);
-struct string_array const *config_get_rsync_args(bool);
+struct string_array const *config_get_rsync_args(void);
bool config_get_http_enabled(void);
unsigned int config_get_http_priority(void);
unsigned int config_get_http_retry_count(void);
+++ /dev/null
-#include "config/rsync_strategy.h"
-
-#include <getopt.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "config.h"
-#include "log.h"
-#include "config/str.h"
-
-#define RSYNC_VALUE_STRICT "strict"
-#define RSYNC_VALUE_ROOT "root"
-#define RSYNC_VALUE_ROOT_EXCEPT_TA "root-except-ta"
-
-#define DEREFERENCE(void_value) (*((enum rsync_strategy *) void_value))
-
-#ifdef ENABLE_STRICT_STRATEGY
-#define PRINT_STRICT_ARG_DOC "|" RSYNC_VALUE_STRICT
-#define HANDLE_RSYNC_STRICT DEREFERENCE(result) = RSYNC_STRICT;
-#else
-#define PRINT_STRICT_ARG_DOC
-#define HANDLE_RSYNC_STRICT \
- return pr_op_err("Unknown rsync synchronization strategy: '%s'. In order to use it, recompile using flag ENABLE_STRICT_STRATEGY.",\
- str);
-#endif
-
-static void
-print_rsync_strategy(struct option_field const *field, void *value)
-{
- char const *str = "<unknown>";
-
- switch (DEREFERENCE(value)) {
- case RSYNC_STRICT:
- str = RSYNC_VALUE_STRICT;
- break;
- case RSYNC_ROOT:
- str = RSYNC_VALUE_ROOT;
- break;
- case RSYNC_ROOT_EXCEPT_TA:
- str = RSYNC_VALUE_ROOT_EXCEPT_TA;
- break;
- default:
- break;
- }
-
- pr_op_info("%s: %s", field->name, str);
-}
-
-static int
-parse_argv_rsync_strategy(struct option_field const *field, char const *str,
- void *result)
-{
- if (strcmp(str, RSYNC_VALUE_STRICT) == 0)
- HANDLE_RSYNC_STRICT
- else if (strcmp(str, RSYNC_VALUE_ROOT) == 0)
- DEREFERENCE(result) = RSYNC_ROOT;
- else if (strcmp(str, RSYNC_VALUE_ROOT_EXCEPT_TA) == 0)
- DEREFERENCE(result) = RSYNC_ROOT_EXCEPT_TA;
- else
- return pr_op_err("Unknown rsync synchronization strategy: '%s'",
- str);
-
- return 0;
-}
-
-static int
-parse_json_rsync_strategy(struct option_field const *opt, struct json_t *json,
- void *result)
-{
- char const *string;
- int error;
-
- error = parse_json_string(json, opt->name, &string);
- return error ? error : parse_argv_rsync_strategy(opt, string, result);
-}
-
-const struct global_type gt_rsync_strategy = {
- .has_arg = required_argument,
- .size = sizeof(enum rsync_strategy),
- .print = print_rsync_strategy,
- .parse.argv = parse_argv_rsync_strategy,
- .parse.json = parse_json_rsync_strategy,
- .arg_doc = RSYNC_VALUE_ROOT
- "|" RSYNC_VALUE_ROOT_EXCEPT_TA
- PRINT_STRICT_ARG_DOC,
-};
+++ /dev/null
-#ifndef SRC_CONFIG_RSYNC_STRATEGY_H_
-#define SRC_CONFIG_RSYNC_STRATEGY_H_
-
-#include "config/types.h"
-
-enum rsync_strategy {
- /**
- * Strictly correct download strategy.
- *
- * The validator will sync each repository publication point separately
- * as requested by each caRepository contained in the CA certificates'
- * SIA extensions.
- *
- * No risk of downloading unneeded files, but otherwise slow, as every
- * different repository publication point requires a separate sync call.
- *
- * In order to enable this strategy, compile using the flag:
- * ENABLE_STRICT_STRATEGY
- */
- RSYNC_STRICT,
- /**
- * Always download the likely root of the entire repository.
- *
- * For example, if we get the following caRepositories:
- *
- * - `rsync://a.b.c/d/e/f/g/h/i`
- * - `rsync://a.b.c/d/e/f/g/h/j`
- * - `rsync://a.b.c/d/e/f/k`
- *
- * This strategy will synchronize `rsync://a.b.c/d` while parsing the
- * first caRepository, and then skip synchronization during the second
- * and third ones. (Because they are already downloaded.)
- *
- * This strategy risks downloading unneeded files, and even failing due
- * to lack of read permissions on stray subdirectories. On the flip
- * side, if the repository holds no unnecessary subdirectories, then
- * this strategy is the fastest one, since it generally only requires
- * one sync call per domain, which often translates into one sync call
- * per validation cycle.
- *
- * Currently, all of the official repositories are actually specifically
- * structured to benefit this strategy.
- */
- RSYNC_ROOT,
- /**
- * Same as SYNC_ROOT, except the root certificate is synchronized
- * separately.
- * (Either because it's in a separate directory, or because we don't
- * want to download its entire repository until we've verified its
- * legitimacy and integrity.)
- */
- RSYNC_ROOT_EXCEPT_TA,
-};
-
-extern const struct global_type gt_rsync_strategy;
-
-#endif /* SRC_CONFIG_RSYNC_STRATEGY_H_ */
{
int error;
- error = rsync_download_files(sia_uris->caRepository.uri, false, false);
+ error = rsync_download_files(sia_uris->caRepository.uri, false);
if (error)
return error;
*/
pr_val_info("Retrying repository download to discard 'transient inconsistency' manifest issue (see RFC 6481 section 5) '%s'",
uri_val_get_printable(sia_uris.caRepository.uri));
- error = rsync_download_files(sia_uris.caRepository.uri, false, true);
+ error = rsync_download_files(sia_uris.caRepository.uri, true);
if (error)
break;
validation_destroy(state);
return 0; /* Try some other TAL URI */
}
- error = rsync_download_files(uri, true, false);
+ error = rsync_download_files(uri, false);
} else /* HTTPS */ {
if (!config_get_http_enabled()) {
validation_destroy(state);
#include "common.h"
#include "config.h"
#include "log.h"
-#include "str_token.h"
#include "thread_var.h"
struct uri {
free(list);
}
-/*
- * Returns true if @ancestor an ancestor of @descendant, or @descendant itself.
- * Returns false otherwise.
- */
-static bool
-is_descendant(struct rpki_uri *ancestor, struct rpki_uri *descendant)
-{
- struct string_tokenizer ancestor_tokenizer;
- struct string_tokenizer descendant_tokenizer;
-
- string_tokenizer_init(&ancestor_tokenizer, uri_get_global(ancestor),
- uri_get_global_len(ancestor), '/');
- string_tokenizer_init(&descendant_tokenizer, uri_get_global(descendant),
- uri_get_global_len(descendant), '/');
-
- if (config_get_rsync_strategy() == RSYNC_STRICT)
- return strcmp(uri_get_global(ancestor),
- uri_get_global(descendant)) == 0;
-
- do {
- if (!string_tokenizer_next(&ancestor_tokenizer))
- return true;
- if (!string_tokenizer_next(&descendant_tokenizer))
- return false;
- if (!token_equals(&ancestor_tokenizer, &descendant_tokenizer))
- return false;
- } while (true);
-}
-
/*
* Returns whether @uri has already been rsync'd during the current validation
* run.
/* TODO (next iteration) this is begging for a hash set. */
SLIST_FOREACH(cursor, visited_uris, next)
- if (is_descendant(cursor->uri, uri))
+ if (uri_equals(cursor->uri, uri))
return true;
return false;
SLIST_INSERT_HEAD(visited_uris, node, next);
}
-static int
-handle_strict_strategy(struct rpki_uri *requested_uri,
- struct rpki_uri **rsync_uri)
-{
- *rsync_uri = requested_uri;
- uri_refget(requested_uri);
- return 0;
-}
-
-static int
-handle_root_strategy(struct rpki_uri *src, struct rpki_uri **dst)
-{
- char const *global;
- size_t global_len;
- unsigned int slashes;
- size_t i;
-
- global = uri_get_global(src);
- global_len = uri_get_global_len(src);
- slashes = 0;
-
- for (i = 0; i < global_len; i++) {
- if (global[i] == '/') {
- slashes++;
- if (slashes == 4)
- return uri_create_rsync_str(dst, global, i);
- }
- }
-
- *dst = src;
- uri_refget(src);
- return 0;
-}
-
-static int
-get_rsync_uri(struct rpki_uri *requested_uri, bool is_ta,
- struct rpki_uri **rsync_uri)
-{
- switch (config_get_rsync_strategy()) {
- case RSYNC_ROOT:
- return handle_root_strategy(requested_uri, rsync_uri);
- case RSYNC_ROOT_EXCEPT_TA:
- return is_ta
- ? handle_strict_strategy(requested_uri, rsync_uri)
- : handle_root_strategy(requested_uri, rsync_uri);
- case RSYNC_STRICT:
- return handle_strict_strategy(requested_uri, rsync_uri);
- }
-
- pr_crit("Invalid rsync strategy: %u", config_get_rsync_strategy());
-}
-
/*
* Duplicate parent FDs, to pipe rsync output:
* - fds[0] = stderr
}
static void
-prepare_rsync(struct rpki_uri *uri, bool is_ta, char ***args, size_t *args_len)
+prepare_rsync(struct rpki_uri *uri, char ***args, size_t *args_len)
{
struct string_array const *config_args;
char **copy_args;
unsigned int i;
- config_args = config_get_rsync_args(is_ta);
+ config_args = config_get_rsync_args();
/*
* We need to work on a copy, because the config args are immutable,
* and we need to add the program name (for some reason) and NULL
* Downloads the @uri->global file into the @uri->local path.
*/
static int
-do_rsync(struct rpki_uri *uri, bool is_ta)
+do_rsync(struct rpki_uri *uri)
{
/* Descriptors to pipe stderr (first element) and stdout (second) */
char **args;
/* Prepare everything for the child exec */
args = NULL;
args_len = 0;
- prepare_rsync(uri, is_ta, &args, &args_len);
+ prepare_rsync(uri, &args, &args_len);
pr_val_info("rsync: %s", uri_get_global(uri));
if (log_val_enabled(LOG_DEBUG)) {
return error;
}
-/**
- * @is_ta: Are we rsync'ing the TA?
- * The TA rsync will not be recursive, and will force SYNC_STRICT
- * (unless the strategy has been set to SYNC_OFF.)
- * Why? Because we should probably not trust the repository until we've
- * validated the TA's public key.
- */
int
-rsync_download_files(struct rpki_uri *requested_uri, bool is_ta, bool force)
+rsync_download_files(struct rpki_uri *uri, bool force)
{
- /**
- * Note:
- * @requested_uri is the URI we were asked to RSYNC.
- * @rsync_uri is the URL we're actually going to RSYNC.
- * (They can differ, depending on config_get_rsync_strategy().)
- */
struct validation *state;
struct uri_list *visited_uris;
- struct rpki_uri *rsync_uri;
int error;
if (!config_get_rsync_enabled())
state = state_retrieve();
visited_uris = validation_rsync_visited_uris(state);
- if (!force && is_already_downloaded(requested_uri, visited_uris)) {
+ if (!force && is_already_downloaded(uri, visited_uris)) {
pr_val_debug("No need to redownload '%s'.",
- uri_val_get_printable(requested_uri));
+ uri_val_get_printable(uri));
return 0;
}
- error = force
- ? handle_strict_strategy(requested_uri, &rsync_uri)
- : get_rsync_uri(requested_uri, is_ta, &rsync_uri);
- if (error)
- return error;
-
- pr_val_debug("Going to RSYNC '%s'.", uri_val_get_printable(rsync_uri));
+ pr_val_debug("Going to RSYNC '%s'.", uri_val_get_printable(uri));
- error = do_rsync(rsync_uri, is_ta);
- switch(error) {
+ error = do_rsync(uri);
+ switch (error) {
case 0:
/* Don't store when "force" and if its already downloaded */
- if (!(force && is_already_downloaded(rsync_uri, visited_uris)))
- mark_as_downloaded(rsync_uri, visited_uris);
+ if (!(force && is_already_downloaded(uri, visited_uris)))
+ mark_as_downloaded(uri, visited_uris);
break;
case EREQFAILED:
- mark_as_downloaded(rsync_uri, visited_uris);
- error = EREQFAILED; /* Return the original error */
+ mark_as_downloaded(uri, visited_uris);
break;
}
- uri_refput(rsync_uri);
return error;
}
struct uri_list;
-int rsync_download_files(struct rpki_uri *, bool, bool);
+int rsync_download_files(struct rpki_uri *, bool);
struct uri_list *rsync_create(void);
void rsync_destroy(struct uri_list *);
MOCK_FALSE(config_get_shuffle_tal_uris, void)
MOCK(config_get_mode, enum mode, STANDALONE, void)
MOCK_TRUE(config_get_rsync_enabled, void)
-MOCK(config_get_rsync_strategy, enum rsync_strategy, RSYNC_ROOT, void)
-MOCK_ABORT_PTR(config_get_rsync_args, string_array const, bool t)
MOCK_NULL(config_get_output_roa, char const *, void)
MOCK_NULL(config_get_output_bgpsec, char const *, void)
MOCK_UINT(config_get_thread_pool_validation_max, 10, void)
/* Tests */
-static void
-assert_descendant(bool expected, char *ancestor, char *descendant)
-{
- struct rpki_uri *ancestor_uri;
- struct rpki_uri *descendant_uri;
-
- ck_assert_int_eq(0, uri_create_rsync_str(&ancestor_uri, ancestor,
- strlen(ancestor)));
- ck_assert_int_eq(0, uri_create_rsync_str(&descendant_uri, descendant,
- strlen(descendant)));
-
- ck_assert_int_eq(is_descendant(ancestor_uri, descendant_uri), expected);
-
- uri_refput(ancestor_uri);
- uri_refput(descendant_uri);
-}
-
-START_TEST(rsync_test_prefix_equals)
-{
- char *ancestor;
-
- ancestor = "rsync://a/b/c";
- assert_descendant(true, ancestor, "rsync://a/b/c");
- assert_descendant(false, ancestor, "rsync://a/b/");
- assert_descendant(true, ancestor, "rsync://a/b/c/c");
- assert_descendant(false, ancestor, "rsync://a/b/cc");
- assert_descendant(false, ancestor, "rsync://a/b/cc/");
-
- ancestor = "rsync://a/b/c/";
- assert_descendant(true, ancestor, "rsync://a/b/c");
- assert_descendant(false, ancestor, "rsync://a/b/");
- assert_descendant(true, ancestor, "rsync://a/b/c/c");
- assert_descendant(false, ancestor, "rsync://a/b/cc");
- assert_descendant(false, ancestor, "rsync://a/b/cc/");
-}
-END_TEST
-
static void
__mark_as_downloaded(char *uri_str, struct uri_list *visited_uris)
{
assert_downloaded("rsync://example.foo/repository/", visited_uris,
true);
assert_downloaded("rsync://example.foo/repository/abc/cdfg",
- visited_uris, true);
+ visited_uris, false);
assert_downloaded("rsync://example.foo/member_repository/bca",
- visited_uris, true);
+ visited_uris, false);
assert_downloaded("rsync://example.boo/repository/", visited_uris,
false);
assert_downloaded("rsync://example.potato/repository/", visited_uris,
false);
assert_downloaded("rsync://example.potato/rpki/abc/", visited_uris,
- true);
+ false);
rsync_destroy(visited_uris);
}
END_TEST
-static void
-test_root_strategy(char *test, char *expected)
-{
- struct rpki_uri *src;
- struct rpki_uri *dst;
-
- ck_assert_int_eq(0, uri_create_rsync_str(&src, test, strlen(test)));
- ck_assert_int_eq(handle_root_strategy(src, &dst), 0);
- ck_assert_str_eq(uri_get_global(dst), expected);
-
- uri_refput(src);
- uri_refput(dst);
-}
-
-START_TEST(rsync_test_get_prefix)
-{
- test_root_strategy("rsync://www.example1.com/test/foo/",
- "rsync://www.example1.com/test");
- test_root_strategy("rsync://www.example1.com/test/foo/bar",
- "rsync://www.example1.com/test");
- test_root_strategy("rsync://www.example1.com/test/",
- "rsync://www.example1.com/test");
- test_root_strategy("rsync://www.example1.com/test",
- "rsync://www.example1.com/test");
- test_root_strategy("rsync://www.example1.com",
- "rsync://www.example1.com");
- test_root_strategy("rsync://w", "rsync://w");
- test_root_strategy("rsync://", "rsync://");
-}
-END_TEST
-
Suite *rsync_load_suite(void)
{
Suite *suite;
- TCase *prefix_equals, *uri_list, *test_get_prefix;
-
- prefix_equals = tcase_create("PrefixEquals");
- tcase_add_test(prefix_equals, rsync_test_prefix_equals);
+ TCase *uri_list;
uri_list = tcase_create("uriList");
tcase_add_test(uri_list, rsync_test_list);
- test_get_prefix = tcase_create("test_get_prefix");
- tcase_add_test(test_get_prefix, rsync_test_get_prefix);
-
suite = suite_create("rsync_test()");
- suite_add_tcase(suite, prefix_equals);
suite_add_tcase(suite, uri_list);
- suite_add_tcase(suite, test_get_prefix);
return suite;
}