HomePhabricator
Diffusion Comm 57d2efb99127

[native] Expose SecureStore to Rust

Description

[native] Expose SecureStore to Rust

Summary:
ENG-5700

Get access to Secure Store from Rust using the previously introduced promises.

Depends on D9923

Test Plan:
Run this code at the beginning of create_backup function:

println!(
  "{:?}\n{:?}\n{:?}\n{:?}\n",
  // Value that doesn't exist
  secure_store_get("non_existant"),
  // Value that does exist
  secure_store_get("DATABASE_MANAGER_STATUS"),
  // Test that values can be set
  secure_store_set(
    "rust_testing_secure_store",
    // Pseudo-random value from `backup_id` in `create_backup`
    backup_id.chars().next().unwrap_or('X').to_string()
  ),
  secure_store_get("rust_testing_secure_store")
);
let non_existant = secure_store::get("non_existant").await;
let device_id = secure_store::get("DATABASE_MANAGER_STATUS").await;
// Test that promises are run on order (if awaited) and that
// "rust_testing_stuff" will always have the newest value
// Used promise_id as a "random" value for testing
let set_result =
  secure_store::set("rust_testing_stuff", promise_id.to_string()).await;
let set_test = secure_store::get("rust_testing_stuff").await;

let ret = format!(
  "
  SecureStore (nonExistant): {non_existant:?}
  SecureStore (dbStatus): {device_id:?}
  SecureStore set: {set_result:?}
  SecureStore (setTest): {set_test:?}"
);

Results:

Err(Exception { what: "Empty Optional cannot be unwrapped" })
Ok("WORKABLE")
Ok(())
Ok("F")

where the last value changes every call.

Reviewers: varun, marcin, kamil

Reviewed By: marcin

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D9926

Details

Provenance
Michal Gniadek <michal.gniadek@swmansion.com>Authored on Nov 15 2023, 7:19 AM
Reviewer
marcin
Differential Revision
D9926: [native] Expose SecureStore to Rust
Parents
rCOMMcffd38ff042f: [native] Make SecureStore methods static
Branches
Unknown
Tags
Unknown

Event Timeline

Michal Gniadek <michal.gniadek@swmansion.com> committed rCOMM57d2efb99127: [native] Expose SecureStore to Rust (authored by Michal Gniadek <michal.gniadek@swmansion.com>).Dec 19 2023, 7:27 AM