Skip to content

Commit

Permalink
Resolve BOUN-557 "Increase cert issuance test cov"
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Cammer authored and raymondk committed Jan 26, 2023
1 parent 397813a commit 5d25c73
Show file tree
Hide file tree
Showing 23 changed files with 742 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ user.bazelrc
# Intellij
.idea
.clwb

# OS X
.DS_Store
71 changes: 38 additions & 33 deletions rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")

package(default_visibility = ["//visibility:public"])

Expand All @@ -18,6 +18,7 @@ DEPENDENCIES = [
"@crate_index//:ic-agent",
"@crate_index//:ic-utils",
"@crate_index//:instant-acme",
"@crate_index//:mockall",
"@crate_index//:opentelemetry_0_18_0",
"@crate_index//:opentelemetry_prometheus_0_11_0",
"@crate_index//:pem",
Expand Down Expand Up @@ -46,3 +47,10 @@ rust_binary(
version = "0.1.0",
deps = DEPENDENCIES,
)

rust_test(
name = "certificate_issuer_test",
crate = ":certificate-issuer",
proc_macro_deps = MACRO_DEPENDENCIES,
deps = DEPENDENCIES,
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ anyhow = "1.0.66"
async-trait = "0.1.58"
axum = { version = "0.6.1", features = ["json"] }
candid = "0.8.4"
cfg-if = "1.0.0"
chacha20poly1305 = "0.10.0"
chrono = { version = "0.4.19", default-features = false, features = ["clock"] }
clap = { version = "4.0.18", features = ["derive"] }
Expand All @@ -22,6 +23,7 @@ hyper-rustls = "0.23.0"
ic-agent = "0.22.0"
ic-utils = { version = "0.22.0", features = ["raw"] }
instant-acme = "0.1.0"
mockall = "0.11.3"
opentelemetry = "0.18.0"
opentelemetry-prometheus = "0.11.0"
pem = "1.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ use async_trait::async_trait;
use instant_acme::{
Account, Authorization, Challenge, ChallengeType, Identifier, NewOrder, OrderStatus,
};
use mockall::automock;
use rcgen::{Certificate, CertificateParams, DistinguishedName};

#[automock]
#[async_trait]
pub trait Order: Sync + Send {
async fn order(&self, name: &str) -> Result<String, Error>;
}

#[automock]
#[async_trait]
pub trait Ready: Sync + Send {
async fn ready(&self, name: &str) -> Result<(), Error>;
}

#[automock]
#[async_trait]
pub trait Finalize: Sync + Send {
async fn finalize(&self, name: &str) -> Result<(String, String), Error>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ use futures::{stream, StreamExt, TryStreamExt};
use garcon::Delay;
use ic_agent::Agent;
use ifc::EncryptedPair;
use mockall::automock;
use serde::Serialize;

use crate::encode::{Decode, Encode};

#[derive(Serialize)]
#[derive(Debug, PartialEq, Serialize)]
pub struct Pair(
pub Vec<u8>, // Private Key
pub Vec<u8>, // Certificate Chain
Expand All @@ -26,6 +27,7 @@ pub enum UploadError {
UnexpectedError(#[from] anyhow::Error),
}

#[automock]
#[async_trait]
pub trait Upload: Sync + Send {
async fn upload(&self, id: &str, pair: Pair) -> Result<(), UploadError>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ use anyhow::anyhow;
use async_trait::async_trait;
use candid::Principal;
use ic_agent::Agent;
use std::sync::Arc;
use trust_dns_resolver::{error::ResolveErrorKind, proto::rr::RecordType};

use ic_utils::{
call::SyncCall,
interfaces::http_request::{HttpRequestCanister, HttpResponse},
};
use std::sync::Arc;
use trust_dns_resolver::{error::ResolveErrorKind, proto::rr::RecordType};

use crate::dns::Resolve;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use anyhow::Error;
use async_trait::async_trait;
use mockall::automock;
use trust_dns_resolver::{
error::ResolveError, lookup::Lookup, proto::rr::RecordType, TokioAsyncResolver,
};

#[automock]
#[async_trait]
pub trait Resolve: Sync + Send {
async fn lookup(&self, name: &str, record_type: RecordType) -> Result<Lookup, ResolveError>;
Expand All @@ -24,11 +26,13 @@ pub enum Record {
Txt(String),
}

#[automock]
#[async_trait]
pub trait Create: Sync + Send {
async fn create(&self, zone: &str, name: &str, record: Record) -> Result<(), Error>;
}

#[automock]
#[async_trait]
pub trait Delete: Sync + Send {
async fn delete(&self, zone: &str, name: &str) -> Result<(), Error>;
Expand Down
Loading

0 comments on commit 5d25c73

Please sign in to comment.