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

Add show_as_button to organizations connection #706

Merged
merged 8 commits into from
Apr 2, 2024
6 changes: 6 additions & 0 deletions src/Auth0.ManagementApi/Models/OrganizationConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public class OrganizationConnection
[JsonProperty("assign_membership_on_login")]
public bool AssignMembershipOnLogin { get; set; }

/// <summary>
/// Determines whether a connection should be displayed on this organization’s login prompt.
/// </summary>
[JsonProperty("show_as_button")]
public bool ShowAsButton { get; set; }

/// <summary>
/// Information on the enabled connection
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ public class OrganizationConnectionCreateRequest
[JsonProperty("assign_membership_on_login")]
public bool AssignMembershipOnLogin { get; set; }

/// <summary>
/// Determines whether a connection should be displayed on this organization’s login prompt.
/// </summary>
[JsonProperty("show_as_button")]
public bool? ShowAsButton { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@ public class OrganizationConnectionUpdateRequest
/// </summary>
[JsonProperty("assign_membership_on_login")]
public bool AssignMembershipOnLogin { get; set; }

/// <summary>
/// Determines whether a connection should be displayed on this organization’s login prompt.
/// </summary>
[JsonProperty("show_as_button")]
public bool? ShowAsButton { get; set; }
}
}
37 changes: 37 additions & 0 deletions tests/Auth0.ManagementApi.IntegrationTests/OrganizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public async Task Test_organization_connections_crud_sequence()

createConnectionResponse.Should().NotBeNull();
createConnectionResponse.AssignMembershipOnLogin.Should().Be(true);
createConnectionResponse.ShowAsButton.Should().Be(true);

try
{
Expand All @@ -167,11 +168,13 @@ public async Task Test_organization_connections_crud_sequence()

updateConnectionResponse.Should().NotBeNull();
updateConnectionResponse.AssignMembershipOnLogin.Should().Be(false);
updateConnectionResponse.ShowAsButton.Should().Be(true);

var connection = await fixture.ApiClient.Organizations.GetConnectionAsync(ExistingOrganizationId, ExistingConnectionId);

connection.Should().NotBeNull();
connection.AssignMembershipOnLogin.Should().Be(false);
connection.ShowAsButton.Should().Be(true);

var connections = await fixture.ApiClient.Organizations.GetAllConnectionsAsync(ExistingOrganizationId, new Paging.PaginationInfo());
connections.Count.Should().Be(initialConnections.Count + 1);
Expand All @@ -189,6 +192,40 @@ public async Task Test_organization_connections_crud_sequence()
}
}

[Fact]
public async Task Test_organization_connections_show_as_button_crud_sequence()
{
var createConnectionResponse = await fixture.ApiClient.Organizations.CreateConnectionAsync(ExistingOrganizationId, new OrganizationConnectionCreateRequest
{
ConnectionId = ExistingConnectionId,
ShowAsButton = false
});

createConnectionResponse.Should().NotBeNull();
createConnectionResponse.ShowAsButton.Should().Be(false);

try
{
var updateConnectionResponse = await fixture.ApiClient.Organizations.UpdateConnectionAsync(ExistingOrganizationId, ExistingConnectionId, new OrganizationConnectionUpdateRequest
{
ShowAsButton = true
});

updateConnectionResponse.Should().NotBeNull();
updateConnectionResponse.ShowAsButton.Should().Be(true);

var connection = await fixture.ApiClient.Organizations.GetConnectionAsync(ExistingOrganizationId, ExistingConnectionId);

connection.Should().NotBeNull();
connection.ShowAsButton.Should().Be(true);
}
finally
{
// Unlink Connection
await fixture.ApiClient.Organizations.DeleteConnectionAsync(ExistingOrganizationId, ExistingConnectionId);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can avoid this test, and instead use the original to:

  • Leave the default on create and assert its true
  • Set it to false on update and assert its false after

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


[Fact]
public async Task Test_organization_members_crud_sequence()
{
Expand Down