Skip to content

Commit

Permalink
Allow http URLs for integration testing, bump ver (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave authored Jul 3, 2023
1 parent 5349c71 commit 17a64ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "divviup-api"
version = "0.0.11"
version = "0.0.12"
edition = "2021"
publish = false
default-run = "divviup_api_bin"
Expand Down
9 changes: 6 additions & 3 deletions src/entity/aggregator/new_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use std::str::FromStr;
use time::OffsetDateTime;
use uuid::Uuid;
use validator::{Validate, ValidationError, ValidationErrors};
use validator::{Validate, ValidationError};

use super::{ActiveModel, Role};

Expand All @@ -17,9 +17,11 @@ pub struct NewAggregator {
pub role: Option<String>,
#[validate(required, length(min = 1))]
pub name: Option<String>,
#[validate(required, custom = "https")]
#[validate(required)]
#[cfg_attr(not(feature = "integration-testing"), validate(custom = "https"))]
pub api_url: Option<String>,
#[validate(required, custom = "https")]
#[validate(required)]
#[cfg_attr(not(feature = "integration-testing"), validate(custom = "https"))]
pub dap_url: Option<String>,
#[validate(required, custom = "base64", length(min = 8))]
pub bearer_token: Option<String>,
Expand All @@ -35,6 +37,7 @@ fn validate_role(role: &str) -> Result<(), ValidationError> {
.map(|_| ())
}

#[cfg_attr(feature = "integration-testing", allow(dead_code))]
fn https(url: &str) -> Result<(), ValidationError> {
let url = url::Url::from_str(url).map_err(|_| ValidationError::new("https-url"))?;
if url.scheme() != "https" {
Expand Down

0 comments on commit 17a64ec

Please sign in to comment.