Skip to content

Commit

Permalink
Add info field to Outcome::Success.
Browse files Browse the repository at this point in the history
This streamlines the implementation, allowing the backend to pass
information to the frontend through the receipt of the status.
  • Loading branch information
cobward committed Aug 14, 2024
1 parent 6da02a8 commit 7f909f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/verifier/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{collections::BTreeMap, fmt::Debug, sync::Arc};

use anyhow::{bail, Error, Ok, Result};
use async_trait::async_trait;
use serde_json::Value as Json;
use tokio::sync::Mutex;
use uuid::Uuid;

Expand Down Expand Up @@ -38,7 +39,7 @@ pub enum Outcome {
/// The authorization response did not pass verification.
Failure { reason: String },
/// The authorization response is verified.
Success,
Success { info: Json },
}

/// Storage interface for session information.
Expand Down Expand Up @@ -111,7 +112,7 @@ impl Outcome {
match self {
Outcome::Error { .. } => 0,
Outcome::Failure { .. } => 1,
Outcome::Success => 2,
Outcome::Success { .. } => 2,
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,8 @@ async fn w3c_vc_did_client_direct_post() {
assert_eq!(None, redirect);

let status = verifier.poll_status(id).await.unwrap();
assert_eq!(Status::Complete(Outcome::Success), status);
match status {
Status::Complete(Outcome::Success { .. }) => (),
_ => panic!("unexpected status: {status:?}"),
}
}
8 changes: 7 additions & 1 deletion tests/jwt_vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ impl AsyncHttpClient for MockHttpClient {
id.parse().context("failed to parse id")?,
AuthorizationResponse::from_x_www_form_urlencoded(body)
.context("failed to parse authorization response request")?,
|_, _| Box::pin(async { Outcome::Success }),
|_, _| {
Box::pin(async {
Outcome::Success {
info: serde_json::Value::Null,
}
})
},
)
.await?;

Expand Down

0 comments on commit 7f909f8

Please sign in to comment.