Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: add app_id to error message #303

Merged
merged 15 commits into from
May 4, 2022
3 changes: 3 additions & 0 deletions autoendpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ validator = "0.14"
validator_derive = "0.14"
yup-oauth2 = "4.1.2" # 5.0+ requires tokio 1.1+

# For mockito test debugging
# ureq={ version="2.4", features=["json"] }

[dev-dependencies]
mockall = "0.8.3" # 0.9+ requires reworking tests
mockito = "0.30.0"
Expand Down
2 changes: 1 addition & 1 deletion autoendpoint/src/extractors/routers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl FromStr for RouterType {
type Err = ();

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
match s.to_lowercase().as_str() {
"webpush" => Ok(RouterType::WebPush),
"fcm" => Ok(RouterType::FCM),
"gcm" => Ok(RouterType::GCM),
Expand Down
5 changes: 1 addition & 4 deletions autoendpoint/src/extractors/subscription.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::error::{ApiError, ApiErrorKind, ApiResult};
use crate::extractors::routers::RouterType;
use crate::extractors::token_info::{ApiVersion, TokenInfo};
use crate::extractors::user::validate_user;
use crate::headers::crypto_key::CryptoKeyHeader;
Expand Down Expand Up @@ -28,7 +27,6 @@ const ONE_DAY_IN_SECONDS: u64 = 60 * 60 * 24;
pub struct Subscription {
pub user: DynamoDbUser,
pub channel_id: Uuid,
pub router_type: RouterType,
pub vapid: Option<VapidHeaderWithKey>,
}

Expand Down Expand Up @@ -89,7 +87,7 @@ impl FromRequest for Subscription {
.get_user(uaid)
.await?
.ok_or(ApiErrorKind::NoSubscription)?;
let router_type = validate_user(&user, &channel_id, &state).await?;
validate_user(&user, &channel_id, &state).await?;

// Validate the VAPID JWT token and record the version
if let Some(vapid) = &vapid {
Expand All @@ -103,7 +101,6 @@ impl FromRequest for Subscription {
Ok(Subscription {
user,
channel_id,
router_type,
vapid,
})
}
Expand Down
2 changes: 1 addition & 1 deletion autoendpoint/src/routers/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ pub mod tests {
subscription: Subscription {
user: DynamoDbUser {
router_data: Some(router_data),
router_type: router_type.to_string(),
jrconlin marked this conversation as resolved.
Show resolved Hide resolved
..Default::default()
},
channel_id: channel_id(),
router_type,
vapid: None,
},
headers: NotificationHeaders {
Expand Down
Loading