Exemple #1
0
 public void SetupTestSite()
 {
     _inputcontext = new FullInputContext("");
     _testSite = new Site(1, "h2g2", 0, false, "brunel", true, "H2G2", "h2g2",
                 "*****@*****.**", "*****@*****.**", "*****@*****.**", 1090497224, false, true, true, "", "Alert", 2000, 1090497224, 0,
                 1, 1, false, false, 16, 255, 1, "h2g2", false, "brunel", "", "");
 }
Exemple #2
0
		public void TestAbsentSkinParams()
		{
            Console.WriteLine("TestAbsentSkinParams");
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                inputcontext.SetCurrentSite("h2g2");
                inputcontext.InitDefaultUser();

                inputcontext.AddParam("notaskinparam", "abcde");
                inputcontext.AddParam("ss_not", "doesn't matter");

                SkinParams sparams = new SkinParams(inputcontext);
                sparams.ProcessRequest();
                DnaXmlValidator validator = new DnaXmlValidator(sparams.RootElement.InnerXml, _schemaUri);
                validator.Validate();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(sparams.RootElement.OuterXml);

                XmlNode node = doc.SelectSingleNode("/DNAROOT/PARAMS");
                Assert.IsNotNull(node, "No PARAMS element found");
                XmlNodeList nodes = doc.SelectNodes("/DNAROOT/PARAMS/PARAM");

                Assert.IsNotNull(nodes, "Unable to find /DNAROOT/PARAMS/PARAM");

                Assert.IsTrue(nodes.Count == 0, string.Format("Expecting 0 s_ params in query, found {0}", nodes.Count));
            }
		}
Exemple #3
0
        public void StartUp()
        {
            SnapshotInitialisation.RestoreFromSnapshot();
            FullInputContext context = new FullInputContext("");

            _siteList = context.SiteList;
        }
 public void Initialise()
 {
     using(var context = new FullInputContext(""))
     {
         var ug = new BBC.Dna.Users.UserGroups(context.ReaderCreator, context.Diagnostics, CacheFactory.GetCacheManager(), null, null);
     }
 }
Exemple #5
0
        public void Setup()
        {
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                _appContext = new AppContext(TestConfig.GetConfig().GetRipleyServerPath());
                _siteOptionList = new SiteOptionList();
                _siteOptionList.CreateFromDatabase(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics);
            }
            
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();
            IInputContext inputContext = DnaMockery.CreateDatabaseInputContext();
            using (IDnaDataReader dataReader = inputContext.CreateDnaDataReader(""))
            {
                SetSiteID(dataReader, "h2g2");

                _includeContentFromOtherSites = _siteOptionList.GetValueBool(_siteId, "PersonalSpace", "IncludeContentFromOtherSites");

                //Create a post on h2g2
                SetForumID(dataReader);
                request = new DnaTestURLRequest("h2g2");
                request.SetCurrentUserNormal();
                int id = request.CurrentUserID;
                request.RequestPage("AddThread?subject=test&body=blahblah&post=1&skin=purexml&forum=" + Convert.ToString(_forumId));

                //Create a post on have your say.
                SetSiteID(dataReader, "haveyoursay");
                SetForumID(dataReader);
                request = new DnaTestURLRequest("haveyoursay");
                request.SetCurrentUserNormal();
                request.RequestPage("AddThread?subject=test&body=blahblah&post=1&skin=purexml&forum=" + Convert.ToString(_forumId));
            }
        }
 public void Test01CreateAUserFromDNAUserID()
 {
     FullInputContext context = new FullInputContext(true);
     User user = new User(null, null, null);
     Assert.IsTrue(user.CreateUserFromDnaUserID(TestUserAccounts.GetModeratorAccount.UserID, 1));
     Assert.IsTrue(user.IsUserA(UserTypes.Moderator));
     Assert.IsFalse(user.IsUserA(UserTypes.Editor));
 }
