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

Commit 2b0b59a

Browse files
committed
test: add tests directly on binary
1 parent 3f2a910 commit 2b0b59a

4 files changed

Lines changed: 42 additions & 4 deletions

File tree

.github/scripts/cosmian_tests.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
export KMS_CLI_FORMAT=json
6+
SEED="11223344556677889900AABBCCDDEEFF11223344556677889900AABBCCDDEEFF"
7+
COSMIAN="cargo run --bin cosmian --"
8+
9+
# Create the key encryption key
10+
kek_id=$($COSMIAN kms sym keys create | jq -r '.unique_identifier')
11+
echo "kek_id: $kek_id"
12+
13+
# Create the index ID
14+
index_id=$($COSMIAN findex-server permissions create | sed 's/Created Index ID: //')
15+
echo "index_id: $index_id"
16+
17+
# Encrypt and index the data
18+
$COSMIAN findex-server encrypt-and-index --seed $SEED --index-id "$index_id" --kek-id "$kek_id" --csv test_data/datasets/smallpop.csv
19+
20+
# Search and decrypt the data
21+
expected_line=$($COSMIAN findex-server search-and-decrypt --seed $SEED --index-id "$index_id" --kek-id "$kek_id" --keyword "Southborough" | sed 's/Decrypted records: //')
22+
echo "expected_line: $expected_line"
23+
24+
# Check the result
25+
if [[ "$expected_line" != "[\"SouthboroughMAUnited States9686\"]" ]]; then
26+
echo "Test failed: unexpected result"
27+
exit 1
28+
else
29+
echo "Test passed"
30+
exit 0
31+
fi

.github/workflows/build_all.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ jobs:
3232
target: x86_64-unknown-linux-gnu
3333
prerequisites: |
3434
sudo apt-get update
35-
sudo apt-get install -qq librust-atk-sys-dev librust-gdk-sys-dev pkg-config
35+
sudo apt-get install -qq librust-atk-sys-dev librust-gdk-sys-dev pkg-config jq
3636
docker_compose: true
3737

3838
- distribution: ubuntu-22.04
3939
archive-name: ubuntu_22_04
4040
target: x86_64-unknown-linux-gnu
4141
prerequisites: |
4242
sudo apt-get update
43-
sudo apt-get install -qq librust-atk-sys-dev librust-gdk-sys-dev pkg-config
43+
sudo apt-get install -qq librust-atk-sys-dev librust-gdk-sys-dev pkg-config jq
4444
docker_compose: true
4545

4646
- distribution: ubuntu-24.04
4747
archive-name: ubuntu_24_04
4848
target: x86_64-unknown-linux-gnu
4949
prerequisites: |
5050
sudo apt-get update
51-
sudo apt-get install -qq libgtk-3-dev libglib2.0-dev pkg-config
51+
sudo apt-get install -qq libgtk-3-dev libglib2.0-dev pkg-config jq
5252
docker_compose: true
5353

5454
- distribution: macos-13

.github/workflows/build_generic.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ jobs:
8686
run: |
8787
bash .github/scripts/cargo_build.sh
8888
89+
- name: Cosmian tests
90+
if: contains(runner.os, 'Linux')
91+
run: |
92+
set -ex
93+
bash .github/scripts/cosmian_tests.sh
94+
8995
- name: Remove large files before saving cache
9096
run: |
9197
find target/ -type f -size +100M -delete

crate/cli/src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use cosmian_config_utils::{location, ConfigUtils};
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};
7+
use tracing::debug;
78

89
use crate::error::CosmianError;
910

@@ -48,7 +49,7 @@ impl ClientConf {
4849
/// not a valid toml file.
4950
pub fn load(conf_path: Option<PathBuf>) -> Result<Self, CosmianError> {
5051
let conf_path_buf = Self::location(conf_path)?;
51-
println!("Loading configuration from: {conf_path_buf:?}");
52+
debug!("Loading configuration from: {conf_path_buf:?}");
5253

5354
Ok(Self::from_toml(conf_path_buf.to_str().ok_or_else(
5455
|| {

0 commit comments

Comments
 (0)