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

LibreSign / libresign / 19839372203

01 Dec 2025 10:16PM UTC coverage: 40.771%. First build
19839372203

Pull #5872

github

web-flow
Merge 7fad3608b into c3ec57e4c
Pull Request #5872: feat: certificate type classification

33 of 70 new or added lines in 7 files covered. (47.14%)

4963 of 12173 relevant lines covered (40.77%)

3.99 hits per line

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

68.75
/lib/Db/Crl.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
7
 * SPDX-License-Identifier: AGPL-3.0-or-later
8
 */
9

10
namespace OCA\Libresign\Db;
11

12
use OCA\Libresign\Enum\CertificateType;
13
use OCA\Libresign\Enum\CRLStatus;
14
use OCP\AppFramework\Db\Entity;
15
use OCP\DB\Types;
16

17
/**
18
 * @method void setId(int $id)
19
 * @method int getId()
20
 * @method void setSerialNumber(string $serialNumber)
21
 * @method string getSerialNumber()
22
 * @method void setOwner(string $owner)
23
 * @method string getOwner()
24
 * @method void setReasonCode(?int $reasonCode)
25
 * @method ?int getReasonCode()
26
 * @method void setRevokedBy(?string $revokedBy)
27
 * @method ?string getRevokedBy()
28
 * @method void setRevokedAt(?\DateTime $revokedAt)
29
 * @method ?\DateTime getRevokedAt()
30
 * @method void setInvalidityDate(?\DateTime $invalidityDate)
31
 * @method ?\DateTime getInvalidityDate()
32
 * @method void setCrlNumber(?int $crlNumber)
33
 * @method ?int getCrlNumber()
34
 * @method void setIssuedAt(\DateTime $issuedAt)
35
 * @method \DateTime getIssuedAt()
36
 * @method void setValidTo(?\DateTime $validTo)
37
 * @method ?\DateTime getValidTo()
38
 * @method void setComment(?string $comment)
39
 * @method ?string getComment()
40
 * @method void setEngine(string $engine)
41
 * @method string getEngine()
42
 * @method void setInstanceId(?string $instanceId)
43
 * @method ?string getInstanceId()
44
 * @method void setGeneration(?int $generation)
45
 * @method ?int getGeneration()
46
 * @method void setIssuer(?string $issuer)
47
 * @method ?string getIssuer()
48
 * @method void setSubject(?string $subject)
49
 * @method ?string getSubject()
50
 */
51
class Crl extends Entity {
52
        protected string $serialNumber = '';
53
        protected string $owner = '';
54
        protected string $status = 'issued';
55
        protected ?int $reasonCode = null;
56
        protected ?string $revokedBy = null;
57
        protected ?\DateTime $revokedAt = null;
58
        protected ?\DateTime $invalidityDate = null;
59
        protected ?int $crlNumber = null;
60
        protected ?\DateTime $issuedAt = null;
61
        protected ?\DateTime $validTo = null;
62
        protected ?string $comment = null;
63
        protected string $engine = '';
64
        protected ?string $instanceId = null;
65
        protected ?int $generation = null;
66
        protected ?string $issuer = null;
67
        protected ?string $subject = null;
68
        protected string $certificateType = 'leaf';
69

70
        public function __construct() {
71
                $this->addType('id', Types::BIGINT);
60✔
72
                $this->addType('serialNumber', Types::STRING);
60✔
73
                $this->addType('status', Types::STRING);
60✔
74
                $this->addType('reasonCode', Types::SMALLINT);
60✔
75
                $this->addType('crlNumber', Types::BIGINT);
60✔
76
                $this->addType('revokedAt', Types::DATETIME);
60✔
77
                $this->addType('invalidityDate', Types::DATETIME);
60✔
78
                $this->addType('issuedAt', Types::DATETIME);
60✔
79
                $this->addType('validTo', Types::DATETIME);
60✔
80
                $this->addType('comment', Types::STRING);
60✔
81
                $this->addType('engine', Types::STRING);
60✔
82
                $this->addType('instanceId', Types::STRING);
60✔
83
                $this->addType('generation', Types::BIGINT);
60✔
84
                $this->addType('issuer', Types::TEXT);
60✔
85
                $this->addType('subject', Types::TEXT);
60✔
86
                $this->addType('certificateType', Types::STRING);
60✔
87
        }
88

89
        public function getStatus(): string {
90
                return $this->status;
1✔
91
        }
92

93
        public function setStatus(CRLStatus|string $status): void {
94
                $value = $status instanceof CRLStatus ? $status->value : $status;
52✔
95
                $this->setter('status', [$value]);
52✔
96
        }
97

98
        public function getCertificateTypeEnum(): CertificateType {
NEW
99
                return CertificateType::from($this->certificateType);
×
100
        }
101

102
        public function getCertificateType(): string {
103
                return $this->certificateType;
49✔
104
        }
105

106
        public function setCertificateType(CertificateType|string $type): void {
107
                $value = $type instanceof CertificateType ? $type->value : $type;
49✔
108
                $this->setter('certificateType', [$value]);
49✔
109
        }
110

111
        public function getIssuer(): ?string {
112
                return $this->issuer;
49✔
113
        }
114

115
        public function getIssuerData(): ?array {
NEW
116
                if ($this->issuer === null) {
×
NEW
117
                        return null;
×
118
                }
NEW
119
                $decoded = json_decode($this->issuer, true);
×
NEW
120
                return is_array($decoded) ? $decoded : null;
×
121
        }
122

123
        public function setIssuer(?string $issuer): void {
NEW
124
                $this->setter('issuer', [$issuer]);
×
125
        }
126

127
        public function setIssuerFromArray(?array $issuer): void {
128
                if ($issuer === null) {
49✔
NEW
129
                        $this->setter('issuer', [null]);
×
NEW
130
                        return;
×
131
                }
132
                $this->setter('issuer', [json_encode($issuer)]);
49✔
133
        }
134

135
        public function getSubject(): ?string {
136
                return $this->subject;
49✔
137
        }
138

139
        public function getSubjectData(): ?array {
NEW
140
                if ($this->subject === null) {
×
NEW
141
                        return null;
×
142
                }
NEW
143
                $decoded = json_decode($this->subject, true);
×
NEW
144
                return is_array($decoded) ? $decoded : null;
×
145
        }
146

147
        public function setSubject(?string $subject): void {
NEW
148
                $this->setter('subject', [$subject]);
×
149
        }
150

151
        public function setSubjectFromArray(?array $subject): void {
152
                if ($subject === null) {
49✔
NEW
153
                        $this->setter('subject', [null]);
×
NEW
154
                        return;
×
155
                }
156
                $this->setter('subject', [json_encode($subject)]);
49✔
157
        }
158

159
        public function isRevoked(): bool {
160
                return CRLStatus::from($this->status) === CRLStatus::REVOKED;
16✔
161
        }
162

163
        public function isExpired(): bool {
164
                if ($this->validTo === null) {
15✔
165
                        return false;
1✔
166
                }
167
                return $this->validTo < new \DateTime();
14✔
168
        }
169

170
        public function isValid(): bool {
171
                return !$this->isRevoked() && !$this->isExpired();
3✔
172
        }
173
}
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