Skip to content

Commit

Permalink
feat: generate local certs on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
YoussefAWasfy committed Oct 8, 2024
1 parent 5551856 commit 3bcd57c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
13 changes: 11 additions & 2 deletions affinidi-messaging-mediator/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async fn test_mediator_server() {
// Generate secrets and did for mediator if not existing
if !fs::metadata(SECRETS_PATH).is_ok() {
println!("Generating secrets");
_generate_keys();
_generate_secrets();
let mediator_did = _get_did_from_secrets(SECRETS_PATH.into());
_inject_did_into_config(CONFIG_PATH, &mediator_did);
Expand All @@ -62,7 +63,7 @@ async fn test_mediator_server() {

let config = Config::builder()
.with_ssl_certificates(&mut vec![
"../affinidi-messaging-mediator/tests/keys/client.chain".into(),
"../affinidi-messaging-mediator/conf/keys/client.chain".into(),
])
.build()
.unwrap();
Expand Down Expand Up @@ -798,7 +799,7 @@ fn _generate_secrets() {
let output = Command::new("cargo")
.args(&["run", "--example", "generate_secrets"])
.output()
.expect("Failed to run example");
.expect("Failed to generate secrets");
assert!(output.status.success());
let source_path = "../affinidi-messaging-mediator/conf/secrets.json-generated";

Expand All @@ -808,6 +809,14 @@ fn _generate_secrets() {
};
}

fn _generate_keys() {
let output = Command::new("cargo")
.args(&["run", "--example", "create_local_certs"])
.output()
.expect("Failed to create local certs");
assert!(output.status.success());
}

fn _get_did_from_secrets(path: String) -> String {
let file = File::open(path).unwrap();
let reader = BufReader::new(file);
Expand Down
21 changes: 0 additions & 21 deletions affinidi-messaging-mediator/tests/keys/client.chain

This file was deleted.

0 comments on commit 3bcd57c

Please sign in to comment.