mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
49
editor/osm_auth_tests/osm_auth_tests.cpp
Normal file
49
editor/osm_auth_tests/osm_auth_tests.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
#include "editor/osm_auth.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace osm_auth
|
||||
{
|
||||
using osm::OsmOAuth;
|
||||
|
||||
char const * kValidOsmUser = "OrganicMapsTestUser";
|
||||
char const * kValidOsmPassword = "12345678";
|
||||
static constexpr char const * kInvalidOsmPassword = "123";
|
||||
static constexpr char const * kForgotPasswordEmail = "osmtest1@organicmaps.app";
|
||||
|
||||
UNIT_TEST(OSM_Auth_InvalidLogin)
|
||||
{
|
||||
OsmOAuth auth = OsmOAuth::DevServerAuth();
|
||||
bool result;
|
||||
TEST_NO_THROW(result = auth.AuthorizePassword(kValidOsmUser, kInvalidOsmPassword), ());
|
||||
TEST_EQUAL(result, false, ("invalid password"));
|
||||
TEST(!auth.IsAuthorized(), ("Should not be authorized."));
|
||||
}
|
||||
|
||||
UNIT_TEST(OSM_Auth_Login)
|
||||
{
|
||||
OsmOAuth auth = OsmOAuth::DevServerAuth();
|
||||
bool result;
|
||||
TEST_NO_THROW(result = auth.AuthorizePassword(kValidOsmUser, kValidOsmPassword), ());
|
||||
TEST_EQUAL(result, true, ("login to test server"));
|
||||
TEST(auth.IsAuthorized(), ("Should be authorized."));
|
||||
OsmOAuth::Response const perm = auth.Request("/permissions");
|
||||
TEST_EQUAL(perm.first, OsmOAuth::HTTP::OK, ("permission request ok"));
|
||||
TEST_NOT_EQUAL(perm.second.find("write_api"), std::string::npos, ("can write to api"));
|
||||
}
|
||||
|
||||
/*
|
||||
UNIT_TEST(OSM_Auth_ForgotPassword)
|
||||
{
|
||||
OsmOAuth auth = OsmOAuth::DevServerAuth();
|
||||
bool result;
|
||||
TEST_NO_THROW(result = auth.ResetPassword(kForgotPasswordEmail), ());
|
||||
TEST_EQUAL(result, true, ("Correct email"));
|
||||
TEST_NO_THROW(result = auth.ResetPassword("not@registered.email"), ());
|
||||
TEST_EQUAL(result, false, ("Incorrect email"));
|
||||
}
|
||||
*/
|
||||
} // namespace osm_auth
|
||||
Reference in New Issue
Block a user