From: Maxim Mamontov Date: Thu, 26 May 2011 16:42:09 +0000 (+0300) Subject: TEST_AUTH added X-Git-Tag: 2.408-alpha~125 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/0a3e4d188472ff4be7948d84a7d0be4c09169da2?ds=sidebyside TEST_AUTH added --- diff --git a/tests/test_reconnect_on_tariff_change.cpp b/tests/test_reconnect_on_tariff_change.cpp index a5f1ce73..87497f9f 100644 --- a/tests/test_reconnect_on_tariff_change.cpp +++ b/tests/test_reconnect_on_tariff_change.cpp @@ -7,6 +7,7 @@ #include "testtariffs.h" #include "testadmin.h" #include "teststore.h" +#include "testauth.h" class AFTER_CONNECTED_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { @@ -57,20 +58,33 @@ namespace tut TEST_TARIFFS tariffs; TEST_ADMIN admin; TEST_STORE store; + TEST_AUTH auth; USER_IMPL user(&settings, &store, &tariffs, &admin, NULL); AFTER_CONNECTED_NOTIFIER connectionNotifier; user.AddConnectedAfterNotifier(&connectionNotifier); + USER_PROPERTY & cash(user.GetProperty().cash); USER_PROPERTY & tariffName(user.GetProperty().tariffName); + USER_PROPERTY & ips(user.GetProperty().ips); + ips = StrToIPS("*"); + + ensure_equals("user.connected = false", user.GetConnected(), false); ensure_equals("connects = 0", connectionNotifier.GetConnects(), 0); ensure_equals("disconnects = 0", connectionNotifier.GetDisconnects(), 0); ensure_equals("user.tariffName == NO_TARIFF_NAME", user.GetProperty().tariffName.ConstData(), NO_TARIFF_NAME); + tariffName = "test"; ensure_equals("user.tariffName == 'test'", user.GetProperty().tariffName.ConstData(), "test"); + + user.Authorize(inet_strington("127.0.0.1"), 0, &auth); + + ensure_equals("user.connected = true", user.GetConnected(), true); + ensure_equals("connects = 1", connectionNotifier.GetConnects(), 1); + ensure_equals("disconnects = 0", connectionNotifier.GetDisconnects(), 0); } } diff --git a/tests/testauth.h b/tests/testauth.h new file mode 100644 index 00000000..f899e800 --- /dev/null +++ b/tests/testauth.h @@ -0,0 +1,34 @@ +#ifndef __TEST_AUTH_H__ +#define __TEST_AUTH_H__ + +#include "stg/auth.h" + +class TEST_AUTH : public AUTH { + public: + TEST_AUTH() {} + + void SetUsers(USERS * /*u*/) {} + void SetTariffs(TARIFFS * /*t*/) {} + void SetAdmins(ADMINS * /*a*/) {} + void SetTraffcounter(TRAFFCOUNTER * /*tc*/) {} + void SetStore(STORE * /*st*/) {} + void SetStgSettings(const SETTINGS * /*s*/) {} + void SetSettings(const MODULE_SETTINGS & /*s*/) {} + int ParseSettings() { return 0; } + + int Start() { return 0; } + int Stop() { return 0; } + int Reload() { return 0; } + bool IsRunning() { return true; } + const std::string & GetStrError() const { return strError; } + const std::string GetVersion() const { return ""; } + uint16_t GetStartPosition() const { return 0; } + uint16_t GetStopPosition() const { return 0; } + + int SendMessage(const STG_MSG & /*msg*/, uint32_t /*ip*/) const { return 0; } + + private: + std::string strError; +}; + +#endif