Skip to content

Commit

Permalink
Fxa fixes (#321)
Browse files Browse the repository at this point in the history
bug: Various mini-patches for FxA integration work

* Added more verbose `trace!` and `debug!` logging messages.
* ignore padding errors for VAPID keys
* bumped up default max bytes to handle base64 encoded 4096 block
* record the VapidError as an info before we send it to metrics

We can't add the key to metrics (cardinality). We can log it locally
and monitor a given server for a short period, though.
  • Loading branch information
jrconlin authored Jul 13, 2022
1 parent 3272fde commit b2b6bfd
Show file tree
Hide file tree
Showing 19 changed files with 309 additions and 73 deletions.
183 changes: 152 additions & 31 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions autoendpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ a2 = { git = "https://github.com/mozilla-services/a2.git", branch = "autoendpoin
actix-web = "3.3"
actix-rt = "1.1" # 2.0+ requires futures 0.3+
actix-cors = "0.5"
actix-http = "3.0"
again = { version = "0.1.2", default-features = false, features = ["log", "rand"] }
async-trait = "0.1"
autopush_common = { path = "../autopush-common" }
Expand Down
6 changes: 6 additions & 0 deletions autoendpoint/src/db/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ impl DbClientImpl {
router_table: String,
message_table: String,
) -> DbResult<Self> {
debug!("Tables: {} and {}", router_table, message_table);
let ddb = if let Ok(endpoint) = env::var("AWS_LOCAL_DYNAMODB") {
DynamoDbClient::new_with(
HttpClient::new().expect("TLS initialization error"),
Expand Down Expand Up @@ -205,6 +206,11 @@ impl DbClient for DbClientImpl {
}

async fn get_user(&self, uaid: Uuid) -> DbResult<Option<DynamoDbUser>> {
trace!(
"Looking up user: {:?} in {}",
uaid.as_simple().to_string(),
self.router_table.clone()
);
let input = GetItemInput {
table_name: self.router_table.clone(),
consistent_read: Some(true),
Expand Down
5 changes: 4 additions & 1 deletion autoendpoint/src/extractors/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ impl FromRequest for Notification {
// Read data
let data = web::Bytes::from_request(&req, &mut payload)
.await
.map_err(ApiErrorKind::PayloadError)?;
.map_err(|e| {
debug!("▶▶ Request read payload error: {:?}", &e);
ApiErrorKind::PayloadError(e)
})?;

// Convert data to base64
let data = if data.is_empty() {
Expand Down
7 changes: 5 additions & 2 deletions autoendpoint/src/extractors/notification_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,15 @@ mod tests {
fn valid_topic() {
let req = TestRequest::post()
.header("TTL", "10")
.header("TOPIC", "test-topic")
.header("TOPIC", "a-test-topic-which-is-just-right")
.to_http_request();
let result = NotificationHeaders::from_request(&req, false);

assert!(result.is_ok());
assert_eq!(result.unwrap().topic, Some("test-topic".to_string()));
assert_eq!(
result.unwrap().topic,
Some("a-test-topic-which-is-just-right".to_string())
);
}

/// Topic names which are too long return an error
Expand Down
Loading

0 comments on commit b2b6bfd

Please sign in to comment.