Test fixture: a store holding a human default identity (with key) and a delegated agent identity (with key).
(
dir: &Path,
)
| 909 | /// Test fixture: a store holding a human default identity (with key) |
| 910 | /// and a delegated agent identity (with key). |
| 911 | fn signer_test_store( |
| 912 | dir: &Path, |
| 913 | ) -> ( |
| 914 | atomic_identity::KeyPair, |
| 915 | atomic_identity::Identity, |
| 916 | atomic_identity::KeyPair, |
| 917 | atomic_identity::Identity, |
| 918 | ) { |
| 919 | use atomic_identity::{Identity, IdentityStore, IdentityType, KeyPair}; |
| 920 | |
| 921 | let mut store = IdentityStore::open(dir).unwrap(); |
| 922 | |
| 923 | let human_key = KeyPair::generate(); |
| 924 | let human = Identity::builder("alice") |
| 925 | .email("alice@example.com") |
| 926 | .public_key(human_key.public.clone()) |
| 927 | .build() |
| 928 | .unwrap(); |
| 929 | store.save_with_keypair(&human, &human_key, None).unwrap(); |
| 930 | store.set_default(&human.id).unwrap(); |
| 931 | |
| 932 | let agent_key = KeyPair::generate(); |
| 933 | let agent = Identity::builder("alice+claude") |
| 934 | .identity_type(IdentityType::Agent) |
| 935 | .email("alice+claude@example.com") |
| 936 | .public_key(agent_key.public.clone()) |
| 937 | .delegated_by(human.id) |
| 938 | .build() |
| 939 | .unwrap(); |
| 940 | store.save_with_keypair(&agent, &agent_key, None).unwrap(); |
| 941 | |
| 942 | (human_key, human, agent_key, agent) |
| 943 | } |
| 944 | |
| 945 | /// The whole point of the feature: a selected agent identity signs with |
| 946 | /// its OWN key, so the signature proves the header's key claim. The |