From 0bc11e78ac4c3f0a0d18fadc408571511baf6c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Wed, 28 Aug 2024 09:22:09 +0200 Subject: [PATCH] Update TAP test 'test_auth_methods' for 'dual-password' There are several failing cases at the moment. This is left as a reminder that 'dual-password' support is not complete. --- test/tap/tests/test_auth_methods-t.cpp | 46 ++++++++++++++++++++------ 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/test/tap/tests/test_auth_methods-t.cpp b/test/tap/tests/test_auth_methods-t.cpp index d12aedcd7..0f7bba16e 100644 --- a/test/tap/tests/test_auth_methods-t.cpp +++ b/test/tap/tests/test_auth_methods-t.cpp @@ -223,8 +223,8 @@ using auth_reg_t = std::unordered_map; struct user_creds_t { user_def_t user_def; - mf_unique_ptr hashed_prim_pass_bin; - mf_unique_ptr hashed_addl_pass_bin; + mf_unique_ptr hashed_prim_pass_bin { nullptr }; + mf_unique_ptr hashed_addl_pass_bin { nullptr }; user_creds_t(const user_creds_t&) = delete; user_creds_t(user_creds_t&&) noexcept(false) = default; @@ -1288,9 +1288,12 @@ const vector backend_users { * @brief Minimal test cases for default backend users. */ const vector tests_creds { + { "dualpass1", MF_CHAR_("USE_PRIM_RAND_PASS") }, { "dualpass1", MF_CHAR_(nullptr) }, { "dualpass1", MF_CHAR_("") }, { "dualpass1", MF_CHAR_("inv_pass") }, + { "dualpass1", MF_CHAR_("USE_PRIM_RAND_PASS") }, + { "dualpass1", MF_CHAR_("USE_ADDL_RAND_PASS") }, { "dualpass2", MF_CHAR_(nullptr) }, { "dualpass2", MF_CHAR_("") }, @@ -1309,6 +1312,10 @@ const vector tests_creds { { "dualpass5", MF_CHAR_(nullptr) }, { "dualpass5", MF_CHAR_("") }, { "dualpass5", MF_CHAR_("inv_pass") }, + // Failure unless in RAND mode - Use fetched RAND_PASS + { "dualpass5", MF_CHAR_("USE_PRIM_RAND_PASS") }, + { "dualpass5", MF_CHAR_("USE_PRIM_RAND_PASS") }, + { "dualpass5", MF_CHAR_("USE_ADDL_RAND_PASS") }, { "dualpass6", MF_CHAR_(nullptr) }, { "dualpass6", MF_CHAR_("") }, @@ -1319,23 +1326,33 @@ const vector tests_creds { { "dualpass7", MF_CHAR_(nullptr) }, { "dualpass7", MF_CHAR_("") }, { "dualpass7", MF_CHAR_("inv_pass") }, - // { "dualpass7", MF_CHAR_("oldpass7") }, + { "dualpass7", MF_CHAR_("oldpass7") }, + // Failure unless in RAND mode - Use fetched RAND_PASS + { "dualpass7", MF_CHAR_("USE_PRIM_RAND_PASS") }, + { "dualpass7", MF_CHAR_("USE_PRIM_RAND_PASS") }, + { "dualpass7", MF_CHAR_("USE_ADDL_RAND_PASS") }, { "dualpass8", MF_CHAR_(nullptr) }, { "dualpass8", MF_CHAR_("") }, { "dualpass8", MF_CHAR_("inv_pass") }, - // { "dualpass8", MF_CHAR_("oldpass8") }, + { "dualpass8", MF_CHAR_("oldpass8") }, { "dualpass9", MF_CHAR_(nullptr) }, { "dualpass9", MF_CHAR_("") }, { "dualpass9", MF_CHAR_("inv_pass") }, - // { "dualpass9", MF_CHAR_("oldpass9") }, + { "dualpass9", MF_CHAR_("oldpass9") }, { "dualpass9", MF_CHAR_("newpass9") }, { "dualpass9", MF_CHAR_("newpass9") }, + { "dualpass9", MF_CHAR_("USE_RAND_PASS") }, { "dualpass11", MF_CHAR_(nullptr) }, { "dualpass11", MF_CHAR_("") }, { "dualpass11", MF_CHAR_("inv_pass") }, + // Failure unless in RAND mode - Use fetched RAND_PASS + { "dualpass11", MF_CHAR_("USE_ADDL_RAND_PASS") }, + // Triggers limitation on 'full_auth' again; this should be improved + { "dualpass11", MF_CHAR_("USE_ADDL_RAND_PASS") }, + { "dualpass11", MF_CHAR_("USE_PRIM_RAND_PASS") }, { "dualpass12", MF_CHAR_(nullptr) }, { "dualpass12", MF_CHAR_("") }, @@ -1364,12 +1381,16 @@ const vector tests_creds { { "dualpass17", MF_CHAR_(nullptr) }, { "dualpass17", MF_CHAR_("") }, { "dualpass17", MF_CHAR_("inv_pass") }, - // { "dualpass17", MF_CHAR_("oldpass17") }, + { "dualpass17", MF_CHAR_("oldpass17") }, + // Failure unless in RAND mode - Use fetched RAND_PASS + { "dualpass17", MF_CHAR_("USE_ADDL_RAND_PASS") }, + { "dualpass17", MF_CHAR_("USE_ADDL_RAND_PASS") }, + { "dualpass17", MF_CHAR_("USE_PRIM_RAND_PASS") }, { "dualpass18", MF_CHAR_(nullptr) }, { "dualpass18", MF_CHAR_("") }, { "dualpass18", MF_CHAR_("inv_pass") }, - // { "dualpass18", MF_CHAR_("oldpass18") }, + { "dualpass18", MF_CHAR_("oldpass18") }, { "dualpass19", MF_CHAR_(nullptr) }, { "dualpass19", MF_CHAR_("") }, @@ -1667,18 +1688,21 @@ int main(int argc, char** argv) { vector rnd_tests_creds { ::tests_creds }; - for (test_creds_t& creds : rnd_tests_creds) { creds.name = "rnd" + creds.name; - auto it = std::find_if(cbres.second.begin(), cbres.second.end(), + auto it = std::find_if(rnd_cbres.second.begin(), rnd_cbres.second.end(), [&creds] (const user_creds_t& user_creds) { return creds.name == user_creds.user_def.name; } ); - if (it != cbres.second.end()) { - creds.pass = it->user_def.prim_pass ? MF_CHAR_(it->user_def.prim_pass.get()) : nullptr; + if (it != rnd_cbres.second.end()) { + if (creds.pass && strcasecmp(creds.pass.get(), "USE_PRIM_RAND_PASS") == 0) { + creds.pass = it->user_def.prim_pass ? MF_CHAR_(it->user_def.prim_pass.get()) : nullptr; + } else if (creds.pass && strcasecmp(creds.pass.get(), "USE_ADDL_RAND_PASS") == 0) { + creds.pass = it->user_def.addl_pass ? MF_CHAR_(it->user_def.addl_pass.get()) : nullptr; + } } }