Skip to content

Commit

Permalink
Merge pull request #105 from lumeohq/dmitry/fix-url-comparison
Browse files Browse the repository at this point in the history
Fix URL comparison
  • Loading branch information
DmitrySamoylov authored Feb 21, 2023
2 parents 4babeea + 31e55f6 commit a49b43d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/git.yml

This file was deleted.

18 changes: 9 additions & 9 deletions onvif/examples/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,25 @@ impl Clients {
};
let services =
schema::devicemgmt::get_services(&out.devicemgmt, &Default::default()).await?;
for s in &services.service {
let url = Url::parse(&s.x_addr).map_err(|e| e.to_string())?;
if !url.as_str().starts_with(base_uri.as_str()) {
for service in &services.service {
let service_url = Url::parse(&service.x_addr).map_err(|e| e.to_string())?;
if !service_url.as_str().starts_with(base_uri.as_str()) {
return Err(format!(
"Service URI {} is not within base URI {}",
&s.x_addr, &base_uri
service_url, base_uri
));
}
let svc = Some(
soap::client::ClientBuilder::new(&url)
soap::client::ClientBuilder::new(&service_url)
.credentials(creds.clone())
.build(),
);
match s.namespace.as_str() {
match service.namespace.as_str() {
"http://www.onvif.org/ver10/device/wsdl" => {
if s.x_addr != devicemgmt_uri.as_str() {
if service_url != devicemgmt_uri {
return Err(format!(
"advertised device mgmt uri {} not expected {}",
&s.x_addr, &devicemgmt_uri
service_url, devicemgmt_uri
));
}
}
Expand All @@ -135,7 +135,7 @@ impl Clients {
"http://www.onvif.org/ver20/imaging/wsdl" => out.imaging = svc,
"http://www.onvif.org/ver20/ptz/wsdl" => out.ptz = svc,
"http://www.onvif.org/ver20/analytics/wsdl" => out.analytics = svc,
_ => debug!("unknown service: {:?}", s),
_ => debug!("unknown service: {:?}", service),
}
}
Ok(out)
Expand Down
4 changes: 2 additions & 2 deletions onvif/src/soap/auth/username_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl UsernameToken {
UsernameToken {
username: username.to_string(),
nonce: base64::encode(&nonce),
digest: base64::encode(&digest),
digest: base64::encode(digest),
created,
}
}
Expand Down Expand Up @@ -66,7 +66,7 @@ fn ws_username_token_example() {
};

assert_eq!(
base64::encode(&digest),
base64::encode(digest),
"tuOSpGlFlIXsozq4HFNeeGeFLEI=".to_string()
)
}
4 changes: 2 additions & 2 deletions onvif/src/soap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum Error {
EnvelopeNotFound,
BodyNotFound,
BodyIsEmpty,
Fault(soap_envelope::Fault),
Fault(Box<soap_envelope::Fault>),
InternalError(String),
}

Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn unsoap(xml: &str) -> Result<String, Error> {

if let Some(fault) = body.get_child("Fault") {
let fault = deserialize_fault(fault)?;
return Err(Error::Fault(fault));
return Err(Error::Fault(Box::new(fault)));
}

body.children
Expand Down

0 comments on commit a49b43d

Please sign in to comment.