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 Integration Tests for User Sharing API #23423

Merged

Conversation

BimsaraBodaragama
Copy link
Member

This PR introduces comprehensive integration tests for the User Sharing API, ensuring correctness in user sharing, unsharing, and verification through a successful GET request for a user's shared organizations and assigned shared roles to a shared user in a given organization. These tests validate request handling, response accuracy, and expected behavior across various valid and invalid scenarios, ensuring API reliability in standard usage.

Test Coverage:

✅ Successful Scenarios

  1. Selective User Sharing:
    • Covers single and multiple users across multiple organizations.
    • Validates all selective resource-sharing policies:
      • SELECTED_ORG_ONLY
      • SELECTED_ORG_WITH_ALL_EXISTING_CHILDREN_ONLY
      • SELECTED_ORG_WITH_ALL_EXISTING_AND_FUTURE_CHILDREN
      • SELECTED_ORG_WITH_EXISTING_IMMEDIATE_CHILDREN_ONLY
      • SELECTED_ORG_WITH_EXISTING_IMMEDIATE_AND_FUTURE_CHILDREN
  2. General User Sharing:
    • Covers single and multiple users.
    • Validates all general resource-sharing policies:
      • ALL_EXISTING_ORGS_ONLY
      • ALL_EXISTING_AND_FUTURE_ORGS
      • IMMEDIATE_EXISTING_ORGS_ONLY
      • IMMEDIATE_EXISTING_AND_FUTURE_ORGS
  3. General User Unsharing:
    • Covers single and multiple users.
  4. Selective User Unsharing:
    • Covers single and multiple users.
    • Covers single and multiple organizations.

Failure Scenarios

  1. Selective User Sharing:
    • Selective User Sharing with invalid roles (single and multiple invalid roles).
    • Selective User Sharing with invalid organizations (single and multiple invalid organizations).
    • Selective User Sharing with invalid users (single and multiple invalid users).
    • Selective User Sharing with conflicting users (user exists in a child organization under the same username).
    • Selective User Sharing with non-immediate child organizations.
  2. General User Sharing:
    • General User Sharing with invalid roles.
    • General User Sharing with invalid users.
    • General User Sharing with conflicting users.
  3. General User Unsharing:
    • General User Unsharing with invalid users (single and multiple invalid users).
  4. Selective User Unsharing:
    • Selective User Unsharing with invalid users and invalid organizations (single and multiple cases).
  5. Selective User Re-Sharing:
    • Invalid Selective User Re-sharing (a shared user from a parent org cannot be re-shared from a child org).
  6. General User Re-Sharing:
    • Invalid General User Re-sharing (a shared user from a parent org cannot be re-shared from a child org).

Related Issue

Add Integration Tests for User Sharing API #23328

@BimsaraBodaragama
Copy link
Member Author

BimsaraBodaragama commented Mar 11, 2025

Integration Test Runner

Attempt 1

Integration Test Runner For this PR can be found here.
Status: Faliure ❌

The failure is unrelated to this PR and originates from UserMeNegativeTestBase.

[INFO] Results:
 [INFO] 
 [ERROR] Failures: 
 [ERROR] org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeNegativeTestBase.testCreateExitingAssociationAgain(org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeNegativeTestBase)
 [INFO] Run 1: PASS
 [ERROR] Run 2: UserMeNegativeTestBase.testCreateExitingAssociationAgain:140 1 expectation failed.
 Expected status code <409> but was <400>.

Attempt 2

Integration Test Runner For this PR can be found here.
Status: Successful ✅

Attempt 3

Integration Test Runner For this PR can be found here.
Status: Faliure ❌

The failure is unrelated to this PR and originates from UserMeNegativeTestBase.

 [INFO] Results:
 [INFO] 
 [ERROR] Failures: 
 [ERROR] org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeNegativeTestBase.testCreateExitingAssociationAgain(org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeNegativeTestBase)
 [INFO] Run 1: PASS
 [ERROR] Run 2: UserMeNegativeTestBase.testCreateExitingAssociationAgain:140 1 expectation failed.
 Expected status code <409> but was <400>.

Attempt 4

Integration Test Runner For this PR can be found here.
Status: Successful ✅

Attempt 5

Integration Test Runner For this PR can be found here.
Status: Successful ✅

Attempt 6

Integration Test Runner For this PR can be found here.
Status: Successful ✅

Attempt 7

Integration Test Runner For this PR can be found here.
Status: Faliure ❌

The failure is unrelated to this PR and originates from UserMeNegativeTestBase.

 [INFO] Results:
 [INFO] 
 [ERROR] Failures: 
 [ERROR] org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeNegativeTestBase.testCreateExitingAssociationAgain(org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeNegativeTestBase)
 [INFO] Run 1: PASS
 [ERROR] Run 2: UserMeNegativeTestBase.testCreateExitingAssociationAgain:140 1 expectation failed.
 Expected status code <409> but was <400>.

Attempt 8

Integration Test Runner For this PR can be found here.
Status: Faliure ❌

The failure is unrelated to this PR and originates from UserMeSuccessTestBase.

 [INFO] Results:
 [INFO] 
 [ERROR] Failures: 
 [ERROR] org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeSuccessTestBase.testCreateAssociation(org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeSuccessTestBase)
 [INFO] Run 1: PASS
 [ERROR] Run 2: UserMeSuccessTestBase.testCreateAssociation:145->createLocalAssociation:251 1 expectation failed.
 Expected status code <201> but was <400>.
 
 [INFO] 
 [ERROR] org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeSuccessTestBase.testGetFederatedAssociations(org.wso2.identity.integration.test.rest.api.user.association.v1.UserMeSuccessTestBase)
 [INFO] Run 1: PASS
 [ERROR] Run 2: UserMeSuccessTestBase.testGetFederatedAssociations:193 1 expectation failed.
 JSON path size() doesn't match.
 Expected: is <2>
 Actual: <0>

Attempt 9

Integration Test Runner For this PR can be found here.
Status: Successful ✅

Attempt 10

Integration Test Runner For this PR can be found here.
Status: Successful ✅

The integration test runner for this PR has been triggered and executed multiple times to ensure there are no intermittent test failures caused by awaiting the completion of asynchronous processes involved in these integration tests introduced in this PR.

@jenkins-is-staging
Copy link
Contributor

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/13804306135

@jenkins-is-staging
Copy link
Contributor

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/13804306135
Status: success

Copy link
Contributor

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/13804306135

@SujanSanjula96 SujanSanjula96 merged commit 9cd74cb into wso2:master Mar 12, 2025
3 checks passed
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.

3 participants