public CreatedSmokeTestApplication(ISmokeTestApplication source, ISmokeTestApplicationRepository smokeTestApplicationRepository, IApprendaTestSession session) { AppAlias = source.AppAlias; SmokeTestApplicationName = source.SmokeTestApplicationName; _smokeTestApplicationRepository = smokeTestApplicationRepository; _session = session; }
private static async Task UpdateCustomProperty(IApprendaTestSession session, int id) { var individClient = await session.GetClient(ApiPortals.SOC); var got = await individClient.GetCustomProperty(id); var updatable = new CustomPropertyUpdate(got); updatable.ValueOptions.DefaultValues.Remove("three"); updatable.ValueOptions.PossibleValues.Remove("three"); updatable.ValueOptions.PossibleValues.Add("five"); updatable.DeletedValueReplacements = new Dictionary <string, string> { { "three", "five" } }; updatable.Applicability.Applications = null; updatable.DeveloperOptions = null; var putresult = await individClient.UpdateCustomProperty(updatable); Assert.True(putresult); var cprop = await individClient.GetCustomProperty(id); Assert.Null(cprop.Applicability.Applications); Assert.False(cprop.DeveloperOptions.IsVisible); Assert.False(cprop.DeveloperOptions.VisibilityOptions.IsEditableByDeveloper); Assert.False(cprop.DeveloperOptions.VisibilityOptions.IsRequiredForDeployment); Assert.Contains("five", cprop.ValueOptions.PossibleValues); Assert.False(cprop.ValueOptions.DefaultValues.Contains("three")); Assert.False(cprop.ValueOptions.PossibleValues.Contains("three")); }
private static async Task DeleteCustomProperty(IApprendaTestSession session, int id) { var individClient = await session.GetClient(ApiPortals.SOC); var deletion = await individClient.DeleteCustomProperty(id); Assert.True(deletion); }
protected async Task <ISmokeTestApplication> CreateAppIfDoesNotExist(IApprendaTestSession currentSession, string smokeTestName, string appAlias) { if (currentSession.TestIsolationLevel == TestIsolationLevel.IsolatedApplication) { await WaitForApplicationToBeFree(appAlias); } return(await _smokeTestApplicationRepository.GetSmokeTestOnPlatform(currentSession, smokeTestName, appAlias)); }
// ReSharper disable once UnusedParameter.Local private static async Task SearchCustomProperties(IApprendaTestSession session, int id) { var client = await session.GetClient(ApiPortals.SOC); var res = await client.GetAllCustomProperties(); //ASSERT Assert.NotNull(res); Assert.True(res.Any(x => x.Id == id)); }
//todo keep track if any tests are using it public async Task <ISmokeTestApplication> GetSmokeTestOnPlatform(IApprendaTestSession session, string smokeTestApplicationName, string appAlias) { var baseSmokeTest = await GetSmokeTestApplication(smokeTestApplicationName); var createdWrapped = new CreatedSmokeTestApplication(baseSmokeTest, this, session) { AppAlias = appAlias }; var existsToUs = _numberOfTestsUsingApplicationCurrently.ContainsKey(appAlias); //check if we need to wait for other apps to stop using the app (or any!) //does it exist? bool existsOnPlatform; try { var client = await session.GetClient(); var get = await client.GetApplication(appAlias); existsOnPlatform = get != null; if (existsOnPlatform) { createdWrapped.AppAlias = get.Alias; } } catch (Exception) { existsOnPlatform = false; } if (!existsOnPlatform) { if (existsToUs) { //we have a problem! throw new Exception("Error maintaining state of applicaiton instances!"); } var client = await session.GetClient(); await CreateAppOnPlatform(client, createdWrapped); } if (_numberOfTestsUsingApplicationCurrently.ContainsKey(appAlias)) { _numberOfTestsUsingApplicationCurrently[appAlias] = _numberOfTestsUsingApplicationCurrently[appAlias] + 1; } else { _numberOfTestsUsingApplicationCurrently[appAlias] = 1; } return(createdWrapped); }
protected async Task DemoteAppFromSandbox(IApprendaTestSession currentSession, string appAlias) { var client = await currentSession.GetClient(); var appOnPlatform = await client.GetApplication(appAlias); if (appOnPlatform == null) { throw new ArgumentException("Cannot find application " + appAlias); } var connectionSettings = _connectionSettingsFactory.GetSmokeTestSettings(); if (appOnPlatform.IsInStage("sandbox")) { await client.DemoteVersion(appAlias, appOnPlatform.CurrentVersion.Alias); } await WaitForPromotionToFinish(appAlias, await connectionSettings, client); }
public async Task MarkAsNoLongerUsedByTest(IApprendaTestSession session, ISmokeTestApplication smApplication) { var numberUsing = _numberOfTestsUsingApplicationCurrently.ContainsKey(smApplication.AppAlias) ? _numberOfTestsUsingApplicationCurrently[smApplication.AppAlias] : 0; //do we have instances using it? if (numberUsing <= 1) { var client = await session.GetClient(); try { var res = await client.DeleteApplication(smApplication.AppAlias); } catch (Exception) { } } _numberOfTestsUsingApplicationCurrently[smApplication.AppAlias] = numberUsing - 1; }
protected async Task PromoteAppToPublished(IApprendaTestSession currentSession, string appAlias) { await PromoteAppToSandbox(currentSession, appAlias); var client = await currentSession.GetClient(); var appOnPlatform = await client.GetApplication(appAlias); if (appOnPlatform.IsInStage("sandbox")) { await client.PromoteVersion(appAlias, appOnPlatform.CurrentVersion.Alias, ApplicationVersionStage.Published); } var connectionSettings = await _connectionSettingsFactory.GetSmokeTestSettings(); var currentState = await WaitForPromotionToFinish(appAlias, connectionSettings, client); if (currentState.IsCurrentlyPromoting()) { throw new Exception("Timed out while waiting for promotion!"); } }
internal static async Task <CustomProperty> CreateAndGetCustomProperty(IApprendaTestSession session) { // Assemble var client = await session.GetClient(ApiPortals.SOC); var suffix = new Random().Next(10000); var customProperty = new CustomProperty { Name = $"test{suffix}", DisplayName = $"Testing {suffix}", Applicability = new CustomPropertyApplicabilityOptionCollection { Applications = new CustomPropertyApplicationOptions { AllowMultipleValues = true, IsApplied = true, IsComponentLevel = false, ApplicationComponentLevelOptions = new CustomPropertyApplicationComponentOptions { Databases = true, JavaWebApplications = true, LinuxServices = true, UserInterfaces = true, WindowsServices = true } }, ComputeServers = new CustomPropertyApplicabilityOption { IsApplied = true, AllowMultipleValues = true, }, DatabaseServers = new CustomPropertyApplicabilityOption { IsApplied = true, AllowMultipleValues = true, }, ResourcePolicies = new CustomPropertyApplicabilityOption { IsApplied = true, AllowMultipleValues = true }, StorageQuotas = new CustomPropertyApplicabilityOption { IsApplied = true, AllowMultipleValues = true } }, DeveloperOptions = new CustomPropertyDeveloperOptions { IsVisible = true, VisibilityOptions = new VisibilityOptions { IsEditableByDeveloper = true, IsRequiredForDeployment = true } }, ValueOptions = new CustomPropertyValueOptions { AllowCustomValues = true, PossibleValues = new List <string> { "one", "two", "three" }, DefaultValues = new List <string> { "two", "three" } } }; // Act var responseProperty = await client.CreateCustomProperty(customProperty); // Assert Assert.Equal(customProperty.Name, responseProperty.Name); Assert.NotEqual(0, responseProperty.Id); return(responseProperty); }
protected Task <ISmokeTestApplication> CreateAppIfDoesNotExist(IApprendaTestSession session, string smokeTestname = "helloworld") { return(CreateAppIfDoesNotExist(session, smokeTestname, smokeTestname)); }