Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikrothenberger committed Jul 4, 2024
1 parent b3c6fc1 commit 9f32056
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions demos/vc_issuer/tests/issue_credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ mod api {
.map(|(x,)| x)
}

pub fn set_alternative_origins(
env: &StateMachine,
canister_id: CanisterId,
alternative_origins: &str,
) -> Result<(), CallError> {
call_candid(
env,
canister_id,
"set_alternative_origins",
(alternative_origins,),
)
}

pub fn add_employee(
env: &StateMachine,
canister_id: CanisterId,
Expand Down Expand Up @@ -732,6 +745,25 @@ fn should_fail_configure_if_not_controller() {
assert_matches!(result, Err(e) if format!("{:?}", e).contains("Only a controller can call configure"));
}

#[test]
fn should_set_alternative_origins() {
let env = env();
let issuer_id = install_canister(&env, VC_ISSUER_WASM.clone());
let alternative_origins = r#"{"alternativeOrigins":["https://test.issuer"]}"#;
api::set_alternative_origins(&env, issuer_id, alternative_origins).expect("API call failed");

let request = HttpRequest {
method: "GET".to_string(),
url: "/.well-known/ii-alternative-origins".to_string(),
headers: vec![],
body: ByteBuf::new(),
certificate_version: Some(2),
};
let http_response = http_request(&env, issuer_id, &request)?;
assert_eq!(http_response.status_code, 200);
assert_eq!(&http_response.body, alternative_origins.as_bytes())
}

/// Verifies that the expected assets is delivered and certified.
#[test]
fn issuer_canister_serves_http_assets() -> Result<(), CallError> {
Expand Down

0 comments on commit 9f32056

Please sign in to comment.