Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dp-943 Update the tenant/lookup endpoint to return the organisation type #1043

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private HttpClient BuildHttpClient(List<string> userOrganisationScopes, List<str
var organisation = new UserOrganisation(
id: OrganisationId,
name: "Org name",
type: Tenant.WebApiClient.OrganisationType.Organisation,
roles:
[
Tenant.WebApiClient.PartyRole.Supplier,
Expand Down
6 changes: 4 additions & 2 deletions Frontend/CO.CDP.OrganisationApp.Tests/LocalizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private HttpClient BuildHttpClient()

session
.Setup(s => s.Get<RegistrationDetails>(Session.RegistrationDetailsKey))
.Returns(new RegistrationDetails() { OrganisationType = OrganisationType.Supplier, OrganisationScheme = "Whatever" });
.Returns(new RegistrationDetails() { OrganisationType = Constants.OrganisationType.Supplier, OrganisationScheme = "Whatever" });

var antiforgery = new Mock<IAntiforgery>();

Expand All @@ -60,7 +60,8 @@ private HttpClient BuildHttpClient()
services.AddSingleton(antiforgery.Object);
services.AddSingleton(tenantClient.Object);
services.AddTransient<IAuthenticationSchemeProvider, FakeSchemeProvider>();
services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options => {
services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>
{
options.ClientId = "123";
options.Authority = "https://whatever";
});
Expand Down Expand Up @@ -189,6 +190,7 @@ public async Task OrganisationNamePage_DisplaysErrorMessageCorrectly_WhenLanguag
new UserOrganisation(
id: Guid.NewGuid(),
name: "Acme Ltd",
type: Tenant.WebApiClient.OrganisationType.Organisation,
roles: [PartyRole.Tenderer],
pendingRoles: [],
scopes: ["ADMIN"],
Expand Down
5 changes: 4 additions & 1 deletion Frontend/CO.CDP.OrganisationApp.Tests/UserInfoServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using FluentAssertions;
using Microsoft.AspNetCore.Http;
using Moq;
using OrganisationType = CO.CDP.Tenant.WebApiClient.OrganisationType;

namespace CO.CDP.OrganisationApp.Tests;

Expand Down Expand Up @@ -242,11 +243,13 @@ private static UserOrganisation GivenUserOrganisation(
string? name = null,
ICollection<string>? scopes = null,
ICollection<PartyRole>? roles = null,
ICollection<PartyRole>? pendingRoles = null)
ICollection<PartyRole>? pendingRoles = null,
OrganisationType type = OrganisationType.Organisation)
{
return new UserOrganisation(
id: id ?? Guid.NewGuid(),
name: name,
type: type,
pendingRoles: pendingRoles,
roles: roles,
scopes: scopes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ private TenantLookup GetTenantLookup(int numberOfTenant = 1, int numberOfOrgsPer
{
Id = Guid.NewGuid(),
Name = $"Test Org{x}{y}",
Type = OrganisationInformation.OrganisationType.Organisation,
Roles = [OrganisationInformation.PartyRole.Buyer],
PendingRoles = [],
Scopes = ["Admin"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public async Task ItFindsThePersonWithAllTheirTenants()
{
Id = acmeCoOrganisation.Guid,
Name = acmeCoOrganisation.Name,
Type = acmeCoOrganisation.Type,
Roles = acmeCoOrganisation.Roles,
PendingRoles = acmeCoOrganisation.PendingRoles,
Scopes = adminPersonScopes
Expand Down Expand Up @@ -113,6 +114,7 @@ public async Task ItFindsThePersonWithAllTheirTenants()
{
Id = widgetCoOrganisation.Guid,
Name = widgetCoOrganisation.Name,
Type = widgetCoOrganisation.Type,
Roles = widgetCoOrganisation.Roles,
PendingRoles = widgetCoOrganisation.PendingRoles,
Scopes = userPersonScopes
Expand Down Expand Up @@ -159,6 +161,7 @@ public async Task ItFindsThePersonWithAllTheirTenants()
{
Id = acmeCoOrganisation.Guid,
Name = acmeCoOrganisation.Name,
Type = acmeCoOrganisation.Type,
Roles = acmeCoOrganisation.Roles,
PendingRoles = acmeCoOrganisation.PendingRoles,
Scopes = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void Save(Tenant tenant)
{
Id = o.Guid,
Name = o.Name,
Type = o.Type,
Roles = o.Roles,
PendingRoles = o.PendingRoles,
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Organisation
{
public required Guid Id { get; init; }
public required string Name { get; init; }
public required OrganisationType Type { get; init; }
public required List<PartyRole> Roles { get; init; }
public required List<PartyRole> PendingRoles { get; init; }
public required List<string> Scopes { get; init; }
Expand Down
2 changes: 2 additions & 0 deletions Services/CO.CDP.OrganisationInformation/TenantLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public record UserOrganisation
/// <example>"Acme Group Ltd"</example>
public required string Name { get; init; }

public required OrganisationType Type { get; init; }

public required List<PartyRole> Roles { get; init; }

public required List<PartyRole> PendingRoles { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private static TenantLookup GivenTenantLookup()
{
Id = Guid.Parse("dfd0c5d3-0740-4be4-aa42-e42ec9c00bad"),
Name = "Acme Ltd",
Type = OrganisationType.Organisation,
Roles = [PartyRole.Tenderer],
PendingRoles = [],
Scopes = ["ADMIN"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public async Task Execute_IfTenantIsFound_ReturnsTenant()
{
Id = Guid.Parse("dfd0c5d3-0740-4be4-aa42-e42ec9c00bad"),
Name = "Acme Ltd",
Type= OrganisationType.Organisation,
Roles = [PartyRole.Tenderer],
PendingRoles = [PartyRole.Buyer],
Scopes = ["ADMIN"]
Expand Down Expand Up @@ -89,6 +90,7 @@ public async Task Execute_IfTenantIsFound_ReturnsTenant()
{
Id = Guid.Parse("dfd0c5d3-0740-4be4-aa42-e42ec9c00bad"),
Name = "Acme Ltd",
Type = OrganisationType.Organisation,
Roles = [PartyRole.Tenderer],
PendingRoles = [PartyRole.Buyer],
Scopes = ["ADMIN"],
Expand Down
Loading