Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit aa59ed6

Browse files
committed
chore: fix tests, add coverage
1 parent f6e17a8 commit aa59ed6

File tree

11 files changed

+186
-12
lines changed

11 files changed

+186
-12
lines changed

fixtures/tokens_base_fixture.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ INSERT INTO public_keys (id, uaid, pubkey, algorithm_identifier) VALUES
3131
(5, '00000000-0000-0000-0000-000000000001', 'test_pubkey_1_b', 1),
3232
(6, '00000000-0000-0000-0000-000000000004', 'test_pubkey_4_b', 1);
3333

34-
-- Test issuers
35-
INSERT INTO issuers (id, domain_components, pem_encoded) VALUES
36-
(1, ARRAY['example', 'com'], 'test_issuer_pem_1'),
37-
(2, ARRAY['test', 'org'], 'test_issuer_pem_2');
38-
3934
-- Test ID-CSRs (for all test users)
4035
INSERT INTO idcsr (
4136
id, serial_number, uaid, actor_public_key_id, actor_signature,
@@ -50,6 +45,11 @@ INSERT INTO idcsr (
5045
-- Additional ID-CSR with unique serial number for user 4 (for testing expired tokens)
5146
(6, 55555555555555555556, '00000000-0000-0000-0000-000000000004', 6, 'test_signature_4_b', 'test_session_4_b', NOW() - INTERVAL '1 day', NOW() + INTERVAL '1 day', 'test_extensions_4_b', 'test_csr_pem_4_b');
5247

48+
-- Test issuers (must be inserted after idcsr because of foreign key constraint)
49+
INSERT INTO issuers (id, domain_components, pem_encoded) VALUES
50+
(1, ARRAY['example', 'com'], 'test_csr_pem_1'),
51+
(2, ARRAY['test', 'org'], 'test_csr_pem_2');
52+
5353
-- Test ID-Certs
5454
-- User 1 and 2 have certificates (for basic scenarios)
5555
-- User 4 has a certificate (for extended scenarios)

src/api/admin/db/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::{
1111
};
1212

1313
/// Create an invite.
14+
#[cfg_attr(coverage_nightly, coverage(off))]
1415
pub(super) async fn create_invite(
1516
owner: Option<&Uuid>,
1617
code: Option<&str>,

src/api/auth/login.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::{
1515
};
1616

1717
#[handler]
18+
#[cfg_attr(coverage_nightly, coverage(off))]
1819
pub(super) async fn login(
1920
Json(payload): Json<LoginSchema>,
2021
Data(db): Data<&Database>,

src/api/auth/register.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use crate::{
1616
errors::{Context, Errcode, Error},
1717
};
1818

19-
#[cfg_attr(coverage_nightly, coverage(off))]
2019
#[handler]
20+
#[cfg_attr(coverage_nightly, coverage(off))]
2121
pub(super) async fn register(
2222
Json(payload): Json<RegisterSchema>,
2323
Data(db): Data<&Database>,

src/api/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@
44

55
use log::info;
66
use poem::{
7-
EndpointExt, IntoResponse, Response, Route, Server,
8-
error::ResponseError,
9-
handler,
7+
EndpointExt, IntoResponse, Response, Route, Server, handler,
108
http::{Method, StatusCode},
119
listener::TcpListener,
1210
middleware::{Cors, NormalizePath},
13-
web::Json,
1411
};
15-
use serde_json::json;
1612

1713
use crate::{
1814
config::ApiConfig,
1915
database::{Database, tokens::TokenStore},
20-
errors::Error,
2116
};
2217

2318
/// Admin-only functionality.

src/crypto/ed25519/private_key.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub(crate) struct DigitalPrivateKey {
99
pubkey: DigitalPublicKey,
1010
}
1111

12+
#[cfg_attr(coverage_nightly, coverage(off))]
1213
impl PrivateKey<DigitalSignature> for DigitalPrivateKey {
1314
type PublicKey = DigitalPublicKey;
1415

src/crypto/ed25519/public_key.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub(crate) struct DigitalPublicKey {
88
key: VerifyingKey,
99
}
1010

11+
#[cfg_attr(coverage_nightly, coverage(off))]
1112
impl PublicKey<DigitalSignature> for DigitalPublicKey {
1213
fn verify_signature(
1314
&self,
@@ -39,6 +40,7 @@ impl PublicKey<DigitalSignature> for DigitalPublicKey {
3940
}
4041
}
4142

43+
#[cfg_attr(coverage_nightly, coverage(off))]
4244
fn try_from_public_key_info(
4345
public_key_info: polyproto::certs::PublicKeyInfo,
4446
) -> Result<Self, polyproto::errors::CertificateConversionError> {

src/crypto/ed25519/signature.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ pub(crate) struct DigitalSignature {
1515
pub(super) signature: ed25519_dalek::Signature,
1616
}
1717

18+
#[cfg_attr(coverage_nightly, coverage(off))]
1819
impl SignatureBitStringEncoding for DigitalSignature {
1920
fn to_bitstring(&self) -> polyproto::der::Result<BitString> {
2021
BitString::from_bytes(&self.as_signature().to_bytes())
2122
}
2223
}
2324

25+
#[cfg_attr(coverage_nightly, coverage(off))]
2426
impl std::fmt::Display for DigitalSignature {
2527
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2628
f.write_str(&self.signature.to_string())
2729
}
2830
}
2931

32+
#[cfg_attr(coverage_nightly, coverage(off))]
3033
impl SignatureTrait for DigitalSignature {
3134
type Signature = ed25519_dalek::Signature;
3235

src/database/algorithm_identifier.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub(crate) struct AlgorithmIdentifier {
1313
pub(crate) parameters: Option<String>,
1414
}
1515

16+
#[cfg_attr(coverage_nightly, coverage(off))]
1617
impl AlgorithmIdentifier {
1718
/// Tries to find an entry or entries from the `algorithm_identifiers` table
1819
/// matching the given parameter(s). The more parameters given, the more

src/database/issuer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub(crate) struct Issuer {
1414
pub(crate) id_cert: IdCert<DigitalSignature, DigitalPublicKey>,
1515
}
1616

17+
#[cfg_attr(coverage_nightly, coverage(off))]
1718
impl Issuer {
1819
/// Create (insert) the issuer entry for this sonata instance. Returns
1920
/// `None`, if there is already a valid issuer entry for the given point in

0 commit comments

Comments
 (0)