Skip to content

Commit

Permalink
refactor(rust): identity show command to use rpc abstraction and to s…
Browse files Browse the repository at this point in the history
…top mapping errors manually
  • Loading branch information
divyank-aggarwal authored and adrianbenavides committed Oct 17, 2022
1 parent 324d941 commit 7ed21e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ impl<'a> CreateIdentityResponse<'a> {
}
}

#[derive(Debug, Clone, Decode, Encode,Serialize)]
#[derive(Debug, Clone, Decode, Encode, Serialize)]
#[rustfmt::skip]
#[cbor(map)]
pub struct LongIdentityResponse<'a> {
#[cfg(feature = "tag")]
#[serde(skip)]
#[n(0)] tag: TypeTag<7961643>,
#[b(1)] pub identity: CowBytes<'a>,
}
Expand All @@ -46,11 +47,12 @@ impl<'a> LongIdentityResponse<'a> {
}
}

#[derive(Debug, Clone, Decode, Encode,Serialize)]
#[derive(Debug, Clone, Decode, Encode, Serialize)]
#[rustfmt::skip]
#[cbor(map)]
pub struct ShortIdentityResponse<'a> {
#[cfg(feature = "tag")]
#[serde(skip)]
#[n(0)] tag: TypeTag<5773131>,
#[b(1)] pub identity_id: Cow<'a, str>,
}
Expand Down
20 changes: 0 additions & 20 deletions implementations/rust/ockam/ockam_command/src/util/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ pub(crate) fn delete_tcp_connection(
Ok(buf)
}

/// Construct a request to export Identity
#[allow(unused)]
pub(crate) fn long_identity() -> Result<Vec<u8>> {
let mut buf = vec![];
Request::post("/node/identity/actions/show/long").encode(&mut buf)?;
Ok(buf)
}

/// Construct a request to print Identity Id
pub(crate) fn short_identity() -> RequestBuilder<'static, ()> {
Request::post("/node/identity/actions/show/short")
Expand Down Expand Up @@ -395,18 +387,6 @@ pub(crate) fn parse_transport_status(
))
}

#[allow(unused)]
pub(crate) fn parse_long_identity_response(
resp: &[u8],
) -> Result<(Response, models::identity::LongIdentityResponse<'_>)> {
let mut dec = Decoder::new(resp);
let response = dec.decode::<Response>()?;
Ok((
response,
dec.decode::<models::identity::LongIdentityResponse>()?,
))
}

pub(crate) fn parse_short_identity_response(
resp: &[u8],
) -> Result<(Response, models::identity::ShortIdentityResponse<'_>)> {
Expand Down
9 changes: 9 additions & 0 deletions implementations/rust/ockam/ockam_command/tests/commands.bats
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ teardown() {
assert_success
}

@test "create a node and show its identity" {
run $OCKAM node create n1
assert_success

run $OCKAM identity show --node n1
assert_success
assert_output --regexp '^P'
}

@test "create a node with a name and do show on it" {
run $OCKAM node create n1
assert_success
Expand Down

0 comments on commit 7ed21e2

Please sign in to comment.