public void Init() { Console.WriteLine($"Starting custom config test {TestContext.CurrentContext.Test.Name}..."); Config = AzureCPConfig.GetConfiguration(UnitTestsHelper.ClaimsProviderConfigName, UnitTestsHelper.SPTrust.Name); BackupConfig = Config.CopyPersistedProperties(); Config.ResetClaimTypesList(); }
public void Init() { Console.WriteLine($"Starting augmentation test {TestContext.CurrentContext.Test.Name}..."); Config = AzureCPConfig.GetConfiguration(UnitTestsHelper.ClaimsProviderConfigName, UnitTestsHelper.SPTrust.Name); BackupConfig = Config.CopyPersistedProperties(); Config.EnableAugmentation = true; Config.Update(); }
public void Init() { AzureCPConfig configFromConfigDB = AzureCPConfig.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 void Init() { Config = AzureCPConfig.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 = AzureCPConfig.CreateConfiguration(ClaimsProviderConstants.CONFIG_ID, ClaimsProviderConstants.CONFIG_NAME, UnitTestsHelper.SPTrust.Name); } BackupConfig = Config.CopyConfiguration(); InitializeConfiguration(); }
public static void InitializeConfiguration(AzureCPConfig config) { config.ResetCurrentConfiguration(); #if DEBUG config.Timeout = 99999; #endif string json = File.ReadAllText(AzureTenantsJsonFile); List <AzureTenant> azureTenants = JsonConvert.DeserializeObject <List <AzureTenant> >(json); config.AzureTenants = azureTenants; config.Update(); }
public static void InitializeConfiguration(AzureCPConfig config) { config.ResetCurrentConfiguration(); #if DEBUG config.Timeout = 99999; #endif string json = File.ReadAllText(AzureTenantsJsonFile); List <AzureTenant> azureTenants = JsonConvert.DeserializeObject <List <AzureTenant> >(json); config.AzureTenants = azureTenants; config.Update(); Trace.WriteLine($"{DateTime.Now.ToString("s")} Set {config.AzureTenants.Count} Azure AD tenants to AzureCP configuration"); }
public static void InitializeSiteCollection() { 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(azurecp.AzureCP)).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")} DataFile_GuestAccountsUPN_Search: {DataFile_GuestAccountsUPN_Search}"); Trace.WriteLine($"{DateTime.Now.ToString("s")} DataFile_GuestAccountsUPN_Validate: {DataFile_GuestAccountsUPN_Validate}"); Trace.WriteLine($"{DateTime.Now.ToString("s")} TestSiteCollectionName: {TestContext.Parameters["TestSiteCollectionName"]}"); #if DEBUG TestSiteCollUri = new Uri("http://spsites/sites/" + TestContext.Parameters["TestSiteCollectionName"]); return; // Uncommented when debugging AzureCP code from unit tests #endif if (SPTrust == null) { Trace.TraceError($"{DateTime.Now.ToString("s")} SPTrust: is null"); } else { Trace.WriteLine($"{DateTime.Now.ToString("s")} SPTrust: {SPTrust.Name}"); } AzureCPConfig config = AzureCPConfig.GetConfiguration(UnitTestsHelper.ClaimsProviderConfigName, UnitTestsHelper.SPTrust.Name); if (config == null) { AzureCPConfig.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 void BtnResetAzureCPConfig_Click(Object sender, EventArgs e) { AzureCPConfig.DeleteConfiguration(PersistedObjectName); Response.Redirect(Request.RawUrl, false); }