Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
49
libs/editor/osm_auth_tests/osm_auth_tests.cpp
Normal file
49
libs/editor/osm_auth_tests/osm_auth_tests.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "editor/osm_auth.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace osm_auth
|
||||
{
|
||||
using osm::OsmOAuth;
|
||||
|
||||
char const * kValidOsmUser = "CoMapsTestUser";
|
||||
char const * kValidOsmPassword = "12345678";
|
||||
static constexpr char const * kInvalidOsmPassword = "123";
|
||||
static constexpr char const * kForgotPasswordEmail = "osmtest1@comaps.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
|
||||
Loading…
Add table
Add a link
Reference in a new issue