public void Init() { Console.WriteLine($"Starting custom config test {TestContext.CurrentContext.Test.Name}..."); Config = LDAPCPConfig.GetConfiguration(UnitTestsHelper.ClaimsProviderConfigName, UnitTestsHelper.SPTrust.Name); BackupConfig = Config.CopyPersistedProperties(); Config.ResetClaimTypesList(); }
public void Init() { LDAPCPConfig configFromConfigDB = LDAPCPConfig.GetConfiguration(UnitTestsHelper.ClaimsProviderConfigName, UnitTestsHelper.SPTrust.Name); // Create a local copy, otherwise changes will impact the whole process (even without calling Update method) Config = configFromConfigDB.CopyPersistedProperties(); // Reset configuration to test its default for the tests Config.ResetCurrentConfiguration(); }
public static void InitializeConfiguration(LDAPCPConfig config) { config.ResetCurrentConfiguration(); #if DEBUG config.LDAPQueryTimeout = 99999; #endif config.Update(); }
public void Init() { Config = LDAPCPConfig.GetConfiguration(UnitTestsHelper.ClaimsProviderConfigName, UnitTestsHelper.SPTrust.Name); if (Config == null) { Trace.TraceWarning($"{DateTime.Now.ToString("s")} Configuration {UnitTestsHelper.ClaimsProviderConfigName} does not exist, create it with default settings..."); Config = LDAPCPConfig.CreateConfiguration(ClaimsProviderConstants.CONFIG_ID, ClaimsProviderConstants.CONFIG_NAME, UnitTestsHelper.SPTrust.Name); } BackupConfig = Config.CopyPersistedProperties(); InitializeConfiguration(); }
public void Init() { Console.WriteLine($"Starting augmentation test {TestContext.CurrentContext.Test.Name}..."); Config = LDAPCPConfig.GetConfiguration(UnitTestsHelper.ClaimsProviderConfigName, UnitTestsHelper.SPTrust.Name); BackupConfig = Config.CopyPersistedProperties(); Config.EnableAugmentation = true; Config.MainGroupClaimType = ClaimsProviderConstants.DefaultMainGroupClaimType; foreach (LDAPConnection ldapConn in Config.LDAPConnectionsProp) { ldapConn.AugmentationEnabled = true; ldapConn.GetGroupMembershipAsADDomainProp = true; } Config.Update(); }
public static void InitializeSiteCollection() { #if DEBUG TestSiteCollUri = new Uri("http://spsites/sites/" + TestContext.Parameters["TestSiteCollectionName"]); return; // Uncommented when debugging LDAPCP code from unit tests #endif logFileListener = new TextWriterTraceListener(TestContext.Parameters["TestLogFileName"]); Trace.Listeners.Add(logFileListener); Trace.AutoFlush = true; Trace.TraceInformation($"{DateTime.Now.ToString("s")} Start integration tests of {ClaimsProviderName} {FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(ldapcp.LDAPCP)).Location).FileVersion}."); Trace.WriteLine($"{DateTime.Now.ToString("s")} DataFile_AllAccounts_Search: {DataFile_AllAccounts_Search}"); Trace.WriteLine($"{DateTime.Now.ToString("s")} DataFile_AllAccounts_Validate: {DataFile_AllAccounts_Validate}"); Trace.WriteLine($"{DateTime.Now.ToString("s")} TestSiteCollectionName: {TestContext.Parameters["TestSiteCollectionName"]}"); if (SPTrust == null) { Trace.TraceError($"{DateTime.Now.ToString("s")} SPTrust: is null"); } else { Trace.WriteLine($"{DateTime.Now.ToString("s")} SPTrust: {SPTrust.Name}"); } LDAPCPConfig config = LDAPCPConfig.GetConfiguration(UnitTestsHelper.ClaimsProviderConfigName, UnitTestsHelper.SPTrust.Name); if (config == null) { LDAPCPConfig.CreateConfiguration(ClaimsProviderConstants.CONFIG_ID, ClaimsProviderConstants.CONFIG_NAME, SPTrust.Name); } var service = SPFarm.Local.Services.GetValue <SPWebService>(String.Empty); SPWebApplication wa = service.WebApplications.FirstOrDefault(); if (wa != null) { Trace.WriteLine($"{DateTime.Now.ToString("s")} Web application {wa.Name} found."); SPClaimProviderManager claimMgr = SPClaimProviderManager.Local; string encodedClaim = claimMgr.EncodeClaim(TrustedGroup); SPUserInfo userInfo = new SPUserInfo { LoginName = encodedClaim, Name = TrustedGroupToAdd_ClaimValue }; // The root site may not exist, but it must be present for tests to run Uri rootWebAppUri = wa.GetResponseUri(0); if (!SPSite.Exists(rootWebAppUri)) { Trace.WriteLine($"{DateTime.Now.ToString("s")} Creating root site collection {rootWebAppUri.AbsoluteUri}..."); SPSite spSite = wa.Sites.Add(rootWebAppUri.AbsoluteUri, "root", "root", 1033, "STS#1", FarmAdmin, String.Empty, String.Empty); spSite.RootWeb.CreateDefaultAssociatedGroups(FarmAdmin, FarmAdmin, spSite.RootWeb.Title); SPGroup membersGroup = spSite.RootWeb.AssociatedMemberGroup; membersGroup.AddUser(userInfo.LoginName, userInfo.Email, userInfo.Name, userInfo.Notes); spSite.Dispose(); } if (!Uri.TryCreate(rootWebAppUri, TestSiteRelativePath, out TestSiteCollUri)) { Trace.TraceError($"{DateTime.Now.ToString("s")} Unable to generate Uri of test site collection from Web application Uri {rootWebAppUri.AbsolutePath} and relative path {TestSiteRelativePath}."); } if (!SPSite.Exists(TestSiteCollUri)) { Trace.WriteLine($"{DateTime.Now.ToString("s")} Creating site collection {TestSiteCollUri.AbsoluteUri}..."); SPSite spSite = wa.Sites.Add(TestSiteCollUri.AbsoluteUri, ClaimsProviderName, ClaimsProviderName, 1033, "STS#1", FarmAdmin, String.Empty, String.Empty); spSite.RootWeb.CreateDefaultAssociatedGroups(FarmAdmin, FarmAdmin, spSite.RootWeb.Title); SPGroup membersGroup = spSite.RootWeb.AssociatedMemberGroup; membersGroup.AddUser(userInfo.LoginName, userInfo.Email, userInfo.Name, userInfo.Notes); spSite.Dispose(); } else { using (SPSite spSite = new SPSite(TestSiteCollUri.AbsoluteUri)) { SPGroup membersGroup = spSite.RootWeb.AssociatedMemberGroup; membersGroup.AddUser(userInfo.LoginName, userInfo.Email, userInfo.Name, userInfo.Notes); } } } else { Trace.TraceError($"{DateTime.Now.ToString("s")} Web application was NOT found."); } }
protected virtual void ResetConfiguration() { LDAPCPConfig.DeleteConfiguration(PersistedObjectName); Response.Redirect(Request.RawUrl, false); }
protected virtual void ResetConfiguration() { LDAPCPConfig.DeleteLDAPCPConfig(); Response.Redirect(Request.RawUrl, false); }
protected void BtnReset_Click(object sender, EventArgs e) { LDAPCPConfig.ResetClaimsList(); Response.Redirect(Request.Url.ToString()); }