From b0b4a918a614a1868bbb12d0501578c046faa119 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 26 May 2011 20:07:22 +0300 Subject: [PATCH] Added TEST_USERS --- tests/test_reconnect_on_tariff_change.cpp | 6 +++- tests/testusers.h | 37 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/testusers.h diff --git a/tests/test_reconnect_on_tariff_change.cpp b/tests/test_reconnect_on_tariff_change.cpp index 87497f9f..da0804ea 100644 --- a/tests/test_reconnect_on_tariff_change.cpp +++ b/tests/test_reconnect_on_tariff_change.cpp @@ -8,6 +8,7 @@ #include "testadmin.h" #include "teststore.h" #include "testauth.h" +#include "testusers.h" class AFTER_CONNECTED_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { @@ -59,7 +60,8 @@ namespace tut TEST_ADMIN admin; TEST_STORE store; TEST_AUTH auth; - USER_IMPL user(&settings, &store, &tariffs, &admin, NULL); + TEST_USERS users; + USER_IMPL user(&settings, &store, &tariffs, &admin, &users); AFTER_CONNECTED_NOTIFIER connectionNotifier; @@ -82,6 +84,8 @@ namespace tut user.Authorize(inet_strington("127.0.0.1"), 0, &auth); + ensure_equals("user.authorised_by = true", user.IsAuthorizedBy(&auth), true); + 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/testusers.h b/tests/testusers.h new file mode 100644 index 00000000..1250ae49 --- /dev/null +++ b/tests/testusers.h @@ -0,0 +1,37 @@ +#ifndef __TEST_USERS_H__ +#define __TEST_USERS_H__ + +class TEST_USERS : public USERS { + public: + TEST_USERS() {} + + int FindByName(const std::string & /*login*/, USER_PTR * /*user*/) { return -1; } + + bool TariffInUse(const std::string & /*tariffName*/) const { return -1; } + + void AddNotifierUserAdd(NOTIFIER_BASE * /*notifier*/) {} + void DelNotifierUserAdd(NOTIFIER_BASE * /*notifier*/) {} + + void AddNotifierUserDel(NOTIFIER_BASE * /*notifier*/) {} + void DelNotifierUserDel(NOTIFIER_BASE * /*notifier*/) {} + + int Add(const std::string & /*login*/, const ADMIN * /*admin*/) { return 0; } + void Del(const std::string & /*login*/, const ADMIN * /*admin*/) {} + + int ReadUsers() { return 0; } + int GetUserNum() const { return 0; } + + int FindByIPIdx(uint32_t /*ip*/, USER_PTR * /*user*/) const { return -1; } + bool IsIPInIndex(uint32_t /*ip*/) const { return false; } + + int OpenSearch() { return 0; } + int SearchNext(int /*handle*/, USER_PTR * /*u*/) { return -1; } + int CloseSearch(int /*handle*/) { return 0; } + + int Start() { return 0; } + int Stop() { return 0; } + + private: +}; + +#endif -- 2.43.2