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)); }
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 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")); }
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")); }
public void UserDoesNotGetsUDNGNameSetFromDisplayNameForNonKidsSiteUsingIDv4() { string cookie = "debugcookie"; string policy = "u16comments"; int siteID = 1; string identityUserName = TestUserAccounts.GetNormalUserAccount.UserName; string dnaUserName = "******"; string originalSiteSuffix = "OriginalSiteSuffix"; string ipAddress = "0.0.0.0"; Guid BBCUid = new Guid(); bool isKidsSite = false; bool useIdV4 = true; string useUDNG = "http://UDNG.bbc.co.uk"; ICacheManager mockedCacheManager; IDnaDiagnostics mockedDiagnostics; ISiteList mockedSiteList; IDnaDataReaderCreator mockedCreator; SetupCallingUserSenario(siteID, dnaUserName, originalSiteSuffix, isKidsSite, useIdV4, useUDNG, out mockedCacheManager, out mockedDiagnostics, out mockedSiteList, out mockedCreator); _mocks.ReplayAll(); var bannedEmails = new BannedEmails(mockedCreator, mockedDiagnostics, mockedCacheManager, new List<string>(), new List<string>()); CallingUser callingUser = new CallingUser(SignInSystem.DebugIdentity, mockedCreator, mockedDiagnostics, null, identityUserName, mockedSiteList); Assert.IsTrue(callingUser.IsUserSignedIn(cookie, policy, siteID, identityUserName, ipAddress, BBCUid)); Assert.AreNotEqual(originalSiteSuffix, callingUser.SiteSuffix); Assert.AreNotEqual(identityUserName, callingUser.SiteSuffix); }
public void Test04CheckSignedInNormalUserBelongsToTheCorrectGroups() { FullInputContext context = new FullInputContext(true); SignInSystem signInType = SignInSystem.Identity; CallingUser user = new CallingUser(signInType, null, null, null, context.SiteList); string cookie = TestUserAccounts.GetNormalUserAccount.Cookie; string policy = "http://identity/policies/dna/adult"; int siteID = 1; Assert.IsTrue(user.IsUserSignedIn(cookie, policy, siteID, "")); Assert.IsTrue(user.IsUserA(UserTypes.NormalUser), "User should be a normal user"); Assert.IsFalse(user.IsUserA(UserTypes.SuperUser), "User should not be a super user"); Assert.IsFalse(user.IsUserA(UserTypes.Moderator), "User should not be a moderator"); Assert.IsFalse(user.IsUserA(UserTypes.Editor), "User should not be a editor"); Assert.IsFalse(user.IsUserA(UserTypes.Notable), "User should not be a notable"); }
/// <summary> /// gets the calling user or uses the notsignedin forum user /// </summary> /// <param name="site"></param> /// <param name="forum"></param> /// <returns></returns> protected CallingUser GetCallingUserOrNotSignedInUser(ISite site, Forum forum) { CallingUser callingUser = null; bool userSignedIn = false; if (site != null) { if (String.IsNullOrEmpty(site.IdentityPolicy)) { callingUser = new CallingUser(SignInSystem.SSO, readerCreator, dnaDiagnostic, cacheManager, debugDnaUserId, siteList); userSignedIn = callingUser.IsUserSignedIn(QueryStringHelper.GetCookieValueAsString("SSO2-UID", ""), site.SSOService, site.SiteID, "", _iPAddress, bbcUidCookie); } else { callingUser = new CallingUser(SignInSystem.Identity, readerCreator, dnaDiagnostic, cacheManager, debugDnaUserId, siteList); userSignedIn = callingUser.IsUserSignedInSecure(QueryStringHelper.GetCookieValueAsString("IDENTITY", ""), QueryStringHelper.GetCookieValueAsString("IDENTITY-HTTPS", ""), site.IdentityPolicy, site.SiteID, _iPAddress, bbcUidCookie); } // Check to see if we've got a user who's signed in, but not logged in. This usualy means they haven't agreed T&Cs if (callingUser.GetSigninStatus == CallingUser.SigninStatus.SignedInNotLoggedIn) { throw new DnaWebProtocolException(new ApiException(site.IdentityPolicy, ErrorType.FailedTermsAndConditions)); } } if ((callingUser == null || !userSignedIn) && (forum.allowNotSignedInCommenting && forum.NotSignedInUserId != 0)) { userSignedIn = callingUser.CreateUserFromDnaUserID(forum.NotSignedInUserId, site.SiteID); } if (callingUser == null || !userSignedIn) { throw new DnaWebProtocolException(ApiException.GetError(ErrorType.MissingUserCredentials)); } return callingUser; }
public void Test07CheckSignedInModeratorBelongsToTheCorrectGroups() { 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.NormalUser), "User should be a normal user"); Assert.IsFalse(user.IsUserA(UserTypes.SuperUser), "User should not be a super user"); Assert.IsTrue(user.IsUserA(UserTypes.Moderator), "User should be a moderator"); Assert.IsFalse(user.IsUserA(UserTypes.Editor), "User should not be a editor"); Assert.IsFalse(user.IsUserA(UserTypes.Notable), "User should not be a notable"); }