Exemple #7
0
 public void Test2LoadSiteListTest()
 {
     Console.WriteLine("Test2LoadSiteListTest");
     using (FullInputContext inputcontext = new FullInputContext(""))
     {
         SiteList testSiteList = new SiteList(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(),null, null);
         _siteListloaded = true;
     }
 }
Exemple #8
0
 public void Test3GetSiteh2g2byidTest()
 {
     Console.WriteLine("Test3GetSiteh2g2byidTest");
     using (FullInputContext inputcontext = new FullInputContext(""))
     {
         Site h2g2 = (Site)_testSiteList.GetSite(1);
         Assert.AreEqual(h2g2.SiteName, "h2g2");
     }
 }
Exemple #9
0
  /// <summary>
  /// Constructor for the User Tests to set up the context for the tests
  /// </summary>
  public UserTests()
  {
      using (FullInputContext fullinputcontext = new FullInputContext(TestUserAccounts.GetProfileAPITestUserAccount.UserName))
      {
          fullinputcontext.SetCurrentSite("h2g2");
          fullinputcontext.InitUserFromCookie(TestUserAccounts.GetProfileAPITestUserAccount.Cookie, TestUserAccounts.GetProfileAPITestUserAccount.SecureCookie);
          _testUser = (User)fullinputcontext.ViewingUser;
      }
 }
Exemple #10
0
 /// <summary>
 /// Constructor
 /// </summary>
 public CommentCreateTests()
 {
     using (FullInputContext inputcontext = new FullInputContext(""))
     {
         _siteList = SiteList.GetSiteList();
         site = _siteList.GetSite("h2g2");
         _comments = new Comments(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
     }
     
 }
Exemple #11
0
 public void StartUp()
 {
     SnapshotInitialisation.RestoreFromSnapshot();
     DnaTestURLRequest testUserReq = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
     testUserReq.SetCurrentUserNormal();
     clearFromDB(testUserReq);
     using (FullInputContext inputContext = new FullInputContext(""))
     {
         inputContext.SendSignal("action=recache-groups");
     }
 }
Exemple #12
0
 public void Test02SignUserInViaIdentityCookie()
 {
     FullInputContext context = new FullInputContext(true);
     SignInSystem signInType = SignInSystem.Identity;
     CallingUser user = new CallingUser(signInType, null, null, null, context.SiteList);
     string cookie = TestUserAccounts.GetModeratorAccount.Cookie;
     string policy = "http://identity/policies/dna/adult";
     int siteID = 1;
     Assert.IsTrue(user.IsUserSignedIn(cookie, policy, siteID, ""));
     Assert.IsTrue(user.IsUserA(UserTypes.Moderator));
     Assert.IsFalse(user.IsUserA(UserTypes.Editor));
 }
Exemple #13
0
 private void TestValidUserIsLoggedIn()
 {
     Console.WriteLine("TestValidUserIsLoggedIn");
     // Create the profile connection first
     using (FullInputContext inputContext = new FullInputContext(false))
     {
         IDnaIdentityWebServiceProxy testProfile = inputContext.GetCurrentSignInObject;
         testProfile.SetService("h2g2");
         testProfile.TrySetUserViaCookie("44c5a3037b5a65b37bbef0f591cdf10e1d9e59903823a0cb01270e7da41e8e3b00");
         Assert.IsTrue(testProfile.IsUserLoggedIn, "User should be logged in.");
     }
 }
Exemple #14
0
 public void StartUp()
 {
     Console.WriteLine("Signal Test StartUp");
     // First get the open close times for the h2g2 site
     SnapshotInitialisation.RestoreFromSnapshot();
     SetSiteEmergencyClosed(false);
     using (FullInputContext inputContext = new FullInputContext(false))
     {
         inputContext.SendSignal("action=recache-site");
     }
     
 }
Exemple #15
0
 public void Test02SignUserInViaIdentityCookie()
 {
     FullInputContext context = new FullInputContext("");
     SignInSystem signInType = SignInSystem.Identity;
     CallingUser user = new CallingUser(signInType, null, null, null, TestUserAccounts.GetModeratorAccount.UserName, context.SiteList);
     string cookie = TestUserAccounts.GetModeratorAccount.Cookie;
     string policy = "comment";
     int siteID = 1;
     Assert.IsTrue(user.IsUserSignedIn(cookie, policy, siteID, "", null, Guid.Empty));
     Assert.IsTrue(user.IsUserA(UserTypes.Moderator));
     Assert.IsFalse(user.IsUserA(UserTypes.Editor));
 }
        public void TestsSetup()
        {
            //SnapshotInitialisation.ForceRestore();
            using (FullInputContext _context = new FullInputContext(""))
            {
                dnaDiagnostics = _context.dnaDiagnostics;
                readerCreator = new DnaDataReaderCreator(_context.DnaConfig.ConnectionString, dnaDiagnostics);
            }
            var bannedEmails = new BannedEmails(readerCreator, dnaDiagnostics, _emailCache, null, null);

            bannedEmails.Clear();
        }
        public void Setup()
        {
            SnapshotInitialisation.RestoreFromSnapshot();

            using (FullInputContext _context = new FullInputContext(""))
            {

                using (IDnaDataReader dataReader = _context.CreateDnaDataReader(""))
                {
                    dataReader.ExecuteDEBUGONLY("update threadentries set hidden=null where entryid=" + _postId.ToString());
                }
            }
        }
Exemple #18
0
 private static void InitialiseSiteList()
 {
     if (!_siteListloaded)
     {
         using (FullInputContext inputcontext = new FullInputContext(""))
         {
             _testSiteList = SiteList.GetSiteList();
             inputcontext.SetCurrentSite("h2g2");
             inputcontext.InitDefaultUser();
             _siteListloaded = true;
         }
     }
 }
Exemple #19
0
        /// <summary>
        /// Constructor
        /// </summary>
        public RatingForumTests()
        {
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                _siteList = SiteList.GetSiteList();
                site = _siteList.GetSite("h2g2");

                _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
                var b = new BannedEmails(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);
                var g = new UserGroups(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);
            }
            
        }
Exemple #20
0
 public void Test03SignUserInAndAddThemToAcesGroup()
 {
     FullInputContext context = new FullInputContext(true);
     SignInSystem signInType = SignInSystem.Identity;
     CallingUser user = new CallingUser(signInType, context.ReaderCreator, null, null, context.SiteList);
     string cookie = TestUserAccounts.GetModeratorAccount.Cookie;
     string policy = "http://identity/policies/dna/adult";
     int siteID = 1;
     Assert.IsTrue(user.IsUserSignedIn(cookie, policy, siteID, ""));
     Assert.IsTrue(user.IsUserA(UserTypes.Moderator));
     Assert.IsFalse(user.GetUsersGroupsForSite().Exists(x => x.Name == "aces"));
     Assert.IsTrue(user.AddUserToGroup("Aces"));
     Assert.IsTrue(user.GetUsersGroupsForSite().Exists(x => x.Name == "aces"));
 }
Exemple #21
0
		public void TestSkinParams()
		{
            Console.WriteLine("TestSkinParams");
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                inputcontext.SetCurrentSite("h2g2");
                inputcontext.InitDefaultUser();

                inputcontext.AddParam("s_abcde", "xyzzy");
                inputcontext.AddParam("notaskinparam", "abcde");
                inputcontext.AddParam("s_xxxxx", "plugh");
                inputcontext.AddParam("ss_not", "doesn't matter");

                SkinParams sparams = new SkinParams(inputcontext);
                sparams.ProcessRequest();
                DnaXmlValidator validator = new DnaXmlValidator(sparams.RootElement.InnerXml, _schemaUri);
                validator.Validate();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(sparams.RootElement.OuterXml);

                XmlNode node = doc.SelectSingleNode("/DNAROOT/PARAMS");
                Assert.IsNotNull(node, "No PARAMS element found");
                XmlNodeList nodes = doc.SelectNodes("/DNAROOT/PARAMS/PARAM");

                Assert.IsNotNull(nodes, "Unable to find /DNAROOT/PARAMS/PARAM");

                Assert.IsTrue(nodes.Count == 2, string.Format("Expecting 2 s_ params in query, found {0}", nodes.Count));

                foreach (XmlNode subnode in nodes)
                {
                    XmlNode name = subnode.SelectSingleNode("NAME");
                    XmlNode value = subnode.SelectSingleNode("VALUE");
                    Assert.IsNotNull(name, "NAME missing from PARAM object");
                    Assert.IsNotNull(value, "VALUE missing from PARAM object");
                    if (name.InnerText == "s_abcde")
                    {
                        Assert.AreEqual(value.InnerText, "xyzzy", "s_abcde value doesn't match");
                    }
                    else if (name.InnerText == "s_xxxxx")
                    {
                        Assert.AreEqual(value.InnerText, "plugh", "Value of s_xxxxx doesn't match");
                    }
                    else
                    {
                        Assert.Fail(string.Format("Unexpected param found: {0}", name.InnerText));
                    }
                }
            }
		}
Exemple #22
0
 public void Test03SignUserInAndAddThemToAcesGroup()
 {
     FullInputContext context = new FullInputContext("dotnetmoderator");
     SignInSystem signInType = SignInSystem.Identity;
     CallingUser user = new CallingUser(signInType, context.ReaderCreator, null, null, TestUserAccounts.GetModeratorAccount.UserName, context.SiteList);
     string cookie = TestUserAccounts.GetModeratorAccount.Cookie;
     string policy = "comment";
     int siteID = 1;
     Assert.IsTrue(user.IsUserSignedIn(cookie, policy, siteID, TestUserAccounts.GetModeratorAccount.UserName, null, Guid.Empty));
     Assert.IsTrue(user.IsUserA(UserTypes.Moderator));
     Assert.IsFalse(user.GetUsersGroupsForSite().Exists(x => x.Name == "aces"));
     Assert.IsTrue(user.AddUserToGroup("Aces"));
     Assert.IsTrue(user.GetUsersGroupsForSite().Exists(x => x.Name.ToLower() == "aces"));
 }
Exemple #23
0
        public void LogoutProfileAPITestUserSetUp()
        {
            using (FullInputContext inputContext = new FullInputContext(false))
            {
                IDnaIdentityWebServiceProxy testProfile = inputContext.GetCurrentSignInObject;
                testProfile.SetService("h2g2");
                testProfile.TrySetUserViaCookie("44c5a3037b5a65b37bbef0f591cdf10e1d9e59903823a0cb01270e7da41e8e3b00");
                if (testProfile.IsUserLoggedIn)
                {
#if DEBUG
                    testProfile.LogoutUser();
#endif
                }
            }
        }
Exemple #24
0
        public void StartUp()
        {
            SnapshotInitialisation.RestoreFromSnapshot();
            _context = new FullInputContext("");

            _siteList = _context.SiteList;

            // Create a comment forums to post tweets to, and the corresponding URLs
            CommentsTests_V1 ct = new CommentsTests_V1();
            _commentForumReactive = ct.CommentForumCreate("Tests Reactive", Guid.NewGuid().ToString(),ModerationStatus.ForumStatus.Reactive);
            _tweetPostUrlReactive= String.Format("http://" + _server + "/dna/api/comments/TwitterService.svc/V1/site/{0}/commentsforums/{1}/",_sitename, _commentForumReactive.Id);

            _commentForumPremod = ct.CommentForumCreate("Tests Premod", Guid.NewGuid().ToString(),ModerationStatus.ForumStatus.PreMod);
            _tweetPostUrlPremod = String.Format("http://" + _server + "/dna/api/comments/TwitterService.svc/V1/site/{0}/commentsforums/{1}/", _sitename, _commentForumPremod.Id);
        }
Exemple #25
0
 public void StartUp()
 {
     SnapshotInitialisation.RestoreFromSnapshot();
     Statistics.InitialiseIfEmpty(null, false);
     using (FullInputContext inputcontext = new FullInputContext(""))
     {
         var p = new ProfanityFilter(DnaMockery.CreateDatabaseReaderCreator(), null, CacheFactory.GetCacheManager(), null, null);
         var b = new BannedEmails(DnaMockery.CreateDatabaseReaderCreator(), null, CacheFactory.GetCacheManager(), null, null);
         var g = new UserGroups(DnaMockery.CreateDatabaseReaderCreator(), null, CacheFactory.GetCacheManager(), null, null);
         _siteList = SiteList.GetSiteList();
         site = _siteList.GetSite("h2g2");
         site.IsEmergencyClosed = false;
         _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
     }
 }
Exemple #26
0
 public void TearDown()
 {
     if (_siteOptionList.GetValueBool(_siteId, "PersonalSpace", "IncludeContentFromOtherSites") !=  _includeContentFromOtherSites)
     {
         using (FullInputContext inputcontext = new FullInputContext(""))
         {
             //Reset to initial value.
             _siteOptionList.SetValueBool(_siteId, "PersonalSpace", "IncludeContentFromOtherSites", _includeContentFromOtherSites, inputcontext.ReaderCreator, inputcontext.dnaDiagnostics);
         }
         
         //Recache Site Data.
         DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
         request.SetCurrentUserNormal();
         int id = request.CurrentUserID;
         request.RequestPage("U" + id.ToString() + "?_ns=1&skin=purexml");
     }
 }
Exemple #27
0
        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);
            }
        }
Exemple #28
0
        /// <summary>
        /// Remove all the groups from the user given in the parameter
        /// </summary>
        /// <param name="testUserReq">the user to be affected</param>
        private void clearFromDB(DnaTestURLRequest testUserReq)
        {
            using (FullInputContext inputcontext = new FullInputContext(true))
            {
                using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
                {
                    ISiteList _siteList = SiteList.GetSiteList();
                    ISite site = _siteList.GetSite(testUtils_CommentsAPI.sitename);

                    string sqlStr = "delete from GroupMembers where UserId=" + testUserReq.CurrentUserID;
                    reader.ExecuteDEBUGONLY(sqlStr);

                    sqlStr = "select * from GroupMembers where UserId=" + testUserReq.CurrentUserID;
                    reader.ExecuteDEBUGONLY(sqlStr);

                    Assert.IsFalse(reader.HasRows, "Error clearing the databse. The user whoulc have no rows in the groupMembers table");
                }
            }
        }
        public void StartUp()
        {
            SnapshotInitialisation.RestoreFromSnapshot();
            Statistics.InitialiseIfEmpty(null,false);
            Statistics.ResetCounters();

            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
                {//force processpremod out...
                    reader.ExecuteDEBUGONLY("delete from siteoptions where SiteID=1 and Name='ProcessPreMod'");
                }
                _siteList = SiteList.GetSiteList();
                site = _siteList.GetSite("h2g2");

                _comments = new Comments(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
                var bannedEmails = new BannedEmails(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);//no sending signals from here
                var userGroups = new UserGroups(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);//no sending signals from here
                var profanityFilter = new ProfanityFilter(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);//no sending signals from here            
            }
        }
        /// <summary>
        /// find out the mod class of the site that we are using
        /// </summary>
        /// <param name="siteName">short name of site to find out about</param>
        /// <returns>the mod class of that site</returns>
        private int getModClass(string siteName)
        {
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
                {
                    ISiteList _siteList = SiteList.GetSiteList();
                    ISite site = _siteList.GetSite(testUtils_CommentsAPI.sitename);

                    string sqlStr = "select ModClassId FROM Sites WHERE shortname ='" + siteName + "'";

                    reader.ExecuteDEBUGONLY(sqlStr);

                    Assert.IsTrue(reader.HasRows);

                    reader.Read();

                    return reader.GetInt32("ModClassId");
                }
            }
        }