1 #include "test/lib/common.hpp"
2 #include "test/lib/Shell.hpp"
3 #include "test/lib/MemcachedCluster.hpp"
4 #include "test/fixtures/callbacks.hpp"
6 TEST_CASE("memcached_sasl") {
7 #if !LIBMEMCACHED_WITH_SASL_SUPPORT
8 WARN("ENABLE_SASL=OFF");
11 string mc
{MEMCACHED_BINARY
}, err
;
13 if (!sh
.run(mc
+ " -S --version", err
)) {
14 WARN(mc
<< ": " << err
);
16 auto test
= MemcachedCluster::sasl();
17 auto memc
= &test
.memc
;
19 REQUIRE_SUCCESS(memcached_set(memc
, S(__func__
), S(__func__
), 0, 0));
20 REQUIRE_SUCCESS(memcached_delete(memc
, S(__func__
), 0));
21 REQUIRE_SUCCESS(memcached_destroy_sasl_auth_data(memc
));
22 REQUIRE_SUCCESS(memcached_destroy_sasl_auth_data(memc
));
23 REQUIRE_RC(MEMCACHED_INVALID_ARGUMENTS
, memcached_destroy_sasl_auth_data(nullptr));
27 REQUIRE_RC(MEMCACHED_AUTH_FAILURE
, memcached_set(memc
, S(__func__
), S(__func__
), 0, 0));
29 REQUIRE_SUCCESS(memcached_set_sasl_auth_data(memc
, "username", "password"));
30 REQUIRE_RC(MEMCACHED_AUTH_FAILURE
, memcached_set(memc
, S(__func__
), S(__func__
), 0, 0));
33 memcached_return_t rc
;
35 for (auto &server
: test
.cluster
.getServers()) {
36 REQUIRE(server
.getPid() == libmemcached_util_getpid2("localhost", get
<int>(server
.getSocketOrPort()), "memcached", "memcached", &rc
));
40 REQUIRE(-1 == libmemcached_util_getpid2("localhost", 1, "foo", "bar", &rc
));
41 REQUIRE(memcached_fatal(rc
));
45 memcached_server_fn fptr
[] = {&ping2_callback
};
47 REQUIRE_SUCCESS(memcached_server_cursor(memc
, fptr
, nullptr, 1));