public async Task RetrievePlans(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession(TestIsolationLevel.CompletelyIsolated)) { IApprendaDeveloperPortalApiClient client = await session.GetClient(); var alias = smokeTestApplication.ToString(); using (var createApp = await CreateAppIfDoesNotExist(session, smokeTestApplication.ToString(), alias)) { await PromoteAppToSandbox(session, alias); var app = await client.GetApplication(createApp.AppAlias); Assert.NotNull(app); var plans = await client.GetPlans(app.Alias, app.CurrentVersion.Alias); foreach (var foundPlan in plans.Where(p => p != null)) { var byId = await client.GetPlan(app.Alias, app.CurrentVersion.Alias, foundPlan.Id); Assert.NotNull(byId); Assert.Equal(foundPlan.Name, byId.Name); Assert.NotNull(foundPlan.Href); Assert.Equal(foundPlan.EntitlementDefintionType, byId.EntitlementDefintionType); Assert.Equal(foundPlan.EntitlementName, byId.EntitlementName); Assert.Equal(foundPlan.Href, byId.Href); Assert.Contains(foundPlan.Id.ToString(), byId.Href); } } } }
private async Task <string> CreateAppOnPlatform(IApprendaDeveloperPortalApiClient client, ISmokeTestApplication smApp) { //create it! var app = new Application("") { Alias = smApp.AppAlias, Description = $"{smApp.SmokeTestApplicationName} created by Smoke Tests", Name = $"st_{smApp.AppAlias}", }; var res = await client.PostApp(app); if (!res) { throw new Exception("Error while posting application"); } //check it exists! var getRes = await client.GetApplication(app.Alias); //check adding the archive var archive = await GetSmokeTestApplication(smApp.SmokeTestApplicationName); var rc = await client.PatchVersion(getRes.Alias, getRes.CurrentVersion.Alias, true, archive.ArchiveContents); if (rc.Status != ReportCardStatus.Succeeded) { throw new Exception($"Patching app returned status of {rc.Status}"); } return(app.Alias); }
public async Task BothAccountAndUserPlansRetreive(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession()) { IApprendaDeveloperPortalApiClient client = await session.GetClient(); var alias = smokeTestApplication.ToString().Substring(0, 10) + "plans"; using (var createApp = await CreateAppIfDoesNotExist(session, smokeTestApplication.ToString(), alias)) { await PromoteAppToSandbox(session, alias); var app = await client.GetApplication(createApp.AppAlias); Assert.NotNull(app); var plans = (await client.GetPlans(app.Alias, app.CurrentVersion.Alias)).ToList(); Assert.True(plans.Any(p => p.EntitlementDefintionType == EntitlementDefintionType.AccountWide)); } } }
private async Task <EnrichedApplication> WaitForPromotionToFinish(string appAlias, ISmokeTestSettings connectionSettings, IApprendaDeveloperPortalApiClient client) { var maxWait = connectionSettings.MaxPromotionWaitTime; var startTIme = DateTime.UtcNow; var currentState = await client.GetApplication(appAlias); while (DateTime.UtcNow - startTIme < maxWait) { try { var isPromoting = currentState.IsCurrentlyPromoting(); if (!isPromoting) { break; } } catch (Exception e) { _reportingService?.ReportInfo("Waiting for promotion: " + e.Message, new List <string> { "promotion", "debug", "exception" }); } Thread.Sleep(new TimeSpan(0, 0, 15)); currentState = await client.GetApplication(appAlias); } return(currentState); }