public async Task QueryingForUsersWithAppInDefintionGivesError(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartAdminSession()) { var client = await session.GetClient(); var alias = smokeTestApplication + "deferr"; using (var createApp = await CreateAppIfDoesNotExist(session, smokeTestApplication.ToString(), alias)) { var app = await client.GetApplication(createApp.AppAlias); await PromoteAppToSandbox(session, app.Alias); Assert.NotNull(app); Assert.Equal("definition", app.CurrentVersion.Stage.ToLower()); var threw = false; try { var users = await client.GetUsersAuthZSubscribedTo(app.Alias, app.CurrentVersion.Alias); var first = users.FirstOrDefault(); } catch (Exception e) { threw = true; Assert.False(string.IsNullOrWhiteSpace(e.Message)); } Assert.True(threw); } } }
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); } } } }
public async Task DoTasksWhilePromotingAnApplication_SandboxOnly(AvailableSmokeTestApplications smokeTestAppToUse) { using (var session = await StartSession(TestIsolationLevel.CompletelyIsolated)) { var randomVal = new Random(DateTime.Now.Millisecond).Next(10000); var alias = smokeTestAppToUse.ToString() + randomVal; await DeleteAppIfExists(alias); var client = await session.GetClient(); using (var app = await CreateAppIfDoesNotExist(session, smokeTestAppToUse.ToString(), alias)) { var getRes = await client.GetApplication(app.AppAlias); //promote it Assert.NotNull(getRes.CurrentVersion); await client.PromoteVersion(getRes.Alias, getRes.CurrentVersion.Alias, ApplicationVersionStage.Sandbox); var timeTaken = new List <TimeSpan>(); getRes = await client.GetApplication(app.AppAlias); while (getRes.IsCurrentlyPromoting()) { await BreakStuff(client, getRes, timeTaken); getRes = await client.GetApplication(app.AppAlias); } } } }
public async Task NonAuthZAppsThrowErrorOnGetGroups(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession()) { var groupId = "lalalala"; var client = await session.GetClient(); var alias = smokeTestApplication.ToString().Substring(0, 6) + "noauthz"; using (var createApp = await CreateAppIfDoesNotExist(session, smokeTestApplication.ToString(), alias)) { await PromoteAppToPublished(session, alias); var app = await client.GetApplication(createApp.AppAlias); Assert.NotNull(app); var plans = await((IApprendaDeveloperPortalApiClient)client).GetPlans(app.Alias, app.CurrentVersion.Alias); var plan = plans.FirstOrDefault(); //get the tenant var tenants = await client.GetTenants(); Assert.NotNull(tenants); var tenant = tenants.FirstOrDefault(); Assert.NotNull(tenant); //make sure we're not already subscribed try { var group = await client.GetGroupAuthZSubscribedTo(app.Alias, app.CurrentVersion.Alias, groupId); Assert.Null(group); } catch (Exception e) { Assert.False(string.IsNullOrWhiteSpace(e.Message)); } var threw = false; try { await client.CreateAuthZGroupSubscription(app.Alias, app.CurrentVersion.Alias, new List <string> { groupId }, plan?.Name ?? "noPlan"); } catch (Exception e) { Assert.Contains("authorization enabled", e.Message); threw = true; } Assert.True(threw); } } }
public async Task SubscribeUserAuthZAndCannotDeleteSelf(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession(TestIsolationLevel.IsolatedApplication)) { var client = await session.GetClient(); var alias = smokeTestApplication.ToString().Substring(0, 10) + "self"; using (var createApp = await CreateAppIfDoesNotExist(session, smokeTestApplication.ToString(), alias)) { await PromoteAppToPublished(session, alias); var app = await client.GetApplication(createApp.AppAlias); Assert.NotNull(app); var plans = await((IApprendaDeveloperPortalApiClient)client).GetPlans(app.Alias, app.CurrentVersion.Alias); var plan = plans.First(); //get the tenant var tenants = await client.GetTenants(); Assert.NotNull(tenants); var tenant = tenants.FirstOrDefault(); Assert.NotNull(tenant); var userId = session.ConnectionSettings.UserLogin.UserName; try { await client.CreateAuthZUserSubscription(app.Alias, app.CurrentVersion.Alias, new List <string> { userId }, plan.Name); //retrieve to check var getUser = await client.GetUserAuthZSubscribedTo(app.Alias, app.CurrentVersion.Alias, userId); Assert.NotNull(getUser); //attempt to delete the user var del = await client.RemoveAuthZUserFromApplication(app.Alias, app.CurrentVersion.Alias, new List <string> { userId }); Assert.False(del); } catch (Exception e) { Assert.True(e.Message.Contains("user could not be added")); //means we couldn't add, what to do? } } } }
public async Task ApplicationIsCreatedOnPlatformAndPromotes(AvailableSmokeTestApplications smokeTestAppToUse) { using (var session = await StartSession()) { var randomVal = new Random(DateTime.Now.Millisecond).Next(10000); var alias = smokeTestAppToUse.ToString() + randomVal; await DeleteAppIfExists(alias); var href = session.ConnectionSettings.AppsUrl + $"/developer/api/v1/apps/{alias}"; var app = new Application(href) { Alias = alias, Description = $"Created by Smoke Tests {randomVal}", Name = $"Created by Smoke Tests {randomVal}", Href = href }; var client = await session.GetClient(ApiPortals.Developer); var res = await client.PostApp(app); Assert.True(res); //check it exists! var getRes = await client.GetApplication(app.Alias); Assert.NotNull(getRes); Assert.Equal(app.Alias.ToLower(), getRes.Alias.ToLower()); Assert.Equal(app.Description, getRes.Description); Assert.Equal(app.Name, getRes.Name); Assert.Equal(app.Href.ToLower(), getRes.Href.ToLower()); Assert.NotNull(getRes.CurrentVersion); //check adding the archive var archive = await GetArchiveForSmokeTestApplication(smokeTestAppToUse.ToString()); Assert.NotNull(archive); var rc = await client.PatchVersion(getRes.Alias, getRes.CurrentVersion.Alias, true, archive.ArchiveContents); Assert.Equal(rc.Status, ReportCardStatus.Succeeded); var promoRes = await client.PromoteVersion(getRes.Alias, getRes.CurrentVersion.Alias, ApplicationVersionStage.Sandbox); Assert.True(promoRes); await DeleteAppIfExists(alias); } }
public async Task SubscribingToAccountInSandboxFails(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession()) { var client = await session.GetClient(); var alias = smokeTestApplication.ToString().Substring(0, 10) + "mtsubs"; 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((IApprendaDeveloperPortalApiClient)client).GetPlans(app.Alias, app.CurrentVersion.Alias); var plan = plans.First(p => p.EntitlementDefintionType == EntitlementDefintionType.AccountWide); //get the tenant var tenants = await client.GetTenants(); Assert.NotNull(tenants); var tenant = tenants.FirstOrDefault(); Assert.NotNull(tenant); var subscriptionRequest = new SubscriptionRequest { NumberOfSubscriptions = 2, PlanName = plan.Name, EntitlementDefintionType = plan.EntitlementDefintionType, EntitlementName = plan.EntitlementName }; var thrown = false; try { await client.CreateMultiTenantSubscription(app.Alias, app.CurrentVersion.Alias, tenant, subscriptionRequest); } catch (Exception e) { Assert.Contains("Multiple subscriptions are not valid for Account subscription types", e.Message); thrown = true; } Assert.True(thrown); } } }
public async Task SubscribeUserAuthZFailsOnSandbox(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession()) { var client = await session.GetClient(); var alias = smokeTestApplication.ToString().Substring(0, 8) + "usubsandbox"; 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((IApprendaDeveloperPortalApiClient)client).GetPlans(app.Alias, app.CurrentVersion.Alias); var plan = plans.First(); //get the tenant var tenants = await client.GetTenants(); Assert.NotNull(tenants); var tenant = tenants.FirstOrDefault(); Assert.NotNull(tenant); var userId = session.ConnectionSettings.UserLogin.UserName; var threw = false; try { await client.CreateAuthZUserSubscription(app.Alias, app.CurrentVersion.Alias, new List <string> { userId }, plan.Name); } catch (Exception e) { Assert.Contains("published", e.Message); threw = true; } Assert.True(threw); } } }
public async Task PromoteAndDemoteApplication(AvailableSmokeTestApplications smokeTestAppToUse, int numOfTimes) { using (var session = await StartSession(TestIsolationLevel.CompletelyIsolated)) { var randomVal = new Random(DateTime.Now.Millisecond).Next(10000); var alias = smokeTestAppToUse.ToString() + randomVal; await DeleteAppIfExists(alias); using (var app = await CreateAppIfDoesNotExist(session, smokeTestAppToUse.ToString(), alias)) { for (var i = 0; i < numOfTimes; i++) { await PromoteAppToSandbox(session, app.AppAlias); await DemoteAppFromSandbox(session, app.AppAlias); } } } }
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)); } } }
public async Task SubscribeUserAuthZ(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession(TestIsolationLevel.CompletelyIsolated)) { var client = await session.GetClient(); var alias = smokeTestApplication.ToString().Substring(0, 10) + "usubs"; using (var createApp = await CreateAppIfDoesNotExist(session, smokeTestApplication.ToString(), alias)) { await PromoteAppToPublished(session, alias); var app = await client.GetApplication(createApp.AppAlias); Assert.NotNull(app); var plans = await((IApprendaDeveloperPortalApiClient)client).GetPlans(app.Alias, app.CurrentVersion.Alias); var plan = plans.First(); //get the tenant var tenants = await client.GetTenants(); Assert.NotNull(tenants); var tenant = tenants.FirstOrDefault(); Assert.NotNull(tenant); var userId = session.ConnectionSettings.UserLogin.UserName; await client.CreateAuthZUserSubscription(app.Alias, app.CurrentVersion.Alias, new List <string> { userId }, plan.Name); //retrieve to check var getUser = await client.GetUserAuthZSubscribedTo(app.Alias, app.CurrentVersion.Alias, userId); Assert.NotNull(getUser); Assert.Equal(userId, getUser.Identifier); } } }
public async Task NodeRetrieval(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession(TestIsolationLevel.CompletelyIsolated)) { var client = await session.GetClient(); var alias = smokeTestApplication.ToString().Substring(0, 10) + "mtsubs"; using (var createApp = await CreateAppIfDoesNotExist(session, smokeTestApplication.ToString(), alias)) { var app = await client.GetApplication(createApp.AppAlias); Assert.NotNull(app); var nodes = (await client.GetNodes()).ToList(); Assert.True(nodes.Any()); foreach (var node in nodes) { var byName = await client.GetNode(node.Name); Assert.Equal(node.Name, byName.Name); Assert.Equal(node.CloudName, byName.CloudName); Assert.Equal(node.Workloads.Href, byName.Workloads.Href); //match our roles foreach (var role in node.NodeRoles) { var matching = byName.NodeRoles.FirstOrDefault(nr => nr.NodeRoleType == role.NodeRoleType); Assert.NotNull(matching); Assert.Equal(role.ClockSpeed, matching.ClockSpeed); } } } } }
public async Task SubscribeUserMultiTenantInPublished(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession(TestIsolationLevel.CompletelyIsolated)) { var client = await session.GetClient(); var alias = smokeTestApplication.ToString(); using (var createApp = await CreateAppIfDoesNotExist(session, smokeTestApplication.ToString(), alias)) { await PromoteAppToPublished(session, alias); var app = await client.GetApplication(createApp.AppAlias); Assert.NotNull(app); var plans = await((IApprendaDeveloperPortalApiClient)client).GetPlans(app.Alias, app.CurrentVersion.Alias); var plan = plans.First(p => p.EntitlementDefintionType == EntitlementDefintionType.UserBased); //get the tenant var tenants = await client.GetTenants(); Assert.NotNull(tenants); var tenant = tenants.FirstOrDefault(); Assert.NotNull(tenant); var subscriptionRequest = new SubscriptionRequest { NumberOfSubscriptions = 2, PlanName = plan.Name, EntitlementDefintionType = plan.EntitlementDefintionType, EntitlementName = plan.EntitlementName }; await client.CreateMultiTenantSubscription(app.Alias, app.CurrentVersion.Alias, tenant, subscriptionRequest); //retrieve the subscriptions and plans, ensure they exist! var gotten = (await client.GetSubscriptions(app.Alias, app.CurrentVersion.Alias, tenant)).ToList(); Assert.NotNull(gotten); Assert.False(gotten.Any(s => s.Status == SubscriptionStatus.Dead)); Assert.False(gotten.Any(s => s.Status == SubscriptionStatus.Swapped)); foreach (var got in gotten) { var byLoc = await client.GetSubscription(app.Alias, app.CurrentVersion.Alias, tenant, got.Locator); Assert.Equal(got.Description, byLoc.Description); Assert.Equal(got.Locator, byLoc.Locator); var delRes = await client.DeleteSubscription(app.Alias, app.CurrentVersion.Alias, tenant, got.Locator); Assert.True(delRes); byLoc = await client.GetSubscription(app.Alias, app.CurrentVersion.Alias, tenant, got.Locator); Assert.True(byLoc.Status == SubscriptionStatus.Cancelled); } } } }
public async Task SubscribeGroupAuthZ(AvailableSmokeTestApplications smokeTestApplication) { using (var session = await StartSession(TestIsolationLevel.IsolatedApplication)) { var settings = session.ConnectionSettings; if (settings.EnvironmentFeaturesAvailable != null && settings.EnvironmentFeaturesAvailable.IsExternalUserStore) { var groupId = settings.EnvironmentInformation.EUSGroupId; var client = await session.GetClient(); var alias = smokeTestApplication.ToString().Substring(0, 10) + "gsubs"; using (var createApp = await CreateAppIfDoesNotExist(session, smokeTestApplication.ToString(), alias)) { await PromoteAppToPublished(session, alias); var app = await client.GetApplication(createApp.AppAlias); Assert.NotNull(app); var plans = await((IApprendaDeveloperPortalApiClient)client).GetPlans(app.Alias, app.CurrentVersion.Alias); var plan = plans.First(); //get the tenant var tenants = await client.GetTenants(); Assert.NotNull(tenants); var tenant = tenants.FirstOrDefault(); Assert.NotNull(tenant); //make sure we're not already subscribed try { var group = await client.GetGroupAuthZSubscribedTo(app.Alias, app.CurrentVersion.Alias, groupId); Assert.Null(group); } catch (Exception e) { Assert.False(string.IsNullOrWhiteSpace(e.Message)); } await client.CreateAuthZGroupSubscription(app.Alias, app.CurrentVersion.Alias, new List <string> { groupId }, plan.Name); //retrieve to check var getGroups = await client.GetGroupsAuthZSubscribedTo(app.Alias, app.CurrentVersion.Alias); Assert.NotNull(getGroups); Assert.True(getGroups.Any()); var getGroup = await client.GetGroupAuthZSubscribedTo(app.Alias, app.CurrentVersion.Alias, groupId); Assert.NotNull(getGroup); Assert.Equal(groupId, getGroup.Id); //remove the group var del = await client.RemoveAuthZGroupFromApplication(app.Alias, app.CurrentVersion.Alias, new List <string> { groupId }, plan.Name); Assert.True(del); //make sure we're gone var threw = false; try { var group = await client.GetGroupAuthZSubscribedTo(app.Alias, app.CurrentVersion.Alias, groupId); Assert.Null(group); } catch (Exception) { threw = true; } Assert.True(threw); } } } }