Skip to content

Commit

Permalink
ci: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuthor committed Nov 3, 2024
1 parent e7dc054 commit afafc41
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 39 deletions.
4 changes: 3 additions & 1 deletion .github/scripts/cargo_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ fi
rustup target add "$TARGET"

# shellcheck disable=SC2086
cargo build --target $TARGET $RELEASE $FEATURES
cargo build --target $TARGET $RELEASE

export RUST_LOG="cosmian_findex_cli=trace,cosmian_findex_server=trace,test_findex_server=trace"

# shellcheck disable=SC2086
cargo test --target $TARGET $RELEASE --workspace -- --nocapture $SKIP_SERVICES_TESTS
4 changes: 2 additions & 2 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
archive-name: ${{ matrix.archive-name }}
target: ${{ matrix.target }}
debug_or_release: ${{ inputs.debug_or_release }}
skip_services_tests: --skip test_findex
skip_services_tests: --skip test_findex --skip test_all_authentications --skip test_server_auth_matrix

generic-macos:
strategy:
Expand All @@ -58,7 +58,7 @@ jobs:
archive-name: ${{ matrix.archive-name }}
target: ${{ matrix.target }}
debug_or_release: ${{ inputs.debug_or_release }}
skip_services_tests: --skip test_findex
skip_services_tests: --skip test_findex --skip test_all_authentications --skip test_server_auth_matrix

cleanup:
needs:
Expand Down
2 changes: 1 addition & 1 deletion crate/cli/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub enum CliError {
Unauthorized(String),

// A cryptographic error
#[error("Cryptographic error: {0}")]
#[error("CLI Cryptographic error: {0}")]
Cryptographic(String),

// Conversion errors
Expand Down
2 changes: 1 addition & 1 deletion crate/cli/src/tests/auth_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tracing::{info, trace};
use crate::{error::result::CliResult, tests::PROG_NAME};

// let us not make other test cases fail
const PORT: u16 = 9999;
const PORT: u16 = 6666;

#[tokio::test]
#[allow(clippy::needless_return)]
Expand Down
35 changes: 8 additions & 27 deletions crate/client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use std::{
path::PathBuf,
};

// #[cfg(target_os = "linux")]
// use log::info;
use serde::{Deserialize, Serialize};
use tracing::info;

Expand Down Expand Up @@ -84,23 +82,6 @@ pub struct Oauth2Conf {
pub scopes: Vec<String>,
}

/// The configuration that is used by the google command
/// to perform actions over Gmail API.
#[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)]
pub struct GmailApiConf {
pub account_type: String,
pub project_id: String,
pub private_key_id: String,
pub private_key: String,
pub client_email: String,
pub client_id: String,
pub auth_uri: String,
pub token_uri: String,
pub auth_provider_x509_cert_url: String,
pub client_x509_cert_url: String,
pub universe_domain: String,
}

#[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone)]
pub struct ClientConf {
// accept_invalid_certs is useful if the cli needs to connect to an HTTPS Findex server
Expand Down Expand Up @@ -294,6 +275,11 @@ impl ClientConf {
let findex_server_url = findex_server_url.unwrap_or(&self.findex_server_url);
let accept_invalid_certs = accept_invalid_certs.unwrap_or(self.accept_invalid_certs);

info!(
"Initializing Findex REST client with server URL: {findex_server_url}, \
accept_invalid_certs: {accept_invalid_certs}"
);

// Instantiate a Findex server REST client with the given configuration
let rest_client = RestClient::instantiate(
findex_server_url,
Expand Down Expand Up @@ -326,18 +312,13 @@ mod tests {
let conf_path = ClientConf::location(None).unwrap();
ClientConf::load(&conf_path).unwrap();

// another valid conf
unsafe {
env::set_var(FINDEX_CLI_CONF_ENV, "test_data/configs/findex_partial.json");
}
let conf_path = ClientConf::location(None).unwrap();
ClientConf::load(&conf_path).unwrap();

// Default conf file
unsafe {
env::remove_var(FINDEX_CLI_CONF_ENV);
}
fs::remove_file(get_default_conf_path().unwrap()).unwrap();
if get_default_conf_path().unwrap().exists() {
fs::remove_file(get_default_conf_path().unwrap()).unwrap();
}
let conf_path = ClientConf::location(None).unwrap();
ClientConf::load(&conf_path).unwrap();
assert!(get_default_conf_path().unwrap().exists());
Expand Down
2 changes: 1 addition & 1 deletion crate/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
clippy::significant_drop_tightening
)]

pub use config::{ClientConf, GmailApiConf, FINDEX_CLI_CONF_ENV};
pub use config::{ClientConf, FINDEX_CLI_CONF_ENV};
pub use error::ClientError;
pub use file_utils::{
read_bytes_from_file, read_from_json_file, write_bytes_to_file, write_json_object_to_file,
Expand Down
2 changes: 1 addition & 1 deletion crate/client/test_data/configs/findex.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"findex_server_url": "http://127.0.0.1:666{}",
"findex_server_url": "http://127.0.0.1:6660",
"findex_access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjVVU1FrSVlULW9QMWZrcjQtNnRrciJ9.eyJuaWNrbmFtZSI6InRlY2giLCJuYW1lIjoidGVjaEBjb3NtaWFuLmNvbSIsInBpY3R1cmUiOiJodHRwczovL3MuZ3JhdmF0YXIuY29tL2F2YXRhci81MmZiMzFjOGNjYWQzNDU4MTIzZDRmYWQxNDA4NTRjZj9zPTQ4MCZyPXBnJmQ9aHR0cHMlM0ElMkYlMkZjZG4uYXV0aDAuY29tJTJGYXZhdGFycyUyRnRlLnBuZyIsInVwZGF0ZWRfYXQiOiIyMDIzLTA1LTMwVDA5OjMxOjExLjM4NloiLCJlbWFpbCI6InRlY2hAY29zbWlhbi5jb20iLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsImlzcyI6Imh0dHBzOi8va21zLWNvc21pYW4uZXUuYXV0aDAuY29tLyIsImF1ZCI6IkszaXhldXhuVDVrM0Roa0tocWhiMXpYbjlFNjJGRXdJIiwiaWF0IjoxNjg1NDM5MDc0LCJleHAiOjE2ODU0NzUwNzQsInN1YiI6ImF1dGgwfDYzZDNkM2VhOTNmZjE2NDJjNzdkZjkyOCIsInNpZCI6ImJnVUNuTTNBRjVxMlpaVHFxMTZwclBCMi11Z0NNaUNPIiwibm9uY2UiOiJVRUZWTlZWeVluWTVUbHBwWjJScGNqSmtVMEZ4TmxkUFEwc3dTVGMwWHpaV2RVVmtkVnBEVGxSMldnPT0ifQ.HmU9fFwZ-JjJVlSy_PTei3ys0upeWQbWWiESmKBtRSClGnAXJNCpwuP4Jw7fgKn-8IBf-PYmP1_54u2Rw3RcJFVl7EblVoGMghYxVq5hViGpd00st3VwZmyCwOUz2CE5RBnBAoES4C8xA3zWg6oau0xjFQbC3jNU20eyFYMDewXA8UXCHQrEiQ56ylqSbyqlBbQIWbmOO4m5w2WDkx0bVyyJ893JfIJr_NANEQMJITYo8Mp_iHCyKp7llsfgCt07xN8ZqnsrMsJ15zC1n50bHGrTQisxURS1dpuFXF1hfrxhzogxYMX8CEISjsFgROjPY84GRMmvpYZfyaJbDDql3A"
}
4 changes: 0 additions & 4 deletions crate/client/test_data/configs/findex_partial.json

This file was deleted.

2 changes: 1 addition & 1 deletion crate/test_server/src/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ pub(crate) static ONCE: OnceCell<TestsContext> = OnceCell::const_new();
pub(crate) static ONCE_SERVER_WITH_AUTH: OnceCell<TestsContext> = OnceCell::const_new();

fn redis_db_config() -> DBConfig {
trace!("TESTS: using redis-findex");
let url = if let Ok(var_env) = env::var("REDIS_HOST") {
format!("redis://{var_env}:6379")
} else {
"redis://localhost:6379".to_owned()
};
trace!("TESTS: using redis on {url}");
DBConfig {
database_type: Some(DatabaseType::Redis),
clear_database: true,
Expand Down

0 comments on commit afafc41

Please sign in to comment.