Skip to content
Snippets Groups Projects
Commit 6eee767c authored by Nicolas Werner's avatar Nicolas Werner
Browse files

hom_server in login response is optional

Since it is depreated it will also be removed in the future.
Fixes #7
parent 1de9e3f9
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,9 @@ from_json(const json &obj, Login &response)
response.user_id = obj.at("user_id").get<User>();
response.access_token = obj.at("access_token").get<std::string>();
response.home_server = obj.at("home_server").get<std::string>();
if (obj.count("home_server") != 0)
response.home_server = obj.at("home_server").get<std::string>();
if (obj.count("device_id") != 0)
response.device_id = obj.at("device_id").get<std::string>();
......
......@@ -524,6 +524,16 @@ TEST(Responses, Login)
EXPECT_EQ(login2.access_token, "abc123");
EXPECT_EQ(login2.home_server, "matrix.org");
EXPECT_EQ(login2.device_id, "");
json data3 = R"({
"user_id": "@cheeky_monkey:matrix.org",
"access_token": "abc123"
})"_json;
Login login3 = data3;
EXPECT_EQ(login3.user_id.to_string(), "@cheeky_monkey:matrix.org");
EXPECT_EQ(login3.access_token, "abc123");
EXPECT_EQ(login3.home_server, "");
EXPECT_EQ(login3.device_id, "");
}
TEST(Responses, Messages)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment