Skip to content

Handle groups with slash and percent in provisioning API - #31017

Closed
phil-davis wants to merge 1 commit into
masterfrom
group-name-api-tests
Closed

phil-davis wants to merge 1 commit into
masterfrom
group-name-api-tests

Conversation

@phil-davis

@phil-davis phil-davis commented Apr 5, 2018 •

Copy link
Copy Markdown
Contributor

Description

  1. Add a range of test cases to the apiProvisioning acceptance test suite covering various group name combinations, including with / % ? etc.
  2. Modify apps/provisioning_api/lib/Groups.php so it will turn a literal %2F into a / - that provides a way to pass a / in a group name. (from outside you pass in %252F and the %25 turns into a % by the time it gets through the server and is delivered to Groups.php)
  3. Similarly turn a literal %25 into a % - you need that so you can always escape a % if you want to construct a literal group like my%25group or my%2Fgroup

Related Issue

#31015

Motivation and Context

It is nice to be able to use all group names in the Provisioning API.

How Has This Been Tested?

Local API acceptance test runs.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov

codecov Bot commented Apr 5, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #31017 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #31017      +/-   ##
============================================
+ Coverage     62.57%   62.57%   +<.01%     
- Complexity    18249    18250       +1     
============================================
  Files          1145     1145              
  Lines         68416    68419       +3     
  Branches       1234     1234              
============================================
+ Hits          42809    42812       +3     
  Misses        25246    25246              
  Partials        361      361
Flag Coverage Δ Complexity Δ
#javascript 52.05% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 63.77% <100%> (ø) 18250 <1> (+1) ⬆️
Impacted Files Coverage Δ Complexity Δ
apps/provisioning_api/lib/Groups.php 100% <100%> (ø) 25 <1> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2016b5...57c3ced. Read the comment docs.

@phil-davis

Copy link
Copy Markdown
Contributor Author

@PVince81 @DeepDiver1975 can you have a look at the approach I took in Groups.php and comment if it seems fine (or not)?

@individual-it can review the test changes/additions.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

this needs to be added to the documentation @settermjd

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@PVince81 objections?

@felixboehm felixboehm modified the milestones: development, planned Apr 10, 2018
@phil-davis
phil-davis force-pushed the group-name-api-tests branch 4 times, most recently from 0076442 to 57c3ced Compare April 20, 2018 13:03
@codecov-io

codecov-io commented Apr 20, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #31017 into master will decrease coverage by 0.78%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #31017      +/-   ##
============================================
- Coverage      64.8%   64.01%   -0.79%     
- Complexity    18375    18667     +292     
============================================
  Files          1199     1176      -23     
  Lines         69573    70236     +663     
  Branches       1282     1267      -15     
============================================
- Hits          45089    44964     -125     
- Misses        24111    24902     +791     
+ Partials        373      370       -3
Flag Coverage Δ Complexity Δ
#javascript 52.84% <ø> (-0.24%) 0 <ø> (ø)
#phpunit 65.28% <100%> (-0.88%) 18667 <1> (+292)
Impacted Files Coverage Δ Complexity Δ
apps/provisioning_api/lib/Groups.php 100% <100%> (ø) 27 <1> (+1) ⬆️
apps/files/lib/ActivityHelper.php 0% <0%> (-100%) 8% <0%> (ø)
...l/InsufficientDataForMeaningfulAnswerException.php 0% <0%> (-100%) 1% <0%> (ø)
lib/private/DB/MySqlTools.php 0% <0%> (-88.47%) 4% <0%> (-7%)
...iles/External/Auth/Password/SessionCredentials.php 0% <0%> (-82.61%) 5% <0%> (-1%)
apps/files_external/lib/Command/Config.php 0% <0%> (-80%) 0% <0%> (ø)
core/Command/User/ResetPassword.php 0% <0%> (-70.53%) 12% <0%> (-11%)
apps/comments/lib/Activity/Listener.php 25.58% <0%> (-69.77%) 11% <0%> (ø)
apps/systemtags/lib/Activity/Listener.php 0% <0%> (-62.89%) 29% <0%> (-3%)
lib/public/SystemTag/MapperEvent.php 38.46% <0%> (-61.54%) 5% <0%> (ø)
... and 260 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce83d92...277c859. Read the comment docs.

@phil-davis
phil-davis force-pushed the group-name-api-tests branch 3 times, most recently from 8657136 to d087fe6 Compare April 25, 2018 06:52
* @return string
*/
private function unencodeGroupId($groupId) {
return \strtr($groupId, ['%25' => '%', '%2F' => '/']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't there a PHP function that does that like urldecode or rawurldecode ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what about "@" signs ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"@" signs work OK (API tests here check creating, working with and deleting such group names)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I remember in some cases when talking Webdav we had to encode the "@" sign, so not sure if it applies here. what if a third party client decides to URL encode other special chars ?

@phil-davis phil-davis Apr 25, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At this point we do not want to urldecode everything. If somebody wanted something literally in a group name like group%29435 then they really do want those characters in the group name, so we do not want to decode %29 into whatever ASCII that is.

Actually they will have sent us group%2529435 so that the % gets escaped on the way through and re-formed here.

@phil-davis

Copy link
Copy Markdown
Contributor Author

This needs more thought to make sure it parses all group name possibilities.

Related PRs in progress:
#31109 do not urlencode group id - tries to sort out some issues with group names with slashes having members listed correctly on the webUI.

#31224 generated resource routes should allow /
that might allow a slash in a group name to be passed through/over by routing, and the group name with slash delivered as the parameter to the back-end code. If that all works without breaking other stuff, then maybe this PR will not be needed.

@phil-davis
phil-davis force-pushed the group-name-api-tests branch 3 times, most recently from 2429053 to e3640ca Compare April 27, 2018 06:05
@phil-davis
phil-davis force-pushed the group-name-api-tests branch from 63762d6 to e0e5387 Compare May 17, 2018 03:37
@phil-davis
phil-davis force-pushed the group-name-api-tests branch from e0e5387 to 7b89570 Compare May 17, 2018 11:47
@phil-davis
phil-davis force-pushed the group-name-api-tests branch 2 times, most recently from 93dda56 to ce3c449 Compare May 23, 2018 10:05
@phil-davis
phil-davis force-pushed the group-name-api-tests branch 3 times, most recently from 8647d27 to ecce517 Compare June 12, 2018 02:31
@phil-davis
phil-davis force-pushed the group-name-api-tests branch from ecce517 to 8a69f14 Compare June 27, 2018 06:38
@PVince81

Copy link
Copy Markdown
Contributor

So we fixed the app framework in #31224 but the provisioning API is not using it and uses OCS instead.

As far as I remember there is a way to port the old OCS way to use App Framework controllers, but that would likely be a lot more work.

@phil-davis

Copy link
Copy Markdown
Contributor Author

I think we have come up with other ways to make this all work - I will look at what PRs are "out there".
I rebased this to keep to up-to-date in case some part of it looks useful.

@phil-davis
phil-davis force-pushed the group-name-api-tests branch 2 times, most recently from 1565ca9 to bf385ab Compare August 24, 2018 07:10
@phil-davis

Copy link
Copy Markdown
Contributor Author

Rebased again to merge in the addition of skipped tests in master yesterday. Let's see what CI thinks.

@PVince81

PVince81 commented Feb 5, 2019

Copy link
Copy Markdown
Contributor

conflict.

didn't we fix slash handling somewhere before ?

@phil-davis

Copy link
Copy Markdown
Contributor Author

I will rebase/resolve conflicts and check this again. Last time I looked there were still problems when the group name needs to be an embedded part of the URL - the slashes become ambiguous.

@phil-davis

Copy link
Copy Markdown
Contributor Author

Rebased and resolved conflicts. Let's see what CI thinks.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

As discussed in #35777 the master branch will from now on hold the ownCloud 10 codebase.

This PR targetted ownCloud 11 which is postponed to a far distant future.

Because of that I'm closing this PR and kindly ask you to re-submit this PR in a few days.

Thanks a lot for your patience

@phil-davis
phil-davis deleted the group-name-api-tests branch June 18, 2020 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants