-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add invite_shamir_recovery_reveal command
- Loading branch information
Showing
11 changed files
with
288 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
libparsec/crates/protocol/schema/invited_cmds/invite_shamir_recovery_reveal.json5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
{ | ||
"major_versions": [ | ||
4 | ||
], | ||
"req": { | ||
"cmd": "invite_shamir_recovery_reveal", | ||
"fields": [ | ||
{ | ||
"name": "reveal_token", | ||
"type": "InvitationToken" | ||
} | ||
] | ||
}, | ||
"reps": [ | ||
{ | ||
"status": "ok", | ||
"fields": [ | ||
{ | ||
"name": "ciphered_data", | ||
"type": "Bytes" | ||
} | ||
] | ||
}, | ||
{ | ||
"status": "not_found" | ||
} | ||
] | ||
} | ||
] |
55 changes: 55 additions & 0 deletions
55
libparsec/crates/protocol/tests/invited_cmds/v4/invite_shamir_recovery_reveal.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
#![allow(clippy::unwrap_used)] | ||
|
||
use super::invited_cmds; | ||
use libparsec_tests_lite::{hex, p_assert_eq}; | ||
use libparsec_types::InvitationToken; | ||
|
||
pub fn rep_not_found() { | ||
// Generated from Parsec 3.2.1-a.0+dev | ||
// Content: | ||
// status: 'not_found' | ||
let raw: &[u8] = hex!("81a6737461747573a96e6f745f666f756e64").as_ref(); | ||
|
||
let expected = invited_cmds::invite_shamir_recovery_reveal::Rep::NotFound; | ||
println!("***expected: {:?}", expected.dump().unwrap()); | ||
let data = invited_cmds::invite_shamir_recovery_reveal::Rep::load(raw).unwrap(); | ||
p_assert_eq!(data, expected); | ||
} | ||
|
||
pub fn rep_ok() { | ||
// Generated from Parsec 3.2.1-a.0+dev | ||
// Content: | ||
// status: 'ok' | ||
// ciphered_data: 0x6369706865726564 | ||
let raw: &[u8] = | ||
hex!("82a6737461747573a26f6bad63697068657265645f64617461c4086369706865726564").as_ref(); | ||
|
||
let expected = invited_cmds::invite_shamir_recovery_reveal::InviteShamirRecoveryRevealRep::Ok { | ||
ciphered_data: "ciphered".into(), | ||
}; | ||
println!("***expected: {:?}", expected.dump().unwrap()); | ||
let data = invited_cmds::invite_shamir_recovery_reveal::Rep::load(raw).unwrap(); | ||
p_assert_eq!(data, expected); | ||
} | ||
pub fn req() { | ||
// Generated from Parsec 3.2.1-a.0+dev | ||
// Content: | ||
// cmd: 'invite_shamir_recovery_reveal' | ||
// reveal_token: 0xd864b93ded264aae9ae583fd3d40c45a | ||
let raw: &[u8] = hex!( | ||
"82a3636d64bd696e766974655f7368616d69725f7265636f766572795f72657665616c" | ||
"ac72657665616c5f746f6b656ec410d864b93ded264aae9ae583fd3d40c45a" | ||
) | ||
.as_ref(); | ||
|
||
let req = invited_cmds::invite_shamir_recovery_reveal::InviteShamirRecoveryRevealReq { | ||
reveal_token: InvitationToken::from_hex("d864b93ded264aae9ae583fd3d40c45a").unwrap(), | ||
}; | ||
println!("***expected: {:?}", req.dump().unwrap()); | ||
|
||
let expected = invited_cmds::AnyCmdReq::InviteShamirRecoveryReveal(req); | ||
|
||
let data = invited_cmds::AnyCmdReq::load(raw).unwrap(); | ||
p_assert_eq!(data, expected); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
server/parsec/_parsec_pyi/protocol/invited_cmds/v4/invite_shamir_recovery_reveal.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
# /!\ Autogenerated by misc/gen_protocol_typings.py, any modification will be lost ! | ||
|
||
from __future__ import annotations | ||
|
||
from parsec._parsec import InvitationToken | ||
|
||
class Req: | ||
def __init__(self, reveal_token: InvitationToken) -> None: ... | ||
def dump(self) -> bytes: ... | ||
@property | ||
def reveal_token(self) -> InvitationToken: ... | ||
|
||
class Rep: | ||
@staticmethod | ||
def load(raw: bytes) -> Rep: ... | ||
def dump(self) -> bytes: ... | ||
|
||
class RepUnknownStatus(Rep): | ||
def __init__(self, status: str, reason: str | None) -> None: ... | ||
@property | ||
def status(self) -> str: ... | ||
@property | ||
def reason(self) -> str | None: ... | ||
|
||
class RepOk(Rep): | ||
def __init__(self, ciphered_data: bytes) -> None: ... | ||
@property | ||
def ciphered_data(self) -> bytes: ... | ||
|
||
class RepNotFound(Rep): | ||
def __init__( | ||
self, | ||
) -> None: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
server/tests/api_v4/invited/test_invite_shamir_recovery_reveal.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
|
||
from parsec._parsec import InvitationToken, invited_cmds | ||
from tests.common import CoolorgRpcClients, HttpCommonErrorsTester, ShamirOrgRpcClients | ||
|
||
|
||
async def test_invited_invite_shamir_recovery_reveal_ok(shamirorg: ShamirOrgRpcClients) -> None: | ||
token = shamirorg.alice_shamir_reveal_token | ||
ciphered_data = shamirorg.alice_shamir_ciphered_data | ||
rep = await shamirorg.shamir_invited_alice.invite_shamir_recovery_reveal(reveal_token=token) | ||
assert rep == invited_cmds.v4.invite_shamir_recovery_reveal.RepOk(ciphered_data=ciphered_data) | ||
|
||
|
||
async def test_invited_invite_shamir_recovery_reveal_not_found( | ||
shamirorg: ShamirOrgRpcClients, | ||
) -> None: | ||
token = InvitationToken.new() | ||
rep = await shamirorg.shamir_invited_alice.invite_shamir_recovery_reveal(token) | ||
assert rep == invited_cmds.v4.invite_shamir_recovery_reveal.RepNotFound() | ||
|
||
|
||
async def test_invited_invite_shamir_recovery_reveal_http_common_errors( | ||
coolorg: CoolorgRpcClients, invited_http_common_errors_tester: HttpCommonErrorsTester | ||
) -> None: | ||
token = InvitationToken.new() | ||
|
||
async def do(): | ||
await coolorg.invited_alice_dev3.invite_shamir_recovery_reveal(reveal_token=token) | ||
|
||
await invited_http_common_errors_tester(do) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters