Skip to content
This repository has been archived by the owner on Jul 31, 2019. It is now read-only.

Commit

Permalink
EN-876 - expose connection invite URL in connection object (#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
glowkey authored and hadleym committed Oct 31, 2018
1 parent 6687cce commit 5d7f071
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions vcx/libvcx/src/connection.rs
Expand Up @@ -47,6 +47,7 @@ struct Connection {
endpoint: String,
// For QR code invitation
invite_detail: Option<InviteDetail>,
invite_url: Option<String>,
agent_did: String,
agent_vk: String,
their_pw_did: String,
Expand Down Expand Up @@ -103,6 +104,7 @@ impl Connection {
return Err(ConnectionError::GeneralConnectionError())
},
};
self.invite_url = Some(response[1].clone());
Ok(error::SUCCESS.code_num)
}
}
Expand Down Expand Up @@ -406,6 +408,7 @@ fn create_connection(source_id: &str) -> Result<u32, ConnectionError> {
uuid: String::new(),
endpoint: String::new(),
invite_detail: None,
invite_url: None,
agent_did: String::new(),
agent_vk: String::new(),
their_pw_did: String::new(),
Expand Down Expand Up @@ -868,6 +871,7 @@ pub mod tests {
uuid: String::new(),
endpoint: String::new(),
invite_detail: Some(InviteDetail::new()),
invite_url: None,
agent_did: "8XFh8yBzrpJQmNyZzgoTqB".to_string(),
agent_vk: "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A".to_string(),
their_pw_did: String::new(),
Expand Down Expand Up @@ -951,6 +955,7 @@ pub mod tests {
uuid: String::new(),
endpoint: String::new(),
invite_detail: None,
invite_url: None,
agent_did: "8XFh8yBzrpJQmNyZzgoTqB".to_string(),
agent_vk: "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A".to_string(),
their_pw_did: String::new(),
Expand Down Expand Up @@ -1101,6 +1106,7 @@ pub mod tests {
uuid: String::new(),
endpoint: String::new(),
invite_detail: None,
invite_url: None,
agent_did: "8XFh8yBzrpJQmNyZzgoTqB".to_string(),
agent_vk: "EkVTa7SCJ5SntpYyX7CSb2pcBhiVGT9kWSagA8a9T69A".to_string(),
their_pw_did: String::new(),
Expand Down
2 changes: 1 addition & 1 deletion vcx/libvcx/src/lib.rs
Expand Up @@ -76,7 +76,7 @@ mod tests {
#[cfg(feature = "sovtoken")]
#[test]
fn test_real_proof() {
let number_of_attributes = 50;
let number_of_attributes = 10;
init!("agency");
let institution_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap();
let (faber, alice) = ::connection::tests::create_connected_connections();
Expand Down
12 changes: 7 additions & 5 deletions vcx/libvcx/src/messages/invite.rs
Expand Up @@ -236,8 +236,9 @@ impl SendInvite{
match httpclient::post_u8(&data) {
Err(_) => return Err(error::POST_MSG_FAILURE.code_num),
Ok(response) => {
let response = parse_response(response)?;
result.push(response);
let (invite, url) = parse_response(response)?;
result.push(invite);
result.push(url);
},
};

Expand Down Expand Up @@ -419,7 +420,7 @@ impl GeneralMessage for AcceptInvite{
}
}

fn parse_response(response: Vec<u8>) -> Result<String, u32> {
fn parse_response(response: Vec<u8>) -> Result<(String, String), u32> {
let data = unbundle_from_agency(response)?;

if data.len() != 3 {
Expand All @@ -438,7 +439,7 @@ fn parse_response(response: Vec<u8>) -> Result<String, u32> {

debug!("Invite Details: {:?}", response.invite_detail);
match serde_json::to_string(&response.invite_detail) {
Ok(x) => Ok(x),
Ok(x) => Ok((x, response.url_to_invite_detail)),
Err(_) => Err(error::INVALID_JSON.code_num),
}
}
Expand Down Expand Up @@ -513,9 +514,10 @@ mod tests {
#[test]
fn test_parse_send_invite_response() {
init!("indy");
let result = parse_response(SEND_INVITE_RESPONSE.to_vec()).unwrap();
let (result, url) = parse_response(SEND_INVITE_RESPONSE.to_vec()).unwrap();

assert_eq!(result, INVITE_DETAIL_STRING);
assert_eq!(url, "http://localhost:9001/agency/invite/WRUzXXuFVTYkT8CjSZpFvT?uid=NjcwOWU");
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions vcx/libvcx/src/utils/devsetup.rs
Expand Up @@ -86,11 +86,11 @@ pub mod tests {
*/

/* sandbox */
pub const AGENCY_ENDPOINT: &'static str = "https://agency-ea-sandbox.evernym.com";
pub const AGENCY_ENDPOINT: &'static str = "http://sbx-eas.pdev.evernym.com";
pub const AGENCY_DID: &'static str = "HB7qFQyFxx4ptjKqioEtd8";
pub const AGENCY_VERKEY: &'static str = "9pJkfHyfJMZjUjS7EZ2q2HX55CbFQPKpQ9eTjSAUMLU8";

pub const C_AGENCY_ENDPOINT: &'static str = "https://agency-sandbox.evernym.com";
pub const C_AGENCY_ENDPOINT: &'static str = "http://sbx-agency.pdev.evernym.com";
pub const C_AGENCY_DID: &'static str = "Nv9oqGX57gy15kPSJzo2i4";
pub const C_AGENCY_VERKEY: &'static str = "CwpcjCc6MtVNdQgwoonNMFoR6dhzmRXHHaUCRSrjh8gj";

Expand Down

0 comments on commit 5d7f071

Please sign in to comment.