mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add test for UpdateUserInfo, fix CheckUsername Test
This commit is contained in:
parent
12188c77e8
commit
34162de1ed
@ -68,7 +68,6 @@ TEST(TestJsonCheckUsername, UsernameWithoutGroup)
|
||||
ASSERT_TRUE(msg.isString());
|
||||
ASSERT_EQ(msg.toString(), "no group given");
|
||||
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
@ -89,6 +88,8 @@ TEST(TestJsonCheckUsername, ExistingUsername)
|
||||
ASSERT_FALSE(msg.isEmpty());
|
||||
ASSERT_TRUE(msg.isString());
|
||||
ASSERT_EQ(msg.toString(), "username already in use");
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
TEST(TestJsonCheckUsername, NewUsername)
|
||||
@ -103,6 +104,8 @@ TEST(TestJsonCheckUsername, NewUsername)
|
||||
ASSERT_FALSE(state.isEmpty());
|
||||
ASSERT_TRUE(state.isString());
|
||||
ASSERT_EQ(state.toString(), "success");
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
TEST(TestJsonCheckUsername, UsernameExistInOtherGroup)
|
||||
@ -118,6 +121,7 @@ TEST(TestJsonCheckUsername, UsernameExistInOtherGroup)
|
||||
ASSERT_TRUE(state.isString());
|
||||
ASSERT_EQ(state.toString(), "success");
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "JSONInterface/JsonUpdateUserInfos.h"
|
||||
#include "TestJsonUpdateUserInfos.h"
|
||||
|
||||
|
||||
void TestJsonUpdateUserInfos::SetUp()
|
||||
{
|
||||
auto sm = SessionManager::getInstance();
|
||||
sm->init();
|
||||
mUserSession = sm->getNewSession();
|
||||
mUserSession->loadUser("Jeet_bb@gmail.com", "TestP4ssword&H");
|
||||
}
|
||||
|
||||
void TestJsonUpdateUserInfos::TearDown()
|
||||
{
|
||||
auto sm = SessionManager::getInstance();
|
||||
if (!mUserSession) {
|
||||
sm->releaseSession(mUserSession);
|
||||
}
|
||||
sm->deinitalize();
|
||||
}
|
||||
|
||||
Poco::JSON::Object::Ptr TestJsonUpdateUserInfos::chooseAccount(const Poco::JSON::Object::Ptr update)
|
||||
{
|
||||
Poco::JSON::Object::Ptr params = new Poco::JSON::Object;
|
||||
params->set("session_id", mUserSession->getHandle());
|
||||
params->set("email", mUserSession->getNewUser()->getModel()->getEmail());
|
||||
params->set("update", update);
|
||||
return params;
|
||||
}
|
||||
|
||||
TEST_F(TestJsonUpdateUserInfos, EmptyOldPassword)
|
||||
{
|
||||
JsonUpdateUserInfos jsonCall;
|
||||
Poco::JSON::Object::Ptr update = new Poco::JSON::Object;
|
||||
|
||||
update->set("User.password", "haLL1o_/%s");
|
||||
|
||||
auto params = chooseAccount(update);
|
||||
auto result = jsonCall.handle(params);
|
||||
|
||||
auto errors = result->get("errors");
|
||||
ASSERT_TRUE(errors.isArray());
|
||||
//User.password_old not found
|
||||
Poco::JSON::Array error_array = errors.extract<Poco::JSON::Array>();
|
||||
|
||||
ASSERT_EQ(error_array.size(), 1);
|
||||
ASSERT_EQ(error_array.getElement<std::string>(0), "User.password_old not found");
|
||||
|
||||
delete result;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
#ifndef __GRADIDO_LOGIN_SERVER_TEST_JSON_INTERFACE_TEST_JSON_UPDATE_USER_INFOS_H
|
||||
#define __GRADIDO_LOGIN_SERVER_TEST_JSON_INTERFACE_TEST_JSON_UPDATE_USER_INFOS_H
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "SingletonManager/SessionManager.h"
|
||||
|
||||
#include "Poco/JSON/Object.h"
|
||||
|
||||
class TestJsonUpdateUserInfos : public ::testing::Test
|
||||
{
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
Poco::JSON::Object::Ptr chooseAccount(const Poco::JSON::Object::Ptr update);
|
||||
|
||||
Session* mUserSession;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //__GRADIDO_LOGIN_SERVER_TEST_JSON_INTERFACE_TEST_JSON_UPDATE_USER_INFOS_H
|
||||
Loading…
x
Reference in New Issue
Block a user