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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,31 @@ public async Task Test_organization_connections_crud_sequence()
var createConnectionResponse = await fixture.ApiClient.Organizations.CreateConnectionAsync(ExistingOrganizationId, new OrganizationConnectionCreateRequest
{
ConnectionId = ExistingConnectionId,
AssignMembershipOnLogin = true
AssignMembershipOnLogin = true,
ShowAsButton = true
Copy link
Member

Choose a reason for hiding this comment

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

show_as_button defaults to true on the API, can we remove this line to ensure the default value is used when omitted?

Copy link
Contributor Author

@jpealing-fiscaltec jpealing-fiscaltec Mar 19, 2024

Choose a reason for hiding this comment

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

I've removed that line and also removed the equivalent in the update call so there is a test for backwards compatability, as well as making ShowAsButton nullable on OrganizationConnectionUpdateRequest and OrganizationConnectionCreateRequest. This means Test_organization_connections_crud_sequence no longer tests creates and updates with ShowAsButton set, so I've added Test_organization_connections_show_as_button_crud_sequence as an attempt to test this, or would you prefer this be tested by extending Test_organization_connections_crud_sequence?

Copy link
Member

Choose a reason for hiding this comment

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

See #706 (comment), I think we can stick to that.

});

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

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

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

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

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

var connections = await fixture.ApiClient.Organizations.GetAllConnectionsAsync(ExistingOrganizationId, new Paging.PaginationInfo());
connections.Count.Should().Be(initialConnections.Count + 1);
Expand Down
Loading