Skip to content

Commit

Permalink
ci(https support ): add test for https support DI
Browse files Browse the repository at this point in the history
- still WIP

Signed-off-by: Sarita Mahajan <sarmahaj@redhat.com>
  • Loading branch information
sarmahaj committed Jan 18, 2024
1 parent a281209 commit baab2b4
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 1 deletion.
5 changes: 4 additions & 1 deletion integration-tests/templates/manufacturing-server.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ ownership_voucher_store_driver:
public_key_store_driver:
Directory:
path: {{ config_dir }}/keys/
bind: {{ bind }}
bind_http: {{ bind }}
bind_https: {{ bind_https }}
rendezvous_info:
- dns: localhost
device_port: 8082
Expand All @@ -33,3 +34,5 @@ manufacturing:
owner_cert_path: {{ keys_path }}/owner_cert.pem
device_cert_ca_private_key: {{ keys_path }}/device_ca_key.der
device_cert_ca_chain: {{ keys_path }}/device_ca_cert.pem
manufacturing_server_https_cert: {{ manufacturing_server_https_cert_path }}/manufacturing_server_https_cert.crt
manufacturing_server_https_key: {{ manufacturing_server_https_key_path }}/manufacturing_server_https_key.key
15 changes: 15 additions & 0 deletions integration-tests/tests/di_diun.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

mod common;
use common::{Binary, LogSide, TestContext};
use lazy_static::lazy_static;
Expand Down Expand Up @@ -25,6 +26,9 @@ async fn test_device_credentials_already_active() -> Result<()> {
cfg.insert("rendezvous_port", "1337");
cfg.insert("diun_key_type", "FileSystem");
cfg.insert("device_identification_format", "SerialNumber");
cfg.insert("manufacturing_server_https_cert_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("manufacturing_server_https_key_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("bind_https", &format!("0.0.0.0:{}","8096"));
Ok(())
})?)
},
Expand Down Expand Up @@ -109,6 +113,9 @@ async fn test_device_credentials_generated_with_mac_address() -> Result<()> {
cfg.insert("rendezvous_port", "1337");
cfg.insert("diun_key_type", "FileSystem");
cfg.insert("device_identification_format", "MACAddress");
cfg.insert("manufacturing_server_https_cert_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("manufacturing_server_https_key_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("bind_https", &format!("https://localhost:{}","8086"));

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
Ok(())
})?)
},
Expand Down Expand Up @@ -207,6 +214,10 @@ async fn test_device_credentials_with_tpm() -> Result<()> {
cfg.insert("rendezvous_port", "1337");
cfg.insert("diun_key_type", "Tpm");
cfg.insert("device_identification_format", "SerialNumber");
cfg.insert("manufacturing_server_https_cert_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("manufacturing_server_https_key_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("bind_https", &format!("https://localhost:{}","8086"));

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production

Ok(())
})?)
},
Expand Down Expand Up @@ -254,6 +265,10 @@ async fn test_device_credentials_generated_with_mac_address_no_user_given_iface(
cfg.insert("rendezvous_port", "1337");
cfg.insert("diun_key_type", "FileSystem");
cfg.insert("device_identification_format", "MACAddress");
cfg.insert("manufacturing_server_https_cert_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("manufacturing_server_https_key_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("bind_https", &format!("https://localhost:{}","8086"));

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production

Ok(())
})?)
},
Expand Down
61 changes: 61 additions & 0 deletions integration-tests/tests/di_diun_https.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
mod common;
use common::{Binary, LogSide, TestContext};
use std::env;
use std::path::Path;
use std::time::Duration;
use anyhow::{Context, Result};
const L: LogSide = LogSide::Test;
#[tokio::test]
async fn di_diun_https_test() -> Result<()> {
let mut ctx = TestContext::new().context("Error building test context")?;
let mfg_server = ctx
.start_test_server(
Binary::ManufacturingServer,
|cfg| {
Ok(cfg.prepare_config_file(None, |cfg| {
cfg.insert("rendezvous_port", "1337");
cfg.insert("diun_key_type", "FileSystem");
cfg.insert("device_identification_format", "SerialNumber");
cfg.insert("manufacturing_server_https_cert_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("manufacturing_server_https_key_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
// cfg.insert("bind_http", "8085");
cfg.insert("bind_https", &format!("0.0.0.0:{}","8086"));
Ok(())
})?)
},
|_| Ok(()),
)
.context("Error creating manufacturing server")?;
ctx.wait_until_servers_ready()
.await
.context("Error waiting for servers to start")?;
let client_result = ctx
.run_client(
Binary::ManufacturingClient,
Some(&mfg_server),
|cfg| {
cfg.env("DEVICE_CREDENTIAL_FILENAME", "devicecredential.dc")
.env("MANUFACTURING_SERVER_URL", "https://localhost:8086")
.env("DEV_ENVIRONMENT", "1")
.env("DIUN_PUB_KEY_INSECURE", "true");
Ok(())
},
Duration::from_secs(5),
)
.context("Error running manufacturing client")?;
client_result
.expect_success()
.context("Manufacturing client failed")?;
let dc_path = client_result.client_path().join("devicecredential.dc");
L.l(format!("Device Credential should be in {:?}", dc_path));
assert!(Path::new(&dc_path).exists());
Ok(())
} */
8 changes: 8 additions & 0 deletions integration-tests/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ where
cfg.insert("diun_key_type", diun_key_type);
cfg.insert("rendezvous_port", &rendezvous_server.server_port().unwrap());
cfg.insert("device_identification_format", "SerialNumber");
cfg.insert("manufacturing_server_https_cert_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("manufacturing_server_https_key_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("bind_https", &format!("0.0.0.0:{}","8086"));

Ok(())
})?)
},
Expand Down Expand Up @@ -514,6 +518,10 @@ where
cfg.insert("diun_key_type", diun_key_type);
cfg.insert("rendezvous_port", &rendezvous_server.server_port().unwrap());
cfg.insert("device_identification_format", "SerialNumber");
cfg.insert("manufacturing_server_https_cert_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("manufacturing_server_https_key_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("bind_https", &format!("0.0.0.0:{}","8086"));

Ok(())
})?)
},
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/tests/service_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ where
cfg.insert("diun_key_type", diun_key_type);
cfg.insert("rendezvous_port", &rendezvous_server.server_port().unwrap());
cfg.insert("device_identification_format", "SerialNumber");
cfg.insert("manufacturing_server_https_cert_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("manufacturing_server_https_key_path", "/workspaces/fido-device-onboard-rs/integration-tests/tests/test-data/https-test");
cfg.insert("bind_https", &format!("0.0.0.0:{}","8086"));
Ok(())
})?)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDqzCCApMCFDBq5YwvijIjOB6U4yFgJpJwHTsEMA0GCSqGSIb3DQEBCwUAMIGR
MQswCQYDVQQGEwJJRTEPMA0GA1UECAwGR2Fsd2F5MQ8wDQYDVQQHDAZHYWx3YXkx
EDAOBgNVBAoMB1JlZCBIYXQxDDAKBgNVBAsMA1I0RTEcMBoGA1UEAwwTd3d3LmZk
by5leGFtcGxlLmNvbTEiMCAGCSqGSIb3DQEJARYTc2FybWFoYWpAcmVkaGF0LmNv
bTAeFw0yMzA5MTIxMDA5MzdaFw0yNDA5MTExMDA5MzdaMIGRMQswCQYDVQQGEwJJ
RTEPMA0GA1UECAwGR2Fsd2F5MQ8wDQYDVQQHDAZHYWx3YXkxEDAOBgNVBAoMB1Jl
ZCBIYXQxDDAKBgNVBAsMA1I0RTEcMBoGA1UEAwwTd3d3LmZkby5leGFtcGxlLmNv
bTEiMCAGCSqGSIb3DQEJARYTc2FybWFoYWpAcmVkaGF0LmNvbTCCASIwDQYJKoZI
hvcNAQEBBQADggEPADCCAQoCggEBAMiKFA4zj4DZ3S85HosHND7hAapN7MSS6h+4
xdJC6xZBe4EkSNpvuj22I09bxdmdPB4KDI0mKIhzM5QTmeIj5ejGaeviuDbLuF1t
2CLbb4Dprj9uS81XattqSdRDeWa4EZRGf3iGoryb2KgdRaqT1sy5Rh2KfNa+267w
JElZ6EsBjjXojBO2yg+dW75U1oIhLtQPFUIQ78muOr8Hg6p67UHaLO6rry7R/Dhd
bphrJwLME5AaQAvpudWM7y0PrHsOzW3nmykktTSbOXBWtx2d7pZYju+DXSW9/1rV
+GV+NtoUIjUL9fEKm9mT2VuW433ZCvPrQTAcNo87VsMYk4mZyZcCAwEAATANBgkq
hkiG9w0BAQsFAAOCAQEAx0l+3iEf6SydBwWP1qVFPRC9NExym5DN14bYQivBwvNO
454WrO/lQyXuKsMrS5Uu2bURNblxs7lOIfyzIn9CHZq8DRcAfPoVl9nn90WnD72j
YIqCvOcC5VtLR5SFMIfWYgpj7/uHhEO0ykQk5oLkxkooPROOcJPDdUuZZx5hY3f9
r7zGBrPhQHT+3YJmg2aF4j7+GCGoydg+alkxLHhHfs7r+tH7bNtL28x86iqilWGs
7ciG5nZm+tM/DaI+yUtnJhN83J6914Zjm8QX/85IiaBC6rVcEfkFTkqlPXId2kHV
pmRu5tNQOqLctpmIr+M1/JQDuhkoh+MyJBfEwzG6Tw==
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDI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