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

Commit 29dffd1

Browse files
committed
test: run all tests on ubuntu runners
1 parent cf544b1 commit 29dffd1

13 files changed

Lines changed: 149 additions & 114 deletions

File tree

.github/scripts/cargo_build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ rm -f /tmp/*.json /tmp/*.toml
8080
cargo build --target $TARGET $RELEASE $FEATURES
8181

8282
export RUST_LOG="cosmian_cli=trace,cosmian_findex_client=trace,cosmian_kmip=error,cosmian_kms_rest_client=info"
83+
# Retry once if the test fails
8384
# shellcheck disable=SC2086
84-
cargo test --target $TARGET $RELEASE $FEATURES --workspace -- --nocapture $SKIP_SERVICES_TESTS
85+
cargo test --target $TARGET $RELEASE $FEATURES --workspace -- --nocapture $SKIP_SERVICES_TESTS ||
86+
cargo test --target $TARGET $RELEASE $FEATURES --workspace -- --nocapture $SKIP_SERVICES_TESTS
8587

8688
# while true; do
8789
# sleep 1

.github/workflows/build_all.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ jobs:
3232
target: x86_64-unknown-linux-gnu
3333
prerequisites: |
3434
sudo apt install librust-atk-sys-dev librust-gdk-sys-dev pkg-config
35-
skip_services_tests: --skip test_encrypt --skip test_create
36-
docker_compose: false
35+
docker_compose: true
3736

3837
- distribution: ubuntu-22.04
3938
archive-name: ubuntu_22_04
@@ -48,8 +47,7 @@ jobs:
4847
prerequisites: |
4948
sudo apt update
5049
sudo apt install libgtk-3-dev libglib2.0-dev pkg-config
51-
skip_services_tests: --skip test_encrypt --skip test_create
52-
docker_compose: false
50+
docker_compose: true
5351

5452
- distribution: macos-13
5553
archive-name: macos_intel

crate/cli/src/actions/encrypt_and_index.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66

77
use clap::Parser;
88
use cosmian_findex_cli::{
9-
actions::findex::{instantiate_findex, FindexParameters},
9+
actions::findex::{FindexParameters, instantiate_findex},
1010
reexports::{
1111
cloudproof_findex::reexport::cosmian_findex::{
1212
Data, IndexedValue, IndexedValueToKeywordsMap, Keyword, Keywords,
@@ -28,8 +28,8 @@ use crate::{
2828

2929
/// Encrypt entries and index the corresponding database UUIDs with the Findex.
3030
///
31-
/// First the CSV file is read and encrypted on client-side with KEM-DEM crypto-system
32-
/// KEM: Key Encapsulation Mechanism
31+
/// First the CSV file is read and encrypted on client-side with KEM-DEM
32+
/// crypto-system KEM: Key Encapsulation Mechanism
3333
/// DEM: Data Encapsulation Mechanism
3434
#[derive(Parser, Debug)]
3535
#[clap(verbatim_doc_comment)]
@@ -42,9 +42,11 @@ pub struct EncryptAndIndexAction {
4242
pub(crate) csv_path: PathBuf,
4343

4444
/// The key encryption key (KEK) unique identifier.
45-
/// If provided, all encryption is done client side. The KEK is first exported locally and is used in the KEM to encapsulates the ephemeral Data Encryption Key (DEK).
46-
/// This KEK has been created in KMS and provides the Key Encapsulation Mechanism (KEM) parameters such as algorithm and mode.
47-
/// KEM supported are:
45+
/// If provided, all encryption is done client side. The KEK is first
46+
/// exported locally and is used in the KEM to encapsulates the ephemeral
47+
/// Data Encryption Key (DEK). This KEK has been created in KMS and
48+
/// provides the Key Encapsulation Mechanism (KEM) parameters such as
49+
/// algorithm and mode. KEM supported are:
4850
/// - RFC5649
4951
/// - AES-GCM
5052
/// - RSA PKCS#1 v1.5
@@ -53,8 +55,8 @@ pub struct EncryptAndIndexAction {
5355
/// - Salsa Sealed Box
5456
/// - ECIES
5557
///
56-
/// If no key encryption key is specified, the data will be sent to the server
57-
/// and will be encrypted server side.
58+
/// If no key encryption key is specified, the data will be sent to the
59+
/// server and will be encrypted server side.
5860
#[clap(long = "kek-id", group = "kem", conflicts_with = "dem")]
5961
pub(crate) key_encryption_key_id: Option<String>,
6062

crate/cli/src/actions/findex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use clap::Subcommand;
2-
use cosmian_findex_cli::{reexports::cosmian_findex_client::FindexRestClient, CoreFindexActions};
2+
use cosmian_findex_cli::{CoreFindexActions, reexports::cosmian_findex_client::FindexRestClient};
33
use cosmian_kms_cli::reexport::cosmian_kms_client::KmsClient;
44

55
use super::{encrypt_and_index::EncryptAndIndexAction, search_and_decrypt::SearchAndDecryptAction};
6-
use crate::error::{result::CosmianResult, CosmianError};
6+
use crate::error::{CosmianError, result::CosmianResult};
77

88
#[derive(Subcommand)]
99
pub enum FindexActions {

crate/cli/src/actions/markdown.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{fmt::Write, fs::File, io::Write as io_Write, path::PathBuf};
22

3-
use clap::{builder::StyledStr, Command, Parser};
3+
use clap::{Command, Parser, builder::StyledStr};
44

55
use crate::error::result::CosmianResult;
66

@@ -17,7 +17,8 @@ impl MarkdownAction {
1717
///
1818
/// # Errors
1919
///
20-
/// Returns an error if there is an issue creating or writing to the markdown file.
20+
/// Returns an error if there is an issue creating or writing to the
21+
/// markdown file.
2122
#[allow(clippy::print_stdout)]
2223
pub fn process(&self, cmd: &Command) -> CosmianResult<()> {
2324
let mut output = String::new();

crate/cli/src/actions/search_and_decrypt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clap::Parser;
22
use cosmian_findex_cli::{
3-
actions::findex::{instantiate_findex, FindexParameters},
3+
actions::findex::{FindexParameters, instantiate_findex},
44
reexports::{
55
cloudproof_findex::reexport::cosmian_findex::{Keyword, Keywords},
66
cosmian_findex_client::FindexRestClient,
@@ -51,8 +51,8 @@ pub struct SearchAndDecryptAction {
5151
/// The data encryption algorithm.
5252
/// If not specified, aes-gcm is used.
5353
///
54-
/// If no key encryption algorithm is specified, the data will be sent to the server
55-
/// and will be decrypted server side.
54+
/// If no key encryption algorithm is specified, the data will be sent to
55+
/// the server and will be decrypted server side.
5656
#[clap(
5757
long = "data-encryption-algorithm",
5858
short = 'd',

crate/cli/src/commands.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::path::PathBuf;
22

33
use clap::{CommandFactory, Parser, Subcommand};
4-
use cosmian_findex_cli::{reexports::cosmian_findex_client::FindexRestClient, CoreFindexActions};
5-
use cosmian_kms_cli::{reexport::cosmian_kms_client::KmsClient, KmsActions};
4+
use cosmian_findex_cli::{CoreFindexActions, reexports::cosmian_findex_client::FindexRestClient};
5+
use cosmian_kms_cli::{KmsActions, reexport::cosmian_kms_client::KmsClient};
66
use cosmian_logger::log_init;
77
use tracing::{info, trace};
88

@@ -32,8 +32,8 @@ pub struct Cli {
3232

3333
/// Allow to connect using a self-signed cert or untrusted cert chain
3434
///
35-
/// `accept_invalid_certs` is useful if the CLI needs to connect to an HTTPS KMS server
36-
/// running an invalid or insecure SSL certificate
35+
/// `accept_invalid_certs` is useful if the CLI needs to connect to an HTTPS
36+
/// KMS server running an invalid or insecure SSL certificate
3737
#[arg(long)]
3838
pub kms_accept_invalid_certs: bool,
3939

@@ -49,8 +49,8 @@ pub struct Cli {
4949

5050
/// Allow to connect using a self-signed cert or untrusted cert chain
5151
///
52-
/// `accept_invalid_certs` is useful if the CLI needs to connect to an HTTPS KMS server
53-
/// running an invalid or insecure SSL certificate
52+
/// `accept_invalid_certs` is useful if the CLI needs to connect to an HTTPS
53+
/// KMS server running an invalid or insecure SSL certificate
5454
#[arg(long)]
5555
pub findex_accept_invalid_certs: bool,
5656
}
@@ -65,16 +65,18 @@ pub enum CliCommands {
6565
#[command(subcommand)]
6666
FindexServer(FindexActions),
6767
/// Action to auto-generate doc in Markdown format
68-
/// Run `cargo run --bin cosmian -- markdown documentation/docs/cli/main_commands.md`
68+
/// Run `cargo run --bin cosmian -- markdown
69+
/// documentation/docs/cli/main_commands.md`
6970
#[clap(hide = true)]
7071
Markdown(MarkdownAction),
7172
}
7273

7374
/// Main function for the CKMS CLI application.
7475
///
75-
/// This function initializes logging, parses command-line arguments, and executes the appropriate
76-
/// command based on the provided arguments. It supports various subcommands for interacting with
77-
/// the CKMS, such as login, logout, locating objects, and more.
76+
/// This function initializes logging, parses command-line arguments, and
77+
/// executes the appropriate command based on the provided arguments. It
78+
/// supports various subcommands for interacting with the CKMS, such as login,
79+
/// logout, locating objects, and more.
7880
///
7981
/// # Errors
8082
///

crate/cli/src/config.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::path::PathBuf;
22

3-
use cosmian_config_utils::{location, ConfigUtils};
3+
use cosmian_config_utils::{ConfigUtils, location};
44
use cosmian_findex_cli::reexports::cosmian_findex_client::FindexClientConfig;
55
use cosmian_kms_cli::reexport::cosmian_kms_client::KmsClientConfig;
66
use serde::{Deserialize, Serialize};
@@ -31,7 +31,8 @@ impl ClientConf {
3131
/// Load the default location of the configuration file.
3232
///
3333
/// # Errors
34-
/// Return an error if the configuration file is not found or if the file is not a valid toml file.
34+
/// Return an error if the configuration file is not found or if the file is
35+
/// not a valid toml file.
3536
pub fn location(conf: Option<PathBuf>) -> Result<PathBuf, CosmianError> {
3637
Ok(location(
3738
conf,
@@ -43,7 +44,8 @@ impl ClientConf {
4344

4445
/// Load the configuration from a toml file.
4546
/// # Errors
46-
/// Return an error if the configuration file is not found or if the file is not a valid toml file.
47+
/// Return an error if the configuration file is not found or if the file is
48+
/// not a valid toml file.
4749
pub fn load(conf_path: Option<PathBuf>) -> Result<Self, CosmianError> {
4850
let conf_path_buf = Self::location(conf_path)?;
4951
println!("Loading configuration from: {conf_path_buf:?}");
@@ -60,7 +62,8 @@ impl ClientConf {
6062
/// Save the configuration to a toml file.
6163
///
6264
/// # Errors
63-
/// Return an error if the configuration file is not found or if the file is not a valid toml file.
65+
/// Return an error if the configuration file is not found or if the file is
66+
/// not a valid toml file.
6467
pub fn save(&self, conf_path: Option<PathBuf>) -> Result<(), CosmianError> {
6568
let conf_path_buf = Self::location(conf_path)?;
6669
println!("Saving configuration to: {conf_path_buf:?}");
@@ -77,10 +80,10 @@ impl ConfigUtils for ClientConf {}
7780
mod tests {
7881
use std::{env, fs, path::PathBuf};
7982

80-
use cosmian_config_utils::{get_default_conf_path, ConfigUtils};
83+
use cosmian_config_utils::{ConfigUtils, get_default_conf_path};
8184
use cosmian_logger::log_init;
8285

83-
use super::{ClientConf, COSMIAN_CLI_CONF_ENV};
86+
use super::{COSMIAN_CLI_CONF_ENV, ClientConf};
8487
use crate::config::COSMIAN_CLI_CONF_PATH;
8588

8689
#[test]
@@ -109,9 +112,11 @@ mod tests {
109112
get_default_conf_path(COSMIAN_CLI_CONF_PATH).unwrap(),
110113
));
111114
assert!(ClientConf::load(None).is_ok());
112-
assert!(get_default_conf_path(COSMIAN_CLI_CONF_PATH)
113-
.unwrap()
114-
.exists());
115+
assert!(
116+
get_default_conf_path(COSMIAN_CLI_CONF_PATH)
117+
.unwrap()
118+
.exists()
119+
);
115120

116121
// invalid conf
117122
unsafe {

crate/cli/src/error/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use thiserror::Error;
1212

1313
pub mod result;
1414

15-
// Each error type must have a corresponding HTTP status code (see `kmip_endpoint.rs`)
15+
// Each error type must have a corresponding HTTP status code (see
16+
// `kmip_endpoint.rs`)
1617
#[derive(Error, Debug)]
1718
pub enum CosmianError {
1819
// When a user requests an endpoint which does not exist

crate/cli/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub mod commands;
3232
pub mod config;
3333
pub mod error;
3434

35-
pub use commands::{cosmian_main, Cli, CliCommands};
35+
pub use commands::{Cli, CliCommands, cosmian_main};
3636

3737
#[cfg(test)]
3838
mod tests;

0 commit comments

Comments
 (0)