@@ -460,6 +460,79 @@ TEST_CASE("user profile C API", "[config][user_profile][c]") {
460460 CHECK (session::to_vector (std::span<const unsigned char >{pic.key , 32 }) ==
461461 " qwert\0 yuio1234567890123456789012" _bytes);
462462
463+ #if 0
464+ // Reupload the "current" pic and confirm it gets returned
465+ strcpy(p.url, "testUrl");
466+ memcpy(p.key, "secret78901234567890123456789000", 32);
467+ CHECK(0 == user_profile_set_reupload_pic(conf, p));
468+
469+ pic = user_profile_get_pic(conf);
470+ REQUIRE(pic.url != ""s);
471+ REQUIRE(pic.key != session::to_vector("").data());
472+ CHECK(pic.url == "testUrl"sv);
473+ CHECK(session::to_vector(std::span<const unsigned char>{pic.key, 32}) ==
474+ "secret78901234567890123456789000"_bytes);
475+
476+ // Upload a "new" pic and it now gets returned
477+ strcpy(p.url, "testNewUrl");
478+ memcpy(p.key, "secret78901234567890123456789111", 32);
479+ CHECK(0 == user_profile_set_pic(conf, p));
480+ pic = user_profile_get_pic(conf);
481+ REQUIRE(pic.url != ""s);
482+ REQUIRE(pic.key != session::to_vector("").data());
483+ CHECK(pic.url == "testNewUrl"sv);
484+ CHECK(session::to_vector(std::span<const unsigned char>{pic.key, 32}) ==
485+ "secret78901234567890123456789111"_bytes);
486+
487+ // Ensure the timestamp for the last modified pic gets updated correctly when the name gets set
488+ UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{0s});
489+ UserProfileTester::set_reupload_profile_updated(conf, std::chrono::sys_seconds{0s});
490+
491+ CHECK(0 == user_profile_set_pic(conf, p));
492+ UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{123s});
493+ user_profile_set_name(conf, "test1");
494+ CHECK(UserProfileTester::get_profile_updated_value(conf).time_since_epoch().count() != 123);
495+ UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{0s});
496+
497+ UserProfileTester::set_reupload_profile_updated(conf, std::chrono::sys_seconds{124s});
498+ CHECK(0 == user_profile_set_reupload_pic(conf, p));
499+ user_profile_set_name(conf, "test2");
500+ CHECK(UserProfileTester::get_reupload_profile_updated_value(conf).time_since_epoch().count() !=
501+ 124);
502+
503+ // Ensure the timestamp for the last modified pic gets updated correctly when the blinded msgreq
504+ // is set
505+ UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{0s});
506+ UserProfileTester::set_reupload_profile_updated(conf, std::chrono::sys_seconds{0s});
507+
508+ CHECK(0 == user_profile_set_pic(conf, p));
509+ UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{123s});
510+ user_profile_set_blinded_msgreqs(conf, 1);
511+ CHECK(UserProfileTester::get_profile_updated_value(conf).time_since_epoch().count() != 123);
512+ UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{0s});
513+
514+ UserProfileTester::set_reupload_profile_updated(conf, std::chrono::sys_seconds{124s});
515+ CHECK(0 == user_profile_set_reupload_pic(conf, p));
516+ user_profile_set_blinded_msgreqs(conf, 2);
517+ CHECK(UserProfileTester::get_reupload_profile_updated_value(conf).time_since_epoch().count() !=
518+ 124);
519+
520+ // Ensure the timestamp is stored in seconds seconds (was incorrectly stored as microseconds)
521+ auto time_before_call = std::chrono::system_clock::now();
522+ CHECK(0 == user_profile_set_pic(conf, p));
523+ auto time_after_call = std::chrono::system_clock::now();
524+ auto before_seconds =
525+ std::chrono::duration_cast<std::chrono::seconds>(time_before_call.time_since_epoch())
526+ .count();
527+ auto after_seconds =
528+ std::chrono::duration_cast<std::chrono::seconds>(time_before_call.time_since_epoch())
529+ .count();
530+
531+ auto raw_value = UserProfileTester::get_raw_profile_updated_value(conf);
532+ INFO("Checking if raw_value " << raw_value << " is within the range [" << before_seconds << ", "
533+ << after_seconds << "]");
534+ CHECK((raw_value >= before_seconds && raw_value <= after_seconds));
535+ #else
463536 // Ensure the timestamp doesn't get updated
464537 strcpy (p.url , " testUrl" );
465538 memcpy (p.key , " secret78901234567890123456789000" , 32 );
@@ -468,76 +541,5 @@ TEST_CASE("user profile C API", "[config][user_profile][c]") {
468541 CHECK (0 == user_profile_set_name (conf, " Test" ));
469542 user_profile_set_blinded_msgreqs (conf, 1 );
470543 CHECK (user_profile_get_profile_updated (conf) == 0 );
471-
472- // // Reupload the "current" pic and confirm it gets returned
473- // strcpy(p.url, "testUrl");
474- // memcpy(p.key, "secret78901234567890123456789000", 32);
475- // CHECK(0 == user_profile_set_reupload_pic(conf, p));
476-
477- // pic = user_profile_get_pic(conf);
478- // REQUIRE(pic.url != ""s);
479- // REQUIRE(pic.key != session::to_vector("").data());
480- // CHECK(pic.url == "testUrl"sv);
481- // CHECK(session::to_vector(std::span<const unsigned char>{pic.key, 32}) ==
482- // "secret78901234567890123456789000"_bytes);
483-
484- // // Upload a "new" pic and it now gets returned
485- // strcpy(p.url, "testNewUrl");
486- // memcpy(p.key, "secret78901234567890123456789111", 32);
487- // CHECK(0 == user_profile_set_pic(conf, p));
488- // pic = user_profile_get_pic(conf);
489- // REQUIRE(pic.url != ""s);
490- // REQUIRE(pic.key != session::to_vector("").data());
491- // CHECK(pic.url == "testNewUrl"sv);
492- // CHECK(session::to_vector(std::span<const unsigned char>{pic.key, 32}) ==
493- // "secret78901234567890123456789111"_bytes);
494-
495- // // Ensure the timestamp for the last modified pic gets updated correctly when the name gets set
496- // UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{0s});
497- // UserProfileTester::set_reupload_profile_updated(conf, std::chrono::sys_seconds{0s});
498-
499- // CHECK(0 == user_profile_set_pic(conf, p));
500- // UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{123s});
501- // user_profile_set_name(conf, "test1");
502- // CHECK(UserProfileTester::get_profile_updated_value(conf).time_since_epoch().count() != 123);
503- // UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{0s});
504-
505- // UserProfileTester::set_reupload_profile_updated(conf, std::chrono::sys_seconds{124s});
506- // CHECK(0 == user_profile_set_reupload_pic(conf, p));
507- // user_profile_set_name(conf, "test2");
508- // CHECK(UserProfileTester::get_reupload_profile_updated_value(conf).time_since_epoch().count() !=
509- // 124);
510-
511- // // Ensure the timestamp for the last modified pic gets updated correctly when the blinded msgreq
512- // // is set
513- // UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{0s});
514- // UserProfileTester::set_reupload_profile_updated(conf, std::chrono::sys_seconds{0s});
515-
516- // CHECK(0 == user_profile_set_pic(conf, p));
517- // UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{123s});
518- // user_profile_set_blinded_msgreqs(conf, 1);
519- // CHECK(UserProfileTester::get_profile_updated_value(conf).time_since_epoch().count() != 123);
520- // UserProfileTester::set_profile_updated(conf, std::chrono::sys_seconds{0s});
521-
522- // UserProfileTester::set_reupload_profile_updated(conf, std::chrono::sys_seconds{124s});
523- // CHECK(0 == user_profile_set_reupload_pic(conf, p));
524- // user_profile_set_blinded_msgreqs(conf, 2);
525- // CHECK(UserProfileTester::get_reupload_profile_updated_value(conf).time_since_epoch().count() !=
526- // 124);
527-
528- // // Ensure the timestamp is stored in seconds seconds (was incorrectly stored as microseconds)
529- // auto time_before_call = std::chrono::system_clock::now();
530- // CHECK(0 == user_profile_set_pic(conf, p));
531- // auto time_after_call = std::chrono::system_clock::now();
532- // auto before_seconds =
533- // std::chrono::duration_cast<std::chrono::seconds>(time_before_call.time_since_epoch())
534- // .count();
535- // auto after_seconds =
536- // std::chrono::duration_cast<std::chrono::seconds>(time_before_call.time_since_epoch())
537- // .count();
538-
539- // auto raw_value = UserProfileTester::get_raw_profile_updated_value(conf);
540- // INFO("Checking if raw_value " << raw_value << " is within the range [" << before_seconds << ", "
541- // << after_seconds << "]");
542- // CHECK((raw_value >= before_seconds && raw_value <= after_seconds));
544+ #endif
543545}
0 commit comments