15 #include <gtest/gtest.h>
36 TEST(Auth, PrincipalSubstitution) {
40 ASSERT_TRUE(sa.
InitKerberos(
"service_name/_HOST@some.realm",
"/etc/hosts").
ok());
42 ASSERT_EQ(string::npos, sa.
principal().find(
"_HOST"));
43 ASSERT_NE(string::npos, sa.
principal().find(hostname));
46 ASSERT_EQ(
"some.realm", sa.
realm());
49 TEST(Auth, ValidAuthProviders) {
60 FLAGS_enable_ldap_auth =
true;
61 FLAGS_ldap_uri =
"ldaps://bogus.com";
70 ASSERT_TRUE(sa->has_ldap());
71 ASSERT_EQ(
"", sa->principal());
75 ASSERT_FALSE(ap->is_sasl());
88 FLAGS_enable_ldap_auth =
true;
89 FLAGS_ldap_uri =
"ldaps://bogus.com";
98 ASSERT_TRUE(sa->has_ldap());
99 ASSERT_EQ(FLAGS_principal, sa->principal());
103 ASSERT_TRUE(ap->is_sasl());
105 ASSERT_FALSE(sa->has_ldap());
106 ASSERT_EQ(FLAGS_principal, sa->principal());
111 int main(
int argc,
char** argv) {
114 ::testing::InitGoogleTest(&argc, argv);
117 env_princ = getenv(
"MINIKDC_PRINC_IMPALA");
119 return RUN_ALL_TESTS();
static const char * env_princ
AuthProvider * GetInternalAuthProvider()
DECLARE_bool(enable_ldap_auth)
const std::string & principal() const
Used for testing.
const std::string & hostname() const
Status InitKerberos(const std::string &principal, const std::string &keytab_path)
void InitGoogleLoggingSafe(const char *arg)
void InitThreading()
Initialises the threading subsystem. Must be called before a Thread is created.
static const char * env_keytab
AuthProvider * GetExternalAuthProvider()
Status GetHostname(string *hostname)
static AuthManager * GetInstance()
const std::string & service_name() const
int main(int argc, char **argv)
const std::string & realm() const
virtual bool is_sasl()=0
Returns true if this provider uses Sasl at the transport layer.