+ Settings settings(true);
+
+ TestSettings * s1 = &settings;
+ STG::Settings * s2 = &settings;
+
+ BOOST_CHECK(settings.GetReconnectOnTariffChange());
+ BOOST_CHECK(s1->GetReconnectOnTariffChange());
+ BOOST_CHECK(s2->GetReconnectOnTariffChange());
+
+ TestTariffs tariffs;
+ STG::Admin admin(STG::Priv(0xFFFF), {}, {});
+ TestStore store;
+ TestAuth auth;
+ TestUsers users;
+ TestServices services;
+ STG::UserImpl user(&settings, &store, &tariffs, &admin, &users, services);
+
+ AfterConnectedNotifier connectionNotifier;
+
+ user.AddConnectedAfterNotifier(&connectionNotifier);
+
+ STG::UserProperty<std::string> & tariffName = user.GetProperties().tariffName;
+ STG::UserProperty<STG::UserIPs> & ips = user.GetProperties().ips;
+
+ ips = STG::UserIPs::parse("*");
+
+ BOOST_CHECK_EQUAL(user.GetConnected(), false);
+ BOOST_CHECK_EQUAL(connectionNotifier.connects(), static_cast<size_t>(0));
+ BOOST_CHECK_EQUAL(connectionNotifier.disconnects(), static_cast<size_t>(0));
+
+ BOOST_CHECK_EQUAL(user.GetProperties().tariffName.ConstData(), NO_TARIFF_NAME);
+
+ user.Authorize(inet_strington("127.0.0.1"), 0, &auth);
+ user.Run();
+
+ BOOST_CHECK_EQUAL(user.IsAuthorizedBy(&auth), true);
+
+ BOOST_CHECK_EQUAL(user.GetConnected(), true);
+ BOOST_CHECK_EQUAL(connectionNotifier.connects(), static_cast<size_t>(1));
+ BOOST_CHECK_EQUAL(connectionNotifier.disconnects(), static_cast<size_t>(0));
+
+ tariffName = "test";
+ BOOST_CHECK_EQUAL(user.GetProperties().tariffName.ConstData(), "test");
+
+ BOOST_CHECK_EQUAL(user.IsAuthorizedBy(&auth), true);
+
+ BOOST_CHECK_EQUAL(user.GetConnected(), true);
+ BOOST_CHECK_EQUAL(connectionNotifier.connects(), static_cast<size_t>(2));
+ BOOST_CHECK_EQUAL(connectionNotifier.disconnects(), static_cast<size_t>(1));