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

[2/2] DXCDT-457: Add members to the auth0_organization data source #615

Merged
merged 1 commit into from
Jun 7, 2023

Conversation

sergiught
Copy link
Contributor

@sergiught sergiught commented Jun 2, 2023

🔧 Changes

Add members to the auth0_organization data source.

📚 References

🔬 Testing

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@sergiught sergiught changed the title DXCDT-457: Add members to the auth0_organization data source [2/2] DXCDT-457: Add members to the auth0_organization data source Jun 2, 2023
@sergiught sergiught force-pushed the feature/DXCDT-457-org-members-data-source branch from d051a13 to c7dd1e8 Compare June 2, 2023 13:41
@sergiught sergiught marked this pull request as ready for review June 2, 2023 13:50
@sergiught sergiught requested a review from a team as a code owner June 2, 2023 13:50
@codecov-commenter
Copy link

Codecov Report

Merging #615 (c7dd1e8) into feature/DXCDT-457-org-members (c0f0e51) will decrease coverage by 0.03%.
The diff coverage is 80.00%.

Additional details and impacted files

Impacted file tree graph

@@                        Coverage Diff                        @@
##           feature/DXCDT-457-org-members     #615      +/-   ##
=================================================================
- Coverage                          86.48%   86.45%   -0.03%     
=================================================================
  Files                                 77       77              
  Lines                              12042    12068      +26     
=================================================================
+ Hits                               10414    10433      +19     
- Misses                              1246     1251       +5     
- Partials                             382      384       +2     
Impacted Files Coverage Δ
internal/auth0/organization/data_source.go 80.53% <80.00%> (-1.58%) ⬇️

@@ -150,6 +161,30 @@ func fetchAllOrganizationConnections(api *management.Management, organizationID
return foundConnections, nil
}

func fetchAllOrganizationMembers(api *management.Management, organizationID string) ([]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just thinking through the performance implications of this. If I understand correctly, there may be a large number of members in an organization. In which case, fetching all members could become a penalty if the customer doesn't want to fetch that data. Though I admit that it could be the primary use case of this data source, so the point might be moot.

Not requesting a change necessarily, but want to get your perspective on this and if there are any ways to mitigate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will CAP at 1000 members, as we're using offset pagination instead of checkpoint pagination, so at most we will make 10 requests to get the list of members. We can further tweak this based on user feedback, but for now this seems like a good compromise.

@@ -110,6 +126,7 @@ func TestAccDataSourceOrganizationByID(t *testing.T) {
resource.TestCheckResourceAttr("data.auth0_organization.test", "name", fmt.Sprintf("test-%s", testName)),
resource.TestCheckResourceAttr("data.auth0_organization.test", "connections.#", "1"),
resource.TestCheckResourceAttrSet("data.auth0_organization.test", "connections.0.connection_id"),
resource.TestCheckResourceAttr("data.auth0_organization.test", "members.#", "1"),
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some way to test the new pagination functionality? IMO, it would ideally be in an integration test but I could see that getting a bit gnarly so would accept a unit test too. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's intrinsically tested through the members integration tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

But only single-paged requests are getting tested and not multi-paged requests, right? That's my only point here.

Copy link
Contributor

Choose a reason for hiding this comment

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

To add, I can see this being a bit gnarly to test. Just looking for some assurances that it works, ideally with a test but at the very least some manual verification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works 😄 , you can sleep well tonight. I changed the per page to 1 and had 2 members.

@sergiught sergiught force-pushed the feature/DXCDT-457-org-members branch from 9d1583d to e3933b9 Compare June 7, 2023 07:09
@sergiught sergiught force-pushed the feature/DXCDT-457-org-members-data-source branch from c7dd1e8 to db98dbd Compare June 7, 2023 07:23
@sergiught sergiught force-pushed the feature/DXCDT-457-org-members branch from e3933b9 to 14c962c Compare June 7, 2023 07:25
@sergiught sergiught force-pushed the feature/DXCDT-457-org-members-data-source branch from db98dbd to 4d45c2c Compare June 7, 2023 07:26
Base automatically changed from feature/DXCDT-457-org-members to main June 7, 2023 13:08
@sergiught sergiught force-pushed the feature/DXCDT-457-org-members-data-source branch from 4d45c2c to ed70341 Compare June 7, 2023 13:09
@sergiught sergiught merged commit 43802ba into main Jun 7, 2023
@sergiught sergiught deleted the feature/DXCDT-457-org-members-data-source branch June 7, 2023 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants