blob: fd90469ecc90a02700596aa1ba5163df78619185 [file]
#include "fake_auth_context.h"
#include "gmock.h"
#include "gunit.h"
using ::testing::ElementsAre;
using ::testing::IsEmpty;
namespace {
TEST(FakeAuthContextTest, PeerIdentityMatches) {
milotic::FakeAuthContext auth_context(true);
auth_context.AddProperty("peer", "peer name");
auth_context.SetPeerIdentityPropertyName("peer");
EXPECT_THAT(auth_context.GetPeerIdentity(), ElementsAre("peer name"));
}
TEST(FakeAuthContextTest, MultiplePropertyValues) {
milotic::FakeAuthContext auth_context(true);
auth_context.AddProperty("test_property", "value1");
auth_context.AddProperty("test_property", "value2");
EXPECT_THAT(auth_context.FindPropertyValues("test_property"),
ElementsAre("value1", "value2"));
}
TEST(FakeAuthContextTest, NoValuesFound) {
milotic::FakeAuthContext auth_context(true);
EXPECT_THAT(auth_context.FindPropertyValues("test_property"), IsEmpty());
}
TEST(FakeAuthContextTest, IsPeerAuthenticated) {
milotic::FakeAuthContext auth_context(true);
EXPECT_TRUE(auth_context.IsPeerAuthenticated());
milotic::FakeAuthContext unauth_context(false);
EXPECT_FALSE(unauth_context.IsPeerAuthenticated());
}
TEST(FakeAuthContextTest, GetPeerIdentityPropertyName) {
milotic::FakeAuthContext auth_context(true);
auth_context.SetPeerIdentityPropertyName("custom_identity");
EXPECT_EQ(auth_context.GetPeerIdentityPropertyName(), "custom_identity");
}
TEST(FakeAuthContextTest, IteratorNotSupported) {
milotic::FakeAuthContext auth_context(true);
EXPECT_DEATH(auth_context.begin(), "Iterator not supported");
EXPECT_DEATH(auth_context.end(), "Iterator not supported");
}
} // namespace