public void Setup() { SnapshotInitialisation.ForceRestore(); ICacheManager groupsCache = new StaticCacheManager(); var g = new UserGroups(DnaMockery.CreateDatabaseReaderCreator(), DnaDiagnostics.Default, groupsCache,null, null); var b = new BannedEmails(DnaMockery.CreateDatabaseReaderCreator(), DnaDiagnostics.Default, groupsCache, null, null); }
public void Setup() { SnapshotInitialisation.ForceRestore(); ICacheManager groupsCache = new StaticCacheManager(); g = new UserGroups(DnaMockery.CreateDatabaseReaderCreator(), _context.dnaDiagnostics, groupsCache, null, null); }
public void StartUp() { Statistics.InitialiseIfEmpty(null,false); SnapshotInitialisation.RestoreFromSnapshot(); ICacheManager groupsCache = new StaticCacheManager(); var g = new UserGroups(DnaMockery.CreateDatabaseReaderCreator(), null, groupsCache, null, null); var p = new ProfanityFilter(DnaMockery.CreateDatabaseReaderCreator(), null, groupsCache, null, null); var b = new BannedEmails(DnaMockery.CreateDatabaseReaderCreator(), null, groupsCache, null, null); }
protected void Application_Start(object sender, EventArgs e) { //System.Diagnostics.Debugger.Launch(); if (ConfigurationManager.AppSettings["MaintenanceMode"] == "1") {//do nothing if in maintenance return; } Statistics.InitialiseIfEmpty(null, false); dnaDiagnostics = new DnaDiagnostics(RequestIdGenerator.GetNextRequestId(), DateTime.Now); connectionString = ConfigurationManager.ConnectionStrings["Database"].ConnectionString; readerCreator = new DnaDataReaderCreator(connectionString, dnaDiagnostics); try { emailServerAddress = ConfigurationManager.AppSettings["EmailServer"]; } catch { dnaDiagnostics.WriteWarningToLog("BBC.Dna.Services.Application_Start", "Unable to find config email server address - no emails will be sent!"); } try { fileCacheFolder = ConfigurationManager.AppSettings["FileCacheFolder"]; } catch { fileCacheFolder = Environment.GetEnvironmentVariable("Temp"); dnaDiagnostics.WriteWarningToLog("BBC.Dna.Services.Application_Start", "Unable to find config file cache folder - Defaulting to the system temp folder!"); } ICacheManager cacheManager = null; try { cacheManager = CacheFactory.GetCacheManager("Memcached"); } catch (Exception error) { dnaDiagnostics.WriteWarningToLog("BBC.Dna.Services.Application_Start", "Unable to use memcached cachemanager - falling back to static inmemory"); dnaDiagnostics.WriteExceptionToLog(error); cacheManager = new StaticCacheManager(); } siteList = new SiteList(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here var bannedEmails = new BannedEmails(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here var userGroups = new UserGroups(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here var profanityFilter = new ProfanityFilter(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here var moderationClasses = new ModerationClassListCache(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here BBC.Dna.Objects.SmileyTranslator.LoadSmileys(readerCreator); }
public void StartUp() { SnapshotInitialisation.ForceRestore(); Statistics.InitialiseIfEmpty(); using (FullInputContext inputcontext = new FullInputContext("")) { _siteList = SiteList.GetSiteList(); site = _siteList.GetSite("h2g2"); _comments = new Comments(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList); ICacheManager groupsCache = new StaticCacheManager(); var g = new UserGroups(DnaMockery.CreateDatabaseReaderCreator(), null, groupsCache, null, null); var p = new ProfanityFilter(DnaMockery.CreateDatabaseReaderCreator(), null, groupsCache, null, null); var b = new BannedEmails(DnaMockery.CreateDatabaseReaderCreator(), null, groupsCache, null, null); } }
public void Test03RemoveUserFromGroup() { ICacheManager groupsCache = new StaticCacheManager(); // Get the groups for the given user on the given site List<UserGroup> details = g.GetUsersGroupsForSite(_userID, 1); Assert.IsNotNull(details, "Failed to get the group details for user " + _userID.ToString() + " for site 1"); int itemCount = details.Count; // Now remove the user from the aces group g.DeleteUserFromGroup(_userID, "bestnewbie", 1); // Check to make sure that the user was added correctly details = g.GetUsersGroupsForSite(_userID, 1); Assert.IsNotNull(details, "Failed to get the group details for user " + _userID.ToString() + " for site 1"); Assert.AreEqual(itemCount - 1, details.Count, "There should be one less group in the list for the user"); Assert.IsFalse(details.Exists(x => x.Name =="bestnewbie"), "The list contains the Mentor group"); }
/// <summary> /// Designed to be called once at application Start-up /// </summary> /// <param name="rootPath">The folder that's the root of the application</param> public static void OnDnaStartup(string rootPath) { #if DEBUG /************************************** * * * DEBUGGING FROM THE WORD GO! * * * **************************************/ // System.Diagnostics.Debugger.Launch(); #endif _appContext = new AppContext(rootPath); _dnaCacheManager = CacheFactory.GetCacheManager(); DnaDiagnostics.Initialise(TheAppContext.Config.InputLogFilePath, "DNALOG"); #if DEBUG DnaDiagnostics.WriteHeader("OnDnaStartup - DEBUG"); #else DnaDiagnostics.WriteHeader("OnDnaStartup - RELEASE"); #endif Statistics.InitialiseIfEmpty(/*TheAppContext*/); //load the smiley list SmileyTranslator.LoadSmileys(ReaderCreator); ICacheManager cacheMemcachedManager = null; try { cacheMemcachedManager = CacheFactory.GetCacheManager("Memcached"); } catch (Exception error) { DnaDiagnostics.Default.WriteWarningToLog("OnDnaStartup", "Unable to use memcached cachemanager - falling back to static inmemory"); DnaDiagnostics.Default.WriteExceptionToLog(error); cacheMemcachedManager = new StaticCacheManager(); } //new signal objects below here _appContext.TheSiteList = new SiteList(AppContext.ReaderCreator, DnaDiagnostics.Default, cacheMemcachedManager, TheAppContext._dnaConfig.RipleyServerAddresses, TheAppContext._dnaConfig.DotNetServerAddresses); var bannedEmails = new BannedEmails(AppContext.ReaderCreator, DnaDiagnostics.Default, cacheMemcachedManager, TheAppContext._dnaConfig.RipleyServerAddresses, TheAppContext._dnaConfig.DotNetServerAddresses); var userGroups = new UserGroups(AppContext.ReaderCreator, DnaDiagnostics.Default, cacheMemcachedManager, TheAppContext._dnaConfig.RipleyServerAddresses, TheAppContext._dnaConfig.DotNetServerAddresses); var profanityFilter = new ProfanityFilter(AppContext.ReaderCreator, DnaDiagnostics.Default, cacheMemcachedManager, TheAppContext._dnaConfig.RipleyServerAddresses, TheAppContext._dnaConfig.DotNetServerAddresses); var moderationClasses = new ModerationClassListCache(AppContext.ReaderCreator, DnaDiagnostics.Default, cacheMemcachedManager, TheAppContext._dnaConfig.RipleyServerAddresses, TheAppContext._dnaConfig.DotNetServerAddresses); // Setup the banned user agents list InitialiseBannedUserAgents(); }
private void SetupSiteForIdentityLogin() { /*using (IDnaDataReader reader = DnaMockery.CreateDatabaseInputContext().CreateDnaDataReader("")) { StringBuilder sql = new StringBuilder("exec setsiteoption 1,'SignIn','UseIdentitySignIn','1'"); sql.AppendLine("UPDATE Sites SET IdentityPolicy='comment' WHERE SiteID=1"); reader.ExecuteDEBUGONLY(sql.ToString()); } using (FullInputContext inputContext = new FullInputContext("")) {//send signal inputContext.SendSignal("action=recache-site"); _siteList = SiteList.GetSiteList(DnaMockery.CreateDatabaseReaderCreator(), null); }*/ ICacheManager groupsCache = new StaticCacheManager(); var g = new UserGroups(DnaMockery.CreateDatabaseReaderCreator(), null, groupsCache, null, null); }
public void PostHistory_GetPostHistoryAsSuperUserForAnonymousComplaint_ExpectFullComplainantDetails() { using (new TransactionScope()) { IInputContext context = DnaMockery.CreateDatabaseInputContext(); ICacheManager groupsCache = new StaticCacheManager(); var g = new BBC.Dna.Users.UserGroups(DnaMockery.CreateDatabaseReaderCreator(), null, groupsCache, null, null); int postId = 61; int userId = 0; int modId = 0; string email = "*****@*****.**"; string complaintText = "This is testing that the complainant details are correctly displayed"; string IpAddress = "192.168.238.1"; Guid BBCUid = new Guid(); ISite site = DnaMockery.CreateMockedSite(context, 1, "h2g2", "h2g2", true, "comment"); modId = RegisterTestComplaint(context, postId, userId, modId, email, complaintText, IpAddress, BBCUid); ISiteList siteList = DnaMockery.CurrentMockery.NewMock<ISiteList>(); Stub.On(siteList).Method("GetSite").With(70).Will(Return.Value(site)); Stub.On(context).Method("GetParamStringOrEmpty").With("reference", "reference").Will(Return.Value("")); Stub.On(context).Method("GetParamIntOrZero").With("postid", "postid").Will(Return.Value(postId)); Stub.On(context).Method("GetParamIntOrZero").With("h2g2id", "h2g2id").Will(Return.Value(0)); Stub.On(context).Method("GetParamStringOrEmpty").With("exlinkurl", "exlinkurl").Will(Return.Value("")); Stub.On(context).GetProperty("TheSiteList").Will(Return.Value(siteList)); IDnaDataReaderCreator creator = DnaMockery.CreateDatabaseReaderCreator(); AppContext.ReaderCreator = creator; IUser viewingUser = DnaMockery.CurrentMockery.NewMock<IUser>(); Stub.On(viewingUser).GetProperty("IsSuperUser").Will(Return.Value(true)); Stub.On(context).GetProperty("ViewingUser").Will(Return.Value(viewingUser)); ModerationHistory history = new ModerationHistory(context); history.ProcessRequest(); XmlNode modHistory = history.RootElement.SelectSingleNode("//MODERATION-HISTORY"); Assert.IsNotNull(modHistory, "Failed to find the moderation history node"); XmlNode modItem = modHistory.SelectSingleNode("MODERATION[@MODID='" + modId + "']"); Assert.IsNotNull(modItem, "Failed to find the moderation node for the complaint."); Assert.IsNotNull(modItem.SelectSingleNode("COMPLAINT/IPADDRESS"), "Failed to find complaint ipaddress"); Assert.AreEqual(IpAddress, modItem.SelectSingleNode("COMPLAINT/IPADDRESS").InnerText); Assert.IsNotNull(modItem.SelectSingleNode("COMPLAINT/COMPLAINT-TEXT"), "Failed to find complaint text"); Assert.AreEqual(complaintText, modItem.SelectSingleNode("COMPLAINT/COMPLAINT-TEXT").InnerText); Assert.IsNotNull(modItem.SelectSingleNode("COMPLAINT/BBCUID"), "Failed to find complaint BBCUID"); Assert.AreEqual(BBCUid.ToString(), modItem.SelectSingleNode("COMPLAINT/BBCUID").InnerText); Assert.IsNotNull(modItem.SelectSingleNode("COMPLAINT/EMAIL-ADDRESS"), "Failed to find complaint email address"); Assert.AreEqual(email, modItem.SelectSingleNode("COMPLAINT/EMAIL-ADDRESS").InnerText); XmlNode complainantUser = modItem.SelectSingleNode("COMPLAINT/USER"); Assert.IsNull(complainantUser, "There shouldn't be a complainant user block"); } }