Skip to content

Commit

Permalink
Fix test failure due to changes and fix CI
Browse files Browse the repository at this point in the history
Signed-off-by: Sagar <[email protected]>
  • Loading branch information
SagarGi committed Oct 16, 2024
1 parent 79ed572 commit c1d0cc6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/Service/OpenProjectAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OCA\TermsOfService\Db\Mapper\TermsMapper;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\Encryption\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
Expand All @@ -56,7 +57,6 @@
use OCP\Security\ISecureRandom;
use OCP\Server;
use Psr\Log\LoggerInterface;
use OCP\Encryption\IManager;

define('CACHE_TTL', 3600);

Expand Down
6 changes: 3 additions & 3 deletions src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
:project-folder-set-up-error="state.project_folder_info.errorMessage" />
<NcNoteCard v-else-if="showEncryptionWarningForGroupFolders" class="note-card" type="warning">
<p><b>Encryption for Group Folders are not enabled.</b></p>
<p class="note-card--info" v-html="getGroupFolderEncryptionWarningHint"></p> <!-- eslint-disable-line vue/no-v-html -->
<p class="note-card--info" v-html="getGroupFolderEncryptionWarningHint" /> <!-- eslint-disable-line vue/no-v-html -->
</NcNoteCard>
<div class="form-actions">
<NcButton
Expand Down Expand Up @@ -581,10 +581,10 @@ export default {
},
showEncryptionWarningForGroupFolders() {
if (!this.isProjectFolderAlreadySetup || !this.state.app_password_set || this.isProjectFolderSetupFormInEdit) {
return false;
return false
}
return this.state.encryption_info.server_side_encryption_enabled
&& !this.state.encryption_info.encryption_enabled_for_groupfolders;
&& !this.state.encryption_info.encryption_enabled_for_groupfolders
},
},
created() {
Expand Down
12 changes: 12 additions & 0 deletions tests/jest/components/AdminSettings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,10 @@ describe('AdminSettings.vue', () => {
},
fresh_project_folder_setup: true,
app_password_set: false,
encryption_info: {
server_side_encryption_enabled: false,
encryption_enabled_for_groupfolders: false,
},
},
isGroupFolderAlreadySetup: null,
})
Expand Down Expand Up @@ -1245,6 +1249,10 @@ describe('AdminSettings.vue', () => {
status: true,
},
app_password_set: true,
encryption_info: {
server_side_encryption_enabled: false,
encryption_enabled_for_groupfolders: false,
},
},
})
await wrapper.setData({
Expand Down Expand Up @@ -1373,6 +1381,10 @@ describe('AdminSettings.vue', () => {
status: true,
},
app_password_set: true,
encryption_info: {
server_side_encryption_enabled: false,
encryption_enabled_for_groupfolders: false,
},
},
isGroupFolderAlreadySetup: null,
})
Expand Down
19 changes: 15 additions & 4 deletions tests/lib/Service/OpenProjectAPIServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use OCA\TermsOfService\Db\Mapper\SignatoryMapper;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\Encryption\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
Expand Down Expand Up @@ -747,7 +748,8 @@ private function getOpenProjectAPIService(
$this->createMock(IEventDispatcher::class),
$this->createMock(ISubAdmin::class),
$this->createMock(IDBConnection::class),
$this->createMock(ILogFactory::class)
$this->createMock(ILogFactory::class),
$this->createMock(IManager::class),
);
}

Expand All @@ -765,6 +767,7 @@ private function getOpenProjectAPIService(
* @param IDBConnection|null $db
* @param IURLGenerator|null $iURLGenerator
* @param ILogFactory|null $iLogFactory
* @param IManager|null $iManager
* @return OpenProjectAPIService|MockObject
*/
private function getServiceMock(
Expand All @@ -780,6 +783,7 @@ private function getServiceMock(
$tokenProviderMock = null,
$db = null,
$iLogFactory = null,
$iManager = null,
$iURLGenerator = null
): OpenProjectAPIService {
$onlyMethods[] = 'getBaseUrl';
Expand Down Expand Up @@ -819,6 +823,9 @@ private function getServiceMock(
if ($iLogFactory === null) {
$iLogFactory = $this->createMock(ILogFactory::class);
}
if ($iManager === null) {
$iManager = $this->createMock(IManager::class);
}
$mock = $this->getMockBuilder(OpenProjectAPIService::class)
->setConstructorArgs(
[
Expand All @@ -840,6 +847,7 @@ private function getServiceMock(
$subAdminManagerMock,
$db,
$iLogFactory,
$iManager,
$iURLGenerator
])
->onlyMethods($onlyMethods)
Expand Down Expand Up @@ -2106,8 +2114,8 @@ public function testRequestConnectException(
$this->createMock(IEventDispatcher::class),
$this->createMock(ISubAdmin::class),
$this->createMock(IDBConnection::class),
$this->createMock(ILogFactory::class)

$this->createMock(ILogFactory::class),
$this->createMock(IManager::class),
);

$response = $service->request('', '', []);
Expand Down Expand Up @@ -2177,7 +2185,8 @@ public function testRequestClientServerException(
$this->createMock(IEventDispatcher::class),
$this->createMock(ISubAdmin::class),
$this->createMock(IDBConnection::class),
$this->createMock(ILogFactory::class)
$this->createMock(ILogFactory::class),
$this->createMock(IManager::class)
);

$response = $service->request('', '', []);
Expand Down Expand Up @@ -3395,6 +3404,7 @@ public function testGetAvailableOpenProjectProjectsQueryOnly() {
null,
null,
null,
null,
$iUrlGeneratorMock
);
$service->method('request')
Expand Down Expand Up @@ -3773,6 +3783,7 @@ public function testGetWorkPackageInfoForExistentWorkPackage(): void {
null,
null,
null,
null,
$iULGeneratorMock
);
$imageURL = 'http://nextcloud/server/index.php/apps/integration_openproject/avatar?userId=3&userName=OpenProject Admin';
Expand Down

0 comments on commit c1d0cc6

Please sign in to comment.