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

[OP#49621] fix app password form becomes inactive #456

Merged
merged 5 commits into from
Aug 16, 2023

Conversation

SwikritiT
Copy link
Collaborator

@SwikritiT SwikritiT commented Aug 10, 2023

Fixes: https://community.openproject.org/projects/nextcloud-integration/work_packages/49621/

Our previous check for hasAppPassword expects the user "OpenProject" to have only one app password. But in cases where the user "OpenProject" has multiple app passwords for instance if the user is logged in somewhere it will create a session app password, this check will return false which will result in the project folder section in the administrative form being disabled.

# previous code
return sizeof($this->tokenProvider->getTokenByUser(Application::OPEN_PROJECT_ENTITIES_NAME)) === 1;

So in this PR we loop through all the tokens and only return true if the token with the name "OpenProject" exists and also while deleting, delete all the tokens with the name "OpenProject". This fixes the issue we are facing

@SwikritiT SwikritiT force-pushed the bug/49621-openproject-form-becomes-inactive branch 2 times, most recently from 568db26 to a5666f2 Compare August 10, 2023 11:17
@SwikritiT SwikritiT marked this pull request as ready for review August 10, 2023 11:27
Copy link
Collaborator

@individual-it individual-it left a comment

Choose a reason for hiding this comment

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

Is is possible to cover that with unit tests?

@SagarGi
Copy link
Collaborator

SagarGi commented Aug 11, 2023

Is is possible to cover that with unit tests?

Also we can add API test for it as well. @SwikritiT

Copy link
Collaborator

@SagarGi SagarGi left a comment

Choose a reason for hiding this comment

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

I checked it manually and seems to be working more fine now.

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
@SwikritiT SwikritiT force-pushed the bug/49621-openproject-form-becomes-inactive branch 2 times, most recently from 5d23965 to d29b991 Compare August 14, 2023 05:28
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
@SwikritiT SwikritiT force-pushed the bug/49621-openproject-form-becomes-inactive branch from d29b991 to 5137f8f Compare August 14, 2023 05:45
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
@SwikritiT SwikritiT force-pushed the bug/49621-openproject-form-becomes-inactive branch from 2613180 to dea267c Compare August 14, 2023 07:07
@SwikritiT
Copy link
Collaborator Author

@SagarGi @individual-it I added the tests can you review it again please

Copy link
Collaborator

@SagarGi SagarGi left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -1739,6 +1744,36 @@ public function testIsSystemReadyForGroupFolderSetUpUserOrGroupExistsException(
$service->isSystemReadyForProjectFolderSetUp();
}

public function testProjectFolderHasAppPassword(): void {
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets add also a test where multiple tokens are returned but only one is an OpenProject token.
and what happens if multiple tokens have the name OpenProject?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If there are multiple OpenProject tokens then hasAppPassword will return true but while deleting it will delete all the app passwords before creating a new one. Is that okay or do we want to check if there's only one token named OpenProject and if there are multiple then send an error message?

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
@SwikritiT SwikritiT force-pushed the bug/49621-openproject-form-becomes-inactive branch 2 times, most recently from 0e6406b to bb7f8f7 Compare August 15, 2023 08:21
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
@SwikritiT SwikritiT force-pushed the bug/49621-openproject-form-becomes-inactive branch from bb7f8f7 to 7c44315 Compare August 15, 2023 08:44
@github-actions
Copy link

JS Code Coverage

Coverage after merging bug/49621-openproject-form-becomes-inactive into release/2.4 will be
88.01%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   adminSettings.js0%0%0%0%1, 1, 10–19, 2, 20–25, 3–9
   bootstrap.js0%0%0%0%1, 1–7
   dashboard.js0%0%0%0%1, 1, 10–19, 2, 20–25, 3–9
   fileActions.js0%0%0%0%1, 1, 10–17, 2–9
   personalSettings.js0%0%0%0%1, 1, 10–19, 2, 20–25, 3–9
   projectTab.js0%0%0%0%1, 1, 10–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60–66, 7–9
   reference.js0%0%0%0%1, 1, 10–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60, 7–9
   utils.js63.64%33.33%50%66%10–14, 17–26, 6–9
src/components
   AdminSettings.vue99.28%95.29%84.62%99.91%1, 1, 1, 1, 1
   OAuthConnectButton.vue99.17%87.50%100%100%1
   PersonalSettings.vue98.87%93.33%85.71%100%1
src/components/admin
   FieldValue.vue97.12%83.33%100%98.89%1, 23, 23
   FormHeading.vue97.66%75%100%99.36%1, 1, 34, 34
   ProjectFolderError.vue96.83%80%100%98.21%1, 1
   TextInput.vue99.25%95%88.89%100%1
src/components/icons
   ClippyIcon.vue93.18%50%50%97.50%1, 1
   OpenProjectIcon.vue93.75%100%0%96.77%1
src/components/settings
   CheckBox.vue92.45%80%66.67%97.62%1, 1
   SettingsTitle.vue94.74%50%100%97.14%1, 1
src/components/tab
   EmptyContent.vue97.04%78.95%100%99.32%1, 1, 1, 33, 33
   SearchInput.vue99.21%88.89%80%100%1
   WorkPackage.vue98.36%40%100%99.33%1, 1, 1, 43, 43
src/utils
   workpackageHelper.js94.21%88%100%95.65%17–19, 48, 48–50
src/views
   Dashboard.vue98.97%71.43%100%99.65%1, 1, 1
   ProjectsTab.vue99.74%93.75%100%100%23
   WorkPackagePickerElement.vue0%0%0%0%1, 1, 10–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60–69, 7, 70–79, 8, 80–89, 9, 90–91
   WorkPackageReferenceWidget.vue0%0%0%0%1, 1, 10, 100–109, 11, 110–119, 12, 120–129, 13, 130–132, 14–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60–69, 7, 70–79, 8, 80–89, 9, 90–99

@github-actions
Copy link

PHP Code Coverage

Coverage after merging bug/49621-openproject-form-becomes-inactive into release/2.4 will be
57.20%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
server/apps/integration_openproject/lib/AppInfo
   Application.php11.43%100%25%9.68%100–102, 106–109, 111, 115–120, 131, 135, 68–69, 72, 76, 79, 83, 85, 89, 94, 96–98
server/apps/integration_openproject/lib/BackgroundJob
   RemoveExpiredDirectUploadTokens.php0%100%0%0%42, 44–46, 55–56
server/apps/integration_openproject/lib/Controller
   ConfigController.php66.40%100%50%67.36%134, 151–152, 154, 156–158, 160–161, 166–167, 169, 219, 280, 369–370, 373–374, 504–507, 509–510, 513, 521, 532, 546–548, 563–567, 569–570, 572–575, 577–579, 597–602, 604–605, 607–609, 612, 614–617, 619–621, 635, 644–647, 649–652, 662–667
   DirectDownloadController.php0%100%0%0%36–38, 53–55, 57, 60–61
   DirectUploadController.php71.43%100%100%70.43%131–132, 177, 190, 194–197, 199, 209, 216, 232–234, 236–237, 240–242, 248, 250, 255–256, 263–264, 267–268, 271–272, 288–289, 309, 314, 320
   FilesController.php78.86%100%100%77.59%168, 220–221, 272, 278–282, 285–287, 289, 291, 302–304, 307–308, 310–311, 315–318, 321
   OpenProjectAPIController.php82.27%100%73.33%82.93%138, 175, 192–195, 199, 203, 205–210, 212, 221–224, 227, 229, 231–234, 236–237, 242, 254, 263, 281, 290, 555, 557, 95
server/apps/integration_openproject/lib/Dashboard
   OpenProjectWidget.php0%100%0%0%101–102, 104–108, 116, 123–124, 126, 128–129, 131–132, 134, 137–138, 140–141, 143, 69–73, 80, 87, 94
server/apps/integration_openproject/lib/Exception
   OpenprojectErrorException.php100%100%100%100%
   OpenprojectFileNotUploadedException.php100%100%100%100%
   OpenprojectGroupfolderSetupConflictException.php100%100%100%100%
   OpenprojectResponseException.php100%100%100%100%
   OpenprojectUnauthorizedUserException.php0%100%0%0%16
server/apps/integration_openproject/lib/Listener
   BeforeGroupDeletedListener.php0%100%0%0%48, 56–57, 60–63
   BeforeNodeInsideOpenProjectGroupfilderChangedListener.php0%100%0%0%40–42, 46–51, 53–58, 60, 62, 66
   BeforeUserDeletedListener.php0%100%0%0%48, 55–56, 58–61
   LoadSidebarScript.php0%100%0%0%100, 102, 104, 106–108, 110, 112, 114–115, 117–118, 120, 122, 75–81, 83–84, 86–87, 89–90, 96–97, 99
   OpenProjectReferenceListener.php0%100%0%0%53–54, 58–59, 62–63, 65, 67
   UserChangedListener.php0%100%0%0%52, 59–60, 63–68
server/apps/integration_openproject/lib/Migration
   Version2001Date20221213083550.php0%100%0%0%47, 57, 60, 63, 67, 70, 73, 77–79, 81
   Version2310Date20230116153411.php0%100%0%0%46, 49–52, 54–56, 60, 64, 68, 72, 76, 81–82, 84
   Version2400Date20230504144300.php0%100%0%0%47, 57, 60
server/apps/integration_openproject/lib/Reference
   WorkPackageReferenceProvider.php0%100%0%0%102–105, 108–110, 113, 120–123, 125, 127–129, 131, 133, 135, 139, 148, 156–157, 165, 53, 60, 67, 74–75, 89–92, 95
server/apps/integration_openproject/lib/Search
   OpenProjectSearchProvider.php0%100%0%0%103–104, 107–114, 116–118, 121–122, 124–125, 129–134, 140–141, 143, 66–69, 76, 83, 91, 93, 96
   OpenProjectSearchResultEntry.php100%100%100%100%
server/apps/integration_openproject/lib/Service
   DatabaseService.php43.90%100%60%41.67%125–128, 131, 80–87, 89–93, 95–97
   DirectDownloadService.php88%100%100%86.96%65–66, 68
   DirectUploadService.php54.55%100%66.67%52.63%112, 118, 79–82, 84, 89, 91
   OauthService.php0%100%0%0%108–115, 45–47, 56–66, 68, 70–72, 75–78, 89, 91–94, 96–97
   OpenProjectAPIService.php70.61%100%70.73%70.60%1000, 1006, 1011, 1015, 1025, 1027, 1030, 1032, 1163–1170, 1172, 1180–1184, 1192–1199, 1216–1223, 1232–1237, 180–184, 255, 364–365, 367, 381–382, 391, 395, 416, 504–505, 512, 515–518, 520, 526, 530–532, 552, 562–565, 569–570,

@SwikritiT SwikritiT merged commit 0398905 into release/2.4 Aug 16, 2023
24 checks passed
@delete-merged-branch delete-merged-branch bot deleted the bug/49621-openproject-form-becomes-inactive branch August 16, 2023 03:36
SwikritiT added a commit that referenced this pull request Aug 18, 2023
* Check and remove the app password with name OpenProject

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add phpunit test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add api test to cover the bug

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test for multiple token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test for delete token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
SwikritiT added a commit that referenced this pull request Aug 21, 2023
* Check and remove the app password with name OpenProject

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add phpunit test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add api test to cover the bug

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test for multiple token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test for delete token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
SwikritiT added a commit that referenced this pull request Aug 21, 2023
* [OP#48106] use same component as project tab for searching in smart picker (#448)

* reuse component

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

reuse

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

emit event

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add op icon vue

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix failing tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* check for access token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* address review

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* Fix the lable of managed project folder (#452)

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* [OP#49182] Fix the form heading index colour in different themes (#453)

* Fix the colour of the indexes in different themes

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* update snapshots

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix style lint

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* [OP#49621] fix app password form becomes inactive (#456)

* Check and remove the app password with name OpenProject

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add phpunit test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add api test to cover the bug

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test for multiple token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test for delete token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* [OP#49435] Nextcloud oauth section should not be disabled when the user deletes the oauth credentials (#457)

* [#49435] Nextcloud oauth section should not be disabled when the user deletes the oauth credentials

https://community.openproject.org/work_packages/49435
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix project folder form

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix and add unit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix the feature

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* Fix link previewd

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix link on front end and fix test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix failing php unit test and add more patterns'

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add php test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* ignore path

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* Support global work package URL without split view

Signed-off-by: Wieland Lindenthal <w.lindenthal@forkmerge.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
Signed-off-by: Wieland Lindenthal <w.lindenthal@forkmerge.com>
Co-authored-by: Wieland Lindenthal <w.lindenthal@forkmerge.com>
SwikritiT added a commit that referenced this pull request Aug 21, 2023
* [OP#48106] use same component as project tab for searching in smart picker (#448)

* reuse component

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

reuse

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

emit event

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add op icon vue

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix failing tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* check for access token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* address review

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* Fix the lable of managed project folder (#452)

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* [OP#49182] Fix the form heading index colour in different themes (#453)

* Fix the colour of the indexes in different themes

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* update snapshots

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix style lint

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* [OP#49621] fix app password form becomes inactive (#456)

* Check and remove the app password with name OpenProject

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add phpunit test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add api test to cover the bug

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test for multiple token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add unit test for delete token

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* [OP#49435] Nextcloud oauth section should not be disabled when the user deletes the oauth credentials (#457)

* [#49435] Nextcloud oauth section should not be disabled when the user deletes the oauth credentials

https://community.openproject.org/work_packages/49435
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix project folder form

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix and add unit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix the feature

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* Fix link previewd

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix link on front end and fix test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix failing php unit test and add more patterns'

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* add php test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* ignore path

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* Support global work package URL without split view

Signed-off-by: Wieland Lindenthal <w.lindenthal@forkmerge.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
Signed-off-by: Wieland Lindenthal <w.lindenthal@forkmerge.com>
Co-authored-by: Wieland Lindenthal <w.lindenthal@forkmerge.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants