#include #include #include #include #include #include #include #include #include #include #include #include constexpr eedb::user_audit t_user_audit; constexpr eedb::user_action t_user_action; constexpr eedb::auth_identity t_auth_identity; constexpr eedb::auth_info t_auth_info; constexpr eedb::auth_token t_auth_token; class PgUserTest : public DbTestBase< PgUserTest > { public: PgUserTest() { db().native()->start_transaction(); auto info_ = std::make_unique< eedb::AuthInfoConst >( eedb::Password{"bcrypt", "OM/Z1c4WBFXvwkxh", "$2y$07$RyytUhDhLDbAPjf0b0r2Y.dsg.FlQ7L.xzWHMmoelI81u0MfBrW7q"}, eedb::Email{"email@eedb.pl"}); auto identity_ = std::make_unique< eedb::AuthIdentityConst >("name", "loginname"); const auto & pass = info_->password(); const auto & email = info_->email(); uid = // db()(sqlpp::postgresql::insert_into(t_auth_info) .set( // t_auth_info.password_hash = pass.value(), // t_auth_info.password_method = pass.function(), // t_auth_info.password_salt = pass.salt(), // t_auth_info.email = std::string{email.address()}, t_auth_info.status = 0) .returning(t_auth_info.id)) .front() .id; db()(insert_into(t_auth_identity) .set( // t_auth_identity.auth_info_id = uid, // t_auth_identity.identity = std::string{identity_->identity()}, t_auth_identity.provider = std::string{identity_->provider()})); sut = std::make_unique< eedb::PgUser >(db(), uid); } ~PgUserTest() { db().native()->rollback_transaction(false); } protected: int64_t uid; std::unique_ptr< eedb::PgUser > sut; }; template <> std::unique_ptr< PgTestDatabasePrepare > DbTestBase< PgUserTest >::_test_db = {}; using namespace sqlpp; TEST_F(PgUserTest, readAllAuthInfoData) { EXPECT_EQ(sut->uid(), uid); } TEST_F(PgUserTest, getIdentities) { EXPECT_TRUE(sut->authIdentities().byProvider("loginname")); } TEST_F(PgUserTest, getTokens) {}