• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 20801999300

08 Jan 2026 01:11AM UTC coverage: 44.692%. First build
20801999300

Pull #6397

github

web-flow
Merge 8818e7c5a into ef69784e5
Pull Request #6397: fix: translate gateway whatsapp to gowhastaspp

1 of 9 new or added lines in 3 files covered. (11.11%)

6731 of 15061 relevant lines covered (44.69%)

5.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

17.95
/lib/Service/IdentifyMethod/TwofactorGateway.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Service\IdentifyMethod;
10

11
use OCA\Libresign\Db\FileElementMapper;
12
use OCA\Libresign\Db\IdentifyMethodMapper;
13
use OCA\Libresign\Service\SessionService;
14
use OCA\TwoFactorGateway\Provider\Gateway\Factory;
15
use OCP\App\IAppManager;
16
use OCP\AppFramework\Utility\ITimeFactory;
17
use OCP\Files\IRootFolder;
18
use OCP\IUserSession;
19
use OCP\Server;
20
use Psr\Log\LoggerInterface;
21

22
class TwofactorGateway extends AbstractIdentifyMethod {
23
        public function __construct(
24
                protected IdentifyService $identifyService,
25
                private IdentifyMethodMapper $identifyMethodMapper,
26
                private IRootFolder $root,
27
                private ITimeFactory $timeFactory,
28
                private SessionService $sessionService,
29
                private FileElementMapper $fileElementMapper,
30
                private IUserSession $userSession,
31
                private LoggerInterface $logger,
32
                private IAppManager $appManager,
33
        ) {
34
                parent::__construct(
47✔
35
                        $identifyService,
47✔
36
                );
47✔
37
        }
38

39
        #[\Override]
40
        public function validateToIdentify(): void {
41
                $this->throwIfMaximumValidityExpired();
×
42
                $this->throwIfRenewalIntervalExpired();
×
43
                $this->throwIfFileNotFound();
×
44
                $this->throwIfAlreadySigned();
×
45
                $this->renewSession();
×
46
                $this->updateIdentifiedAt();
×
47
        }
48

49
        #[\Override]
50
        public function validateToSign(): void {
51
                $this->throwIfInvalidToken();
×
52
                $this->throwIfMaximumValidityExpired();
×
53
                $this->throwIfRenewalIntervalExpired();
×
54
                $this->throwIfFileNotFound();
×
55
                $this->throwIfAlreadySigned();
×
56
                $this->renewSession();
×
57
                $this->updateIdentifiedAt();
×
58
        }
59

60
        public function isTwofactorGatewayEnabled(): bool {
61
                $isAppEnabled = $this->appManager->isEnabledForAnyone('twofactor_gateway');
13✔
62
                if (!$isAppEnabled) {
13✔
63
                        $this->logger->info('Twofactor Gateway app is not enabled');
13✔
64
                        return false;
13✔
65
                }
66
                /** @var Factory */
67
                $gatewayFactory = Server::get(Factory::class);
×
68

NEW
69
                $gatewayName = $this->getGatewayName();
×
70

71
                $gateway = $gatewayFactory->get($gatewayName);
×
72
                return $gateway->isComplete();
×
73
        }
74

75
        private function getGatewayName(): string {
NEW
76
                return match ($this->getId()) {
×
NEW
77
                        'whatsapp' => 'gowhatsapp',
×
NEW
78
                        default => strtolower($this->getId()),
×
NEW
79
                };
×
80
        }
81

82
        #[\Override]
83
        public function getSettings(): array {
84
                if (!empty($this->settings)) {
×
85
                        return $this->settings;
×
86
                }
87
                $this->settings = parent::getSettingsFromDatabase(
×
88
                        default: [
×
89
                                'enabled' => false,
×
90
                        ],
×
91
                        immutable: [
×
92
                                'test_url' => $this->identifyService->getUrlGenerator()->linkToRoute('settings.PersonalSettings.index', ['section' => 'security']),
×
93
                        ]
×
94
                );
×
95
                return $this->settings;
×
96
        }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc