remove allow(dead_code) for all glory

Signed-off-by: Erik Hollensbe <git@hollensbe.org>
This commit is contained in:
Erik Hollensbe 2022-02-17 14:38:24 -08:00
parent 9b15d4e184
commit ab38851c33
No known key found for this signature in database
GPG key ID: 4BB0E241A863B389
11 changed files with 23 additions and 27 deletions

View file

@ -258,6 +258,7 @@ impl CACollector {
}
}
#[cfg(test)]
mod tests {
use openssl::{error::ErrorStack, x509::X509Req};

View file

@ -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,

View file

@ -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",

View file

@ -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")]

View file

@ -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();

View file

@ -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".

View file

@ -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")]

View file

@ -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.
//!

View file

@ -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?;

View file

@ -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<'_>,

View file

@ -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,
}