|
@@ -6,6 +6,7 @@
|
|
|
* \brief Test hidden service functionality.
|
|
|
*/
|
|
|
|
|
|
+#define HS_COMMON_PRIVATE
|
|
|
#define HS_SERVICE_PRIVATE
|
|
|
#define HS_INTROPOINT_PRIVATE
|
|
|
|
|
@@ -14,6 +15,7 @@
|
|
|
#include "crypto.h"
|
|
|
|
|
|
#include "hs/cell_establish_intro.h"
|
|
|
+#include "hs_common.h"
|
|
|
#include "hs_service.h"
|
|
|
#include "hs_intropoint.h"
|
|
|
|
|
@@ -196,12 +198,52 @@ test_hs_ntor(void *arg)
|
|
|
;
|
|
|
}
|
|
|
|
|
|
+/** Test that our HS time period calculation functions work properly */
|
|
|
+static void
|
|
|
+test_time_period(void *arg)
|
|
|
+{
|
|
|
+ (void) arg;
|
|
|
+ unsigned int tn;
|
|
|
+ int retval;
|
|
|
+ time_t fake_time;
|
|
|
+
|
|
|
+ /* Let's do the example in prop224 section [TIME-PERIODS] */
|
|
|
+ retval = parse_rfc1123_time("Wed, 13 Apr 2016 11:00:00 UTC",
|
|
|
+ &fake_time);
|
|
|
+ tt_int_op(retval, ==, 0);
|
|
|
+
|
|
|
+ /* Check that the time period number is right */
|
|
|
+ tn = get_time_period_num(fake_time);
|
|
|
+ tt_int_op(tn, ==, 16903);
|
|
|
+
|
|
|
+ /* Increase current time to 11:59:59 UTC and check that the time period
|
|
|
+ number is still the same */
|
|
|
+ fake_time += 3599;
|
|
|
+ tn = get_time_period_num(fake_time);
|
|
|
+ tt_int_op(tn, ==, 16903);
|
|
|
+
|
|
|
+ /* Now take time to 12:00:00 UTC and check that the time period rotated */
|
|
|
+ fake_time += 1;
|
|
|
+ tn = get_time_period_num(fake_time);
|
|
|
+ tt_int_op(tn, ==, 16904);
|
|
|
+
|
|
|
+ /* Now also check our hs_get_next_time_period_num() function */
|
|
|
+ tn = hs_get_next_time_period_num(fake_time);
|
|
|
+ tt_int_op(tn, ==, 16905);
|
|
|
+
|
|
|
+ done:
|
|
|
+ ;
|
|
|
+}
|
|
|
+
|
|
|
struct testcase_t hs_service_tests[] = {
|
|
|
{ "gen_establish_intro_cell", test_gen_establish_intro_cell, TT_FORK,
|
|
|
NULL, NULL },
|
|
|
{ "gen_establish_intro_cell_bad", test_gen_establish_intro_cell_bad, TT_FORK,
|
|
|
NULL, NULL },
|
|
|
- { "hs_ntor", test_hs_ntor, TT_FORK, NULL, NULL },
|
|
|
+ { "hs_ntor", test_hs_ntor, TT_FORK,
|
|
|
+ NULL, NULL },
|
|
|
+ { "time_period", test_time_period, TT_FORK,
|
|
|
+ NULL, NULL },
|
|
|
|
|
|
END_OF_TESTCASES
|
|
|
};
|