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

Refactor local API tests of JSON responses #3179

Closed
phil-davis opened this issue Feb 16, 2022 · 3 comments
Closed

Refactor local API tests of JSON responses #3179

phil-davis opened this issue Feb 16, 2022 · 3 comments
Assignees
Labels

Comments

@phil-davis
Copy link
Contributor

phil-davis commented Feb 16, 2022

There are scenarios that test the JSON response to various spaces API requests. For example:

  Scenario: A user can see that a received shared space is available
    Given user "Alice" has created a space "Share space to Brian" of type "project" with quota "10"
    And user "Alice" has shared a space "Share space to Brian" to user "Brian" with role "viewer"
    When user "Brian" lists all available spaces via the GraphApi
    Then the json responded should contain a space "Share space to Brian" owned by "Alice" with these key and value pairs:
      | key                                                | value                |
      | driveType                                          | project              |
      | id                                                 | %space_id%           |
      | name                                               | Share space to Brian |
      | root@@@permissions@@@0@@@grantedTo@@@0@@@user@@@id | %user_id%            |
      | root@@@permissions@@@0@@@roles@@@0                 | manager              |


  Scenario: A user can see who has been granted access
    Given user "Alice" has created a space "Share space to Brian" of type "project" with quota "10"
    And user "Alice" has shared a space "Share space to Brian" to user "Brian" with role "viewer"
    When user "Alice" lists all available spaces via the GraphApi
    Then the json responded should contain a space "Share space to Brian" granted to "Brian" with these key and value pairs:
      | key                                                | value     |
      | root@@@permissions@@@1@@@grantedTo@@@0@@@user@@@id | %user_id% |
      | root@@@permissions@@@1@@@roles@@@0                 | viewer    |

Those drill-down into the JSON response structure and have specific numeric array indices mentioned. (see the "0" and "1" mentioned in the above) Those are brittle because they depend on the exact order of entries in the JSON response.

  1. refactor the code so that it can look for and find the data anywhere in the numeric-indexed arrays

  2. implement a nicer way of referring to the nested array structure than having those "@@@" in the scenario steps.

Note: (2) can also be done in the core API tests, they are where the "@@@" thing came from. See owncloud/core#39796

@phil-davis
Copy link
Contributor Author

@ScharfViktor I am thinking about this, and will work on a proposed core solution for issue owncloud/core#39796 and you can review. Once we agree on what is a good refactoring, then someone can also implement here in oCIS local API tests.

@SagarGi
Copy link
Member

SagarGi commented Feb 17, 2023

We have used to check the response of the json using a library in core with this PR owncloud/core#40619. We can use the similar library in ocis and refactor the test code.

TODO:

@SagarGi
Copy link
Member

SagarGi commented Apr 5, 2023

All test suite related to the json schema assertion has been replaced and added. So closing this issue .

@SagarGi SagarGi closed this as completed Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants