Skip to content

Commit

Permalink
fix(DiscoveryBuilder): hide the URL details. (#21)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnaud de Grandmaison <arnaud.degrandmaison@arm.com>
  • Loading branch information
Arnaud-de-Grandmaison-ARM authored Dec 18, 2024
1 parent b5a7614 commit 8c98e95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
4 changes: 1 addition & 3 deletions examples/challenge_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ fn my_evidence_builder(nonce: &[u8], accept: &[String]) -> Result<(Vec<u8>, Stri
fn main() {
let base_url = "https://localhost:8080";

let discovery_api_endpoint = format!("{}{}", base_url, "/.well-known/veraison/verification");

let discovery = DiscoveryBuilder::new()
.with_url(discovery_api_endpoint)
.with_base_url(base_url.into())
.with_root_certificate("veraison-root.crt".into())
.build()
.expect("Failed to start API discovery with the service");
Expand Down
21 changes: 10 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,15 @@ impl DiscoveryBuilder {
}
}

/// Use this method to supply the URL of the discovery endpoint, e.g.:
/// "https://veraison.example/.well-known/veraison/verification"
pub fn with_url(mut self, v: String) -> DiscoveryBuilder {
self.url = Some(v);
/// Use this method to supply the base URL of the discovery endpoint, e.g.
/// "https://veraison.example" in the full
/// "https://veraison.example/.well-known/veraison/verification".
/// This hides / encapsulate the details of what the actual URL looks like.
pub fn with_base_url(mut self, base_url: String) -> DiscoveryBuilder {
self.url = Some(format!(
"{}{}",
base_url, "/.well-known/veraison/verification"
));
self
}

Expand Down Expand Up @@ -710,14 +715,8 @@ mod tests {
.mount(&mock_server)
.await;

let discovery_api_endpoint = format!(
"{}{}",
mock_server.uri(),
"/.well-known/veraison/verification"
);

let discovery = DiscoveryBuilder::new()
.with_url(discovery_api_endpoint)
.with_base_url(mock_server.uri())
.build()
.expect("Failed to create Discovery client.");

Expand Down

0 comments on commit 8c98e95

Please sign in to comment.