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

Add info field to Outcome::Success #10

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading