4269430871U, 610793021U, 527273862U, 1437122909U,
2300930706U, 2943759320U, 674306647U, 2400528935U,
54481931U, 4186304426U, 1741088401U, 2979625118U,
- 4159057246U, 3425930182U, 2593724503U, 1868899624U};
+ 4159057246U, 3425930182U, 2593724503U, 1868899624U,
+ 1769812374U, 2302537950U, 1110330676U };
// You have updated the memcache_error messages but not updated docs/tests.
- test_true(MEMCACHED_MAXIMUM_RETURN == 40);
+ test_true(MEMCACHED_MAXIMUM_RETURN == 43);
for (rc= MEMCACHED_SUCCESS; rc < MEMCACHED_MAXIMUM_RETURN; rc++)
{
uint32_t hash_val;
memcached_server_instance_st instance=
memcached_server_instance_by_position(memc, 0);
+ #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+ if (memcached_get_sasl_callbacks(memc) != NULL)
+ return TEST_SKIPPED;
+ #endif
rc= memcached_stat_servername(&memc_stat, NULL,
memcached_server_name(instance),
memcached_server_port(instance));
static test_return_t pre_cork_and_nonblock(memcached_st *memc)
{
test_return_t rc;
-
+
rc= pre_cork(memc);
#ifdef __APPLE__
return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED;
}
+ static test_return_t pre_sasl(memcached_st *memc)
+ {
+ memcached_return_t rc= MEMCACHED_FAILURE;
+
+ #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+ const char *server= getenv("LIBMEMCACHED_TEST_SASL_SERVER");
+ const char *user= getenv("LIBMEMCACHED_TEST_SASL_USERNAME");
+ const char *pass= getenv("LIBMEMCACHED_TEST_SASL_PASSWORD");
+
+ if (server != NULL && user != NULL && pass != NULL)
+ {
+ memcached_server_st *servers= memcached_servers_parse(server);
+ test_true(servers != NULL);
+ memcached_servers_reset(memc);
+ test_true(memcached_server_push(memc, servers) == MEMCACHED_SUCCESS);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
+ rc= memcached_set_sasl_auth_data(memc, user, pass);
+ test_true(rc == MEMCACHED_SUCCESS);
+ }
+ #else
+ (void)memc;
+ #endif
+
+ return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED;
+ }
static test_return_t pre_replication(memcached_st *memc)
{
rc= memcached_set(mmc[0], key, keylen, "0", 1, 0, 0);
test_true(rc == MEMCACHED_SUCCESS);
- for (size_t x= 0; x < 10; ++x)
+ for (size_t x= 0; x < 10; ++x)
{
uint64_t number_value;
rc= memcached_increment(mmc[x], key, keylen, 1, &number_value);
{
uint32_t x;
const char **ptr;
- hashkit_st *kit;
+ const hashkit_st *kit;
+ hashkit_st new_kit;
hashkit_return_t hash_rc;
uint32_t md5_hosts[]= {4U, 1U, 0U, 1U, 4U, 2U, 0U, 3U, 0U, 0U, 3U, 1U, 0U, 0U, 1U, 3U, 0U, 0U, 0U, 3U, 1U, 0U, 4U, 4U, 3U};
kit= memcached_get_hashkit(memc);
- hash_rc= hashkit_set_custom_function(kit, hash_md5_test_function, NULL);
+ hashkit_clone(&new_kit, kit);
+ hash_rc= hashkit_set_custom_function(&new_kit, hash_md5_test_function, NULL);
test_true(hash_rc == HASHKIT_SUCCESS);
+ memcached_set_hashkit(memc, &new_kit);
+
/*
Verify Setting the hash.
*/
test_true(md5_values[x] == hash_val);
}
-
+
/*
Now check memcached_st.
*/
test_true(md5_hosts[x] == hash_val);
}
- hash_rc= hashkit_set_custom_function(kit, hash_crc_test_function, NULL);
+ hash_rc= hashkit_set_custom_function(&new_kit, hash_crc_test_function, NULL);
test_true(hash_rc == HASHKIT_SUCCESS);
+ memcached_set_hashkit(memc, &new_kit);
+
/*
Verify Setting the hash.
*/
return TEST_SUCCESS;
}
+ /*
+ * Test that the sasl authentication works. We cannot use the default
+ * pool of servers, because that would require that all servers we want
+ * to test supports SASL authentication, and that they use the default
+ * creds.
+ */
+ static test_return_t sasl_auth_test(memcached_st *memc)
+ {
+ memcached_return_t rc;
+ rc= memcached_set(memc, "foo", 3, "bar", 3, (time_t)0, (uint32_t)0);
+ test_true(rc == MEMCACHED_SUCCESS);
+ test_true((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_SUCCESS);
+ test_true((rc= memcached_destroy_sasl_auth_data(memc)) == MEMCACHED_SUCCESS);
+ test_true((rc= memcached_destroy_sasl_auth_data(memc)) == MEMCACHED_FAILURE);
+ test_true((rc= memcached_destroy_sasl_auth_data(NULL)) == MEMCACHED_FAILURE);
+ memcached_quit(memc);
+
+ rc= memcached_set_sasl_auth_data(memc,
+ getenv("LIBMEMCACHED_TEST_SASL_USERNAME"),
+ getenv("LIBMEMCACHED_TEST_SASL_SERVER"));
+ test_true(rc == MEMCACHED_SUCCESS);
+ rc= memcached_set(memc, "foo", 3, "bar", 3, (time_t)0, (uint32_t)0);
+ test_true(rc == MEMCACHED_AUTH_FAILURE);
+ test_true(memcached_destroy_sasl_auth_data(memc) == MEMCACHED_SUCCESS);
+
+ memcached_quit(memc);
+ return TEST_SUCCESS;
+ }
/* Clean the server before beginning testing */
test_st tests[] ={
{0, 0, (test_callback_fn)0}
};
+ #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+ test_st sasl_auth_tests[]= {
+ {"sasl_auth", 1, (test_callback_fn)sasl_auth_test },
+ {0, 0, (test_callback_fn)0}
+ };
+ #endif
+
test_st ketama_compatibility[]= {
{"libmemcached", 1, (test_callback_fn)ketama_compatibility_libmemcached },
{"spymemcached", 1, (test_callback_fn)ketama_compatibility_spymemcached },
#endif
{"memory_allocators", (test_callback_fn)set_memory_alloc, 0, tests},
{"prefix", (test_callback_fn)set_prefix, 0, tests},
+ {"sasl_auth", (test_callback_fn)pre_sasl, 0, sasl_auth_tests },
+ {"sasl", (test_callback_fn)pre_sasl, 0, tests },
{"version_1_2_3", (test_callback_fn)check_for_1_2_3, 0, version_1_2_3},
{"string", 0, 0, string_tests},
{"result", 0, 0, result_tests},