Skip to content

Commit

Permalink
Remove old discarded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kjetilhau committed Dec 4, 2024
1 parent a4e6254 commit e9c7a08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public async Task<ActionResult> RemovePortal([FromRoute] Guid portalId)
}
catch (InvalidOperationException ex)
{
return FusionApiError.Forbidden(ex.Message);
return FusionApiError.InvalidOperation("500", ex.Message);
}
catch (Exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text;
using Equinor.ProjectExecutionPortal.Tests.WebApi.Data;
using Equinor.ProjectExecutionPortal.Tests.WebApi.Setup;
using Equinor.ProjectExecutionPortal.WebApi.ViewModels;
using Equinor.ProjectExecutionPortal.WebApi.ViewModels.Portal;
using Equinor.ProjectExecutionPortal.WebApi.ViewModels.PortalApp;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down Expand Up @@ -77,7 +78,8 @@ public async Task Create_Portal_AsAdministratorUser_ShouldReturnOk()
ShortName = "Created short name",
Subtext = "Created subtext",
Icon = "Created icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey],
Admins = [new ApiAccountIdentifier { AzureUniqueId = Guid.Parse(UserData.AuthenticatedUserId) }]
};

// Act
Expand Down Expand Up @@ -110,7 +112,8 @@ public async Task Create_Portal_AsAuthenticatedUser_ShouldReturnForbidden()
ShortName = "Created short name",
Subtext = "Created subtext",
Icon = "Created icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey],
Admins = [new ApiAccountIdentifier { AzureUniqueId = Guid.Parse(UserData.AuthenticatedUserId) }]
};

// Act
Expand All @@ -131,7 +134,8 @@ public async Task Create_Portal_AsAnonymousUser_ShouldReturnUnauthorized()
ShortName = "Created short name",
Subtext = "Created subtext",
Icon = "Created icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey],
Admins = [new ApiAccountIdentifier { AzureUniqueId = Guid.Parse(UserData.AuthenticatedUserId) }]
};

// Act
Expand All @@ -155,7 +159,8 @@ public async Task Update_Portal_AsAdministratorUser_ShouldReturnOk()
ShortName = "Updated short name",
Subtext = "Updated subtext",
Icon = "Updated icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey],
Admins = [new ApiAccountIdentifier { AzureUniqueId = Guid.Parse(UserData.AuthenticatedUserId) }]
};

// Act
Expand Down Expand Up @@ -186,7 +191,8 @@ public async Task Update_Portal_AsAuthenticatedUser_ShouldReturnForbidden()
ShortName = "Updated short name",
Subtext = "Updated subtext",
Icon = "Updated icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey],
Admins = [new ApiAccountIdentifier { AzureUniqueId = Guid.Parse(UserData.AuthenticatedUserId) }]
};

// Act
Expand All @@ -207,7 +213,8 @@ public async Task Update_Portal_AsAnonymousUser_ShouldReturnUnauthorized()
ShortName = "Updated short name",
Subtext = "Updated subtext",
Icon = "Updated icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey],
Admins = [new ApiAccountIdentifier { AzureUniqueId = Guid.Parse(UserData.AuthenticatedUserId) }]
};

// Act
Expand Down Expand Up @@ -329,50 +336,6 @@ public async Task Update_PortalConfiguration_AsAnonymousUser_ShouldReturnUnautho
Assert.AreEqual(HttpStatusCode.Unauthorized, response.StatusCode);
}

[TestMethod]
public async Task Get_OnlyGlobalAppKeysForPortal_WithoutContext_AsAuthenticatedUser_ShouldReturnOk()
{
// Arrange
var portals = await AssertGetAllPortals(UserType.Authenticated, HttpStatusCode.OK);
var portalToTest = portals?.SingleOrDefault(x => x.Key == PortalData.InitialDbSeedData.ProjectExecution.Key);

// Act
var apps = await AssertGetAppKeysForPortal(portalToTest!.Id, null, UserType.Authenticated, HttpStatusCode.OK);

// Assert
Assert.IsNotNull(apps);
Assert.AreEqual(4, apps.Count);
}

[TestMethod]
public async Task Get_BothGlobalAndContextAppKeysForPortal_WithValidContext_AsAuthenticatedUser_ShouldReturnOk()
{
// Arrange
var portals = await AssertGetAllPortals(UserType.Authenticated, HttpStatusCode.OK);
var portalToTest = portals?.SingleOrDefault(x => x.Key == PortalData.InitialDbSeedData.ProjectExecution.Key);

// Act
var apps = await AssertGetAppKeysForPortal(portalToTest!.Id, FusionContextApiData.JcaContextId, UserType.Authenticated, HttpStatusCode.OK);

// Assert
Assert.IsNotNull(apps);
Assert.AreEqual(6, apps.Count);
}

[TestMethod]
public async Task Get_BothGlobalAndContextAppKeysForPortal_WithInvalidContext_AsAuthenticatedUser_ShouldReturn404()
{
// Arrange
var portals = await AssertGetAllPortals(UserType.Authenticated, HttpStatusCode.OK);
var portalToTest = portals?.SingleOrDefault(x => x.Key == PortalData.InitialDbSeedData.ProjectExecution.Key);

// Act
var response = await GetAppKeysForPortal(portalToTest!.Id, FusionContextApiData.InvalidContextId, UserType.Authenticated);

// Assert
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
}

[TestMethod]
public async Task Get_OnlyGlobalAppsForPortal_WithoutContext_AsAuthenticatedUser_ShouldReturnOk()
{
Expand Down Expand Up @@ -477,7 +440,8 @@ public async Task Delete_Portal_AsAdministrator_ShouldReturnOk()
ShortName = "Created short name",
Subtext = "Created subtext",
Icon = "Created icon",
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey]
ContextTypes = [ContextTypeData.ValidContextTypes.ProjectMasterContextTypeKey],
Admins = [new ApiAccountIdentifier { AzureUniqueId = Guid.Parse(UserData.AuthenticatedUserId) }]
};

await CreatePortal(UserType.Administrator, payload);
Expand Down

0 comments on commit e9c7a08

Please sign in to comment.