mirror of
https://github.com/zerotier/coyote.git
synced 2024-11-25 12:37:02 +00:00
remove allow(dead_code) for all glory
Signed-off-by: Erik Hollensbe <git@hollensbe.org>
This commit is contained in:
parent
9b15d4e184
commit
ab38851c33
11 changed files with 23 additions and 27 deletions
|
@ -258,6 +258,7 @@ impl CACollector {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use openssl::{error::ErrorStack, x509::X509Req};
|
||||
|
||||
|
|
|
@ -103,10 +103,6 @@ impl NewAccount {
|
|||
self.contact.clone()
|
||||
}
|
||||
|
||||
pub fn is_deleted(&self) -> bool {
|
||||
self.contact.is_none() || self.contact.as_ref().unwrap().is_empty()
|
||||
}
|
||||
|
||||
pub fn to_account(&self) -> Account {
|
||||
Account {
|
||||
status: AccountStatus::Valid,
|
||||
|
|
|
@ -27,7 +27,8 @@ pub(crate) mod directory;
|
|||
pub(crate) mod nonce;
|
||||
pub(crate) mod order;
|
||||
|
||||
pub(crate) const REPLAY_NONCE_HEADER: &str = "Replay-Nonce";
|
||||
const REPLAY_NONCE_HEADER: &str = "Replay-Nonce";
|
||||
const ACME_CONTENT_TYPE: &str = "application/jose+json";
|
||||
|
||||
/// ServiceState is the carried state globally for the application. It contains many items the
|
||||
/// handlers need to function.
|
||||
|
@ -77,7 +78,7 @@ impl HandlerState {
|
|||
}
|
||||
|
||||
Ok(builder
|
||||
.header("content-type", "application/json")
|
||||
.header("content-type", ACME_CONTENT_TYPE)
|
||||
.header(REPLAY_NONCE_HEADER, self.clone().nonce.unwrap())
|
||||
.header(
|
||||
"Link",
|
||||
|
|
|
@ -18,10 +18,6 @@ use crate::{
|
|||
|
||||
use super::{uri_to_url, HandlerState, ServiceState};
|
||||
|
||||
pub struct OrdersList {
|
||||
orders: Vec<Url>,
|
||||
}
|
||||
|
||||
/// RFC8555 7.1.3. Detailed read.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
|
@ -290,6 +290,7 @@ impl JWK {
|
|||
|
||||
/// from_jws transforms a JSON web signature into a JWK. It uses the ACME-derived `alg` field
|
||||
/// from the protected header to determine what crypto to use.
|
||||
#[allow(dead_code)]
|
||||
fn from_jws(jws: &mut JWS) -> Result<Self, JWSError> {
|
||||
let mut aph = jws.protected()?;
|
||||
let alg = aph.alg.clone();
|
||||
|
|
|
@ -29,9 +29,6 @@ use crate::{
|
|||
|
||||
use self::dns::DNSName;
|
||||
|
||||
const DEFAULT_NONCE_SIZE: usize = 16;
|
||||
const ACME_CONTENT_TYPE: &str = "application/jose+json";
|
||||
|
||||
lazy_static! {
|
||||
/// List of supported algorithms, with the ACME preferred one first; in our case this is
|
||||
/// "ES256".
|
||||
|
|
|
@ -169,7 +169,7 @@ const ACME_URN_NAMESPACE: &str = "urn:ietf:params:acme:error:";
|
|||
|
||||
/// RFCError is for reporting errors conformant to the ACME RFC. These are used in the `type` field
|
||||
/// of the "problem details" document returned to ACME clients.
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Deserialize)]
|
||||
pub enum RFCError {
|
||||
AccountDoesNotExist,
|
||||
AlreadyRevoked,
|
||||
|
@ -199,7 +199,16 @@ pub enum RFCError {
|
|||
|
||||
impl RFCError {
|
||||
/// to_string converts an enum error into the string you should return to the client.
|
||||
fn to_string(self) -> String {
|
||||
fn serde_serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
s.serialize_str(&self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for RFCError {
|
||||
fn to_string(&self) -> String {
|
||||
ACME_URN_NAMESPACE.to_string()
|
||||
+ match self {
|
||||
RFCError::AccountDoesNotExist => "accountDoesNotExist",
|
||||
|
@ -247,7 +256,7 @@ pub enum ValidationError {
|
|||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Error {
|
||||
/// the type of error we have experienced.
|
||||
#[serde(rename = "type")]
|
||||
#[serde(rename = "type", serialize_with = "RFCError::serde_serialize")]
|
||||
error_type: RFCError,
|
||||
/// subproblems, if any, will be here.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#![allow(dead_code)]
|
||||
//! Coyote lets you make ACME servers, which are not guaranteed to not explode in
|
||||
//! your face. You have to code that out yourself.
|
||||
//!
|
||||
|
|
|
@ -78,6 +78,7 @@ impl Postgres {
|
|||
|
||||
/// resets the database, destroying all data in the public schema.
|
||||
/// useful for tests.
|
||||
#[cfg(test)]
|
||||
pub(crate) async fn reset(&self) -> Result<(), SaveError> {
|
||||
let c = Self::connect_one(&self.config).await?;
|
||||
c.execute("drop schema public cascade", &[]).await?;
|
||||
|
|
|
@ -149,6 +149,8 @@ impl Order {
|
|||
Ok(o)
|
||||
}
|
||||
|
||||
// FIXME this is only used in tests rn
|
||||
#[cfg(test)]
|
||||
pub(crate) async fn challenges(
|
||||
&self,
|
||||
tx: &Transaction<'_>,
|
||||
|
|
|
@ -38,8 +38,6 @@ fn is_debug() -> bool {
|
|||
!std::env::var(DEBUG_VAR).unwrap_or_default().is_empty()
|
||||
}
|
||||
|
||||
pub(crate) const DEFAULT_CONTACT: &str = "erik@hollensbe.org";
|
||||
|
||||
impl From<MigrationError> for eggshell::Error {
|
||||
fn from(me: MigrationError) -> Self {
|
||||
Self::Generic(me.to_string())
|
||||
|
@ -53,7 +51,7 @@ pub struct PGTest {
|
|||
docker: Arc<Mutex<Docker>>,
|
||||
// NOTE: the only reason we keep this is to ensure it lives the same lifetime as the PGTest
|
||||
// struct; otherwise the temporary directory is removed prematurely.
|
||||
temp: Arc<Mutex<TempDir>>,
|
||||
_temp: Arc<Mutex<TempDir>>,
|
||||
}
|
||||
|
||||
fn pull_images(images: Vec<&str>) -> () {
|
||||
|
@ -189,7 +187,7 @@ impl PGTest {
|
|||
docker,
|
||||
gs: Arc::new(Mutex::new(gs)),
|
||||
postgres,
|
||||
temp: Arc::new(Mutex::new(temp)),
|
||||
_temp: Arc::new(Mutex::new(temp)),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -200,11 +198,8 @@ impl PGTest {
|
|||
pub fn eggshell(self) -> Arc<Mutex<EggShell>> {
|
||||
self.gs
|
||||
}
|
||||
|
||||
pub fn docker(&self) -> Arc<Mutex<Docker>> {
|
||||
self.docker.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Error)]
|
||||
pub(crate) enum ContainerError {
|
||||
#[error("Unknown error encountered: {0}")]
|
||||
|
@ -228,7 +223,6 @@ fn short_hash(s: String) -> String {
|
|||
#[derive(Clone)]
|
||||
pub(crate) struct TestService {
|
||||
pub pg: Box<PGTest>,
|
||||
pub nonce: PostgresNonceValidator,
|
||||
pub app: ratpack::app::TestApp<ServiceState, HandlerState>,
|
||||
pub url: String,
|
||||
}
|
||||
|
@ -279,7 +273,6 @@ impl TestService {
|
|||
|
||||
Self {
|
||||
pg: Box::new(pg),
|
||||
nonce: validator,
|
||||
app: TestApp::new(app),
|
||||
url,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue