diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index eee4fedd..00000000 --- a/.cargo/config +++ /dev/null @@ -1,3 +0,0 @@ -# Alias test command to run against different environment -[alias] -t = "test --features senv" \ No newline at end of file diff --git a/.gitignore b/.gitignore index ef0c98be..e8853d96 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ Cargo.lock *.code-workspace .metals/ tests/testkeys/*.pem +tests/testkeys/*.json java/scala/src/test/resources/service-keys.conf java/scala/src/test/resources/service-keys.conf.stage java/scala/src/test/resources/service-keys.conf.local diff --git a/.travis.yml b/.travis.yml index 773561be..a83c9d97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,13 @@ cache: before_cache: - rm -rf /home/travis/.cargo/registry rust: - - 1.36.0 + - 1.38.0 branches: only: - master before_install: # key for integration tests - - openssl aes-256-cbc -K $encrypted_86f168e6939a_key -iv $encrypted_86f168e6939a_iv -in tests/testkeys/rsa_private.pem.enc -out tests/testkeys/rsa_private.pem -d + - openssl aes-256-cbc -K $encrypted_d5683c11b5e1_key -iv $encrypted_d5683c11b5e1_iv -in tests/testkeys/iak-dev.pem.enc -out tests/testkeys/iak-dev.pem -d before_script: - rustup component add rustfmt-preview - cross --version || cargo install cross diff --git a/.travis_scripts/cross-test.sh b/.travis_scripts/cross-test.sh index 1443e902..2318d4d9 100755 --- a/.travis_scripts/cross-test.sh +++ b/.travis_scripts/cross-test.sh @@ -5,7 +5,7 @@ set -x # If no special target provided, use default cargo arch for building and run all unit tests if [ -z "$TARGET" ]; then - cargo t --verbose + IRONCORE_ENV=dev cargo t --verbose cargo fmt -- --check # Cross doesn't have support for iOS builds, so use cargo to add the target and compile for it elif [ "$IOS" = 1 ]; then diff --git a/CHANGELOG.md b/CHANGELOG.md index 83cb302d..f8fb6ed4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Changelog ## 0.14.0 (Unreleased) + +- [[#69](https://github.com/IronCoreLabs/ironoxide/pull/69)] + - Allows changing of IronCore environment at runtime. - [[#64](https://github.com/IronCoreLabs/ironoxide/pull/64)] - - Adds need_rotation to `GroupCreateOpts`, allowing a group to be created with its private key marked for rotation + - Adds need_rotation to `GroupCreateOpts`, allowing a group to be created with its private key marked for rotation. ## 0.13.0 diff --git a/Cargo.toml b/Cargo.toml index 4dc8fb15..4a02d976 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,14 +37,11 @@ log = "~0.4" protobuf = {version = "~2.8", features = ["with-bytes"]} [dev-dependencies] -frank_jwt = "~3.1.1" +frank_jwt = "~3.1.2" galvanic-assert = "~0.8" uuid = { version = "~0.7.2", features = ["serde", "v4"] } double = "~0.2.4" [build-dependencies] -protobuf-codegen-pure = "~2.8" - -[features] -senv = [] +protobuf-codegen-pure = "~2.8" \ No newline at end of file diff --git a/README.md b/README.md index e67b6ac7..cdb6025e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ If you are not building a Rust application, you might be interested in one of th - [ironoxide-java](https://github.com/IronCoreLabs/ironoxide-java) - Java bindings for ironoxide. Appropriate for all JVM langauges. - [ironoxide-scala](https://github.com/IronCoreLabs/ironoxide-scala) - Scala wrappers around `ironoxide-java`. -- [ironode](https://github.com/IronCoreLabs/ironnode) - NodeJS implementation of IronCore's Privacy Platform. +- [ironnode](https://github.com/IronCoreLabs/ironnode) - NodeJS implementation of IronCore's Privacy Platform. - [ironweb](https://github.com/IronCoreLabs/ironweb) - Javascript implementation of IronCore's Privacy Platform. Appropriate for all modern browsers. All SDKs are intended to be compatible with one another. diff --git a/build.rs b/build.rs index fa0b85df..2e0b7d01 100644 --- a/build.rs +++ b/build.rs @@ -1,8 +1,10 @@ extern crate protobuf_codegen_pure; -use std::env; -use std::fs::File; -use std::io::{Read, Write}; -use std::path::Path; +use std::{ + env, + fs::File, + io::{Read, Write}, + path::Path, +}; fn main() { let out_dir = env::var("OUT_DIR").expect("OUT_DIR should exist"); diff --git a/src/internal/mod.rs b/src/internal/mod.rs index d226894f..d42f33ad 100644 --- a/src/internal/mod.rs +++ b/src/internal/mod.rs @@ -27,13 +27,20 @@ pub mod group_api; mod rest; pub mod user_api; -#[cfg(feature = "senv")] -pub const OUR_REQUEST: IronCoreRequest = - IronCoreRequest::new("https://api-staging.ironcorelabs.com/api/1/"); - -#[cfg(not(feature = "senv"))] -pub const OUR_REQUEST: IronCoreRequest = - IronCoreRequest::new("https://api.ironcorelabs.com/api/1/"); +lazy_static! { + pub static ref URL_STRING: String = match std::env::var("IRONCORE_ENV") { + Ok(url) => match url.to_lowercase().as_ref() { + "dev" => "https://api-dev1.ironcorelabs.com/api/1/", + "stage" => "https://api-staging.ironcorelabs.com/api/1/", + "prod" => "https://api.ironcorelabs.com/api/1/", + url_choice => url_choice, + } + .to_string(), + _ => "https://api.ironcorelabs.com/api/1/".to_string(), + }; + pub static ref OUR_REQUEST: IronCoreRequest::<'static> = + IronCoreRequest::new(URL_STRING.as_str()); +} #[derive(Debug, PartialEq, Clone, Copy)] pub enum RequestErrorCode { diff --git a/src/internal/rest.rs b/src/internal/rest.rs index 0424e922..385b45f0 100644 --- a/src/internal/rest.rs +++ b/src/internal/rest.rs @@ -300,14 +300,14 @@ impl<'a> HeaderIronCoreRequestSig<'a> { } ///A struct which holds the basic info that will be needed for making requests to an ironcore service. Currently just the base_url. -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Copy)] pub struct IronCoreRequest<'a> { base_url: &'a str, } impl Default for IronCoreRequest<'static> { fn default() -> Self { - OUR_REQUEST + *OUR_REQUEST } } diff --git a/src/user.rs b/src/user.rs index a656ee7b..28ca3f91 100644 --- a/src/user.rs +++ b/src/user.rs @@ -154,7 +154,7 @@ impl UserOps for IronOxide { jwt.try_into()?, password.try_into()?, user_create_opts.needs_rotation, - OUR_REQUEST, + *OUR_REQUEST, )) } @@ -178,7 +178,7 @@ impl UserOps for IronOxide { password.try_into()?, device_create_options.device_name, &std::time::SystemTime::now().into(), - OUR_REQUEST, + *OUR_REQUEST, )) } @@ -189,7 +189,7 @@ impl UserOps for IronOxide { fn user_verify(jwt: &str) -> Result> { let mut rt = Runtime::new().unwrap(); - rt.block_on(user_api::user_verify(jwt.try_into()?, OUR_REQUEST)) + rt.block_on(user_api::user_verify(jwt.try_into()?, *OUR_REQUEST)) } fn user_get_public_key(&self, users: &[UserId]) -> Result> { diff --git a/tests/INTEGRATION-TESTS.md b/tests/INTEGRATION-TESTS.md index cd2e9c5a..b2805cc5 100644 --- a/tests/INTEGRATION-TESTS.md +++ b/tests/INTEGRATION-TESTS.md @@ -1,24 +1,61 @@ -Integration Testing -=================== +# Integration Testing -Our integration tests require that we point to the IronCore staging environment. In order to swap that out at compile time we use a Rust feature flag to causes the SDK to point to stage. To prevent us from having to always pass `--features` when running our tests, we created an alias so that `cargo t` will automatically apply that feature flag. If you run `cargo test` you'll get failures that will hopefully clue you in that you need to use `cargo t` instead. +Our integration tests default to pointing to the IronCore environment, and will therefore need to be set up before use. However, unit tests can be run without prior setup. -Running *only* the unit tests (IronOxide users - this is what you want): +To run _only_ the unit tests (IronOxide users - this is what you want): `cargo t --lib` -Running *only* the integration tests: +To run _only_ the integration tests: `cargo t --test group_ops --test user_ops --test document_ops` -Running all the tests: +To run all the tests: `cargo t` -#### Integration Tests +## Testing against IronCore Dev, Stage, or Prod Environments -Integration tests are run as part of a PR build on Travis. These keys are stored as a Travis secret. +Integration tests run against IronCore environments require some test keys and configuration files. Pre-generated keys and config files can be found in `tests/testkeys/`. _Currently only IronCore devs have access to these keys._ The following ironhide command will decrypt the developer test keys. -The integration test run against IronCore's staging environment and require some tests keys. These can be found in `tests/testkeys/rsa_private.pem.iron`. _Currently only IronCore devs have access to these keys._ The following ironhide command will decrypt the developer test keys. +`$ ironhide file:decrypt tests/testkeys/*.iron` -`$ ironhide file:decrypt rsa_private.pem.iron` +### Running the Tests + +The environment you would like to test against is specified in the environment variable `IRONCORE_ENV`. This variable can be set to `dev`, `stage`, or `prod` to use the pre-generated keys and config files. To test against these, run one of the following: + +- Development: `IRONCORE_ENV=dev cargo t` +- Staging: `IRONCORE_ENV=stage cargo t` +- Production: `IRONCORE_ENV=prod cargo t` + +## Testing against a different environment + +IronOxide tests can be run against any other environment, with proper setup. To do this, you must provide an Identity Assertion Key file, an IronCore Config file, and the URL you would like to test against. This will require you to create a project, segment, and Identity Assertion Key using the admin console interface. + +### Identity Assertion Key File + +An Identity Assertion Key file must be downloaded from the admin console interface immediately after creating a new Identity Assertion Key. It must be named `iak.pem` and placed in `./tests/testkeys/`. + +### IronCore Config File + +An IronCore Config file can be downloaded from the admin console on creation of the very first project. For subsequent projects, it will need to be created manually. The file is of the form: + +```javascript +{ + "projectId": YOUR_PROJECT_ID, + "segmentId": "YOUR_SEGMENT_ID", + "identityAssertionKeyId": YOUR_IDENTITY_ASSERION_KEY_ID +} +``` + +Note that case is significant for the key names. + +This file must be named `ironcore-config.json` and placed in `./tests/testkeys/`. + +### Environment URL + +The URL of the environment you would like to test against is specified in the environment variable `IRONCORE_ENV`. To specify this when running the tests, run the following: + + Manual URL: `IRONCORE_ENV={URL} cargo t` + +where `{URL}` is the URL of the environment you want to test against. diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 94402dbc..a71a0e24 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,54 +1,104 @@ use ironoxide::{ prelude::*, user::{UserCreateOpts, UserResult}, - InitAndRotationCheck, IronOxide, + InitAndRotationCheck, }; +use lazy_static::*; use std::{convert::TryInto, default::Default}; use uuid::Uuid; pub const USER_PASSWORD: &str = "foo"; -pub fn gen_jwt( +#[derive(serde::Deserialize)] +#[serde(rename_all = "camelCase")] +struct Config { project_id: usize, - seg_id: &str, - service_key_id: usize, - account_id: Option<&str>, -) -> (String, String) { - use std::env; + segment_id: String, + identity_assertion_key_id: usize, +} - let mut keypath = env::current_dir().unwrap(); - keypath.push("tests"); - keypath.push("testkeys"); - keypath.push("rsa_private.pem"); +lazy_static! { + pub static ref ENV: String = match std::env::var("IRONCORE_ENV") { + Ok(url) => match url.to_lowercase().as_ref() { + "dev" => "-dev", + "stage" => "-stage", + "prod" => "-prod", + _ => "", + }, + _ => "-prod", + } + .to_string(); + static ref KEYPATH: (String, std::path::PathBuf) = { + let mut path = std::env::current_dir().unwrap(); + let filename = format!("iak{}.pem", *ENV); + path.push("tests"); + path.push("testkeys"); + path.push(filename.clone()); + (filename, path) + }; + static ref IRONCORE_CONFIG_PATH: (String, std::path::PathBuf) = { + let mut path = std::env::current_dir().unwrap(); + let filename = format!("ironcore-config{}.json", *ENV); + path.push("tests"); + path.push("testkeys"); + path.push(filename.clone()); + (filename, path) + }; + static ref CONFIG: Config = { + use std::{error::Error, fs::File, io::Read}; + let mut file = File::open(IRONCORE_CONFIG_PATH.1.clone()).unwrap_or_else(|err| { + panic!( + "Failed to open config file ({}) with error '{}'", + IRONCORE_CONFIG_PATH.0, + err.description() + ) + }); + let mut json_config = String::new(); + file.read_to_string(&mut json_config).unwrap_or_else(|err| { + panic!( + "Failed to read config file ({}) with error '{}'", + IRONCORE_CONFIG_PATH.0, + err.description() + ) + }); + serde_json::from_str(&json_config).unwrap_or_else(|err| { + panic!( + "Failed to deserialize config file ({}) with error '{}'", + IRONCORE_CONFIG_PATH.0, + err.description() + ) + }) + }; +} +pub fn gen_jwt(account_id: Option<&str>) -> (String, String) { use std::time::{SystemTime, UNIX_EPOCH}; let start = SystemTime::now(); let iat_seconds = start .duration_since(UNIX_EPOCH) .expect("Time before epoch? Something's wrong.") .as_secs(); - let jwt_header = json!({}); let default_account_id = Uuid::new_v4().to_string(); - let sub = account_id - .or_else(|| Some(&default_account_id)) - .expect("Missing expected JWT account ID."); + let sub = account_id.unwrap_or(&default_account_id); let jwt_payload = json!({ - "pid" : project_id, - "sid" : seg_id, - "kid" : service_key_id, + "pid" : CONFIG.project_id, + "sid" : CONFIG.segment_id, + "kid" : CONFIG.identity_assertion_key_id, "iat" : iat_seconds, "exp" : iat_seconds + 120, "sub" : sub }); let jwt = frank_jwt::encode( jwt_header, - &keypath.to_path_buf(), + &KEYPATH.1.to_path_buf(), &jwt_payload, - frank_jwt::Algorithm::RS256, + frank_jwt::Algorithm::ES256, ) - .expect("You don't appear to have the proper service private key to sign the test JWT."); - (jwt, format!("{}", sub)) + .expect( + &format!("Error with {}: You don't appear to have the proper service private key to sign the test JWT.", KEYPATH.0) + ); + (jwt, sub.to_string()) } pub fn init_sdk() -> IronOxide { @@ -63,21 +113,19 @@ pub fn init_sdk_get_user() -> (UserId, IronOxide) { pub fn init_sdk_get_init_result(user_needs_rotation: bool) -> (UserId, InitAndRotationCheck) { let account_id: UserId = create_id_all_classes("").try_into().unwrap(); IronOxide::user_create( - &gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0, + &gen_jwt(Some(account_id.id())).0, USER_PASSWORD, &UserCreateOpts::new(user_needs_rotation), ) .unwrap(); - let verify_resp = - IronOxide::user_verify(&gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0) - .unwrap() - .unwrap(); + let verify_resp = IronOxide::user_verify(&gen_jwt(Some(account_id.id())).0) + .unwrap() + .unwrap(); assert_eq!(&account_id, verify_resp.account_id()); - assert_eq!(2012, verify_resp.segment_id()); let device = IronOxide::generate_new_device( - &gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0, + &gen_jwt(Some(account_id.id())).0, USER_PASSWORD, &Default::default(), ) @@ -106,7 +154,7 @@ pub fn init_sdk_get_init_result(user_needs_rotation: bool) -> (UserId, InitAndRo } pub fn create_second_user() -> UserResult { - let (jwt, _) = gen_jwt(1012, "test-segment", 551, Some(&create_id_all_classes(""))); + let (jwt, _) = gen_jwt(Some(&create_id_all_classes(""))); let create_result = IronOxide::user_create(&jwt, USER_PASSWORD, &Default::default()); assert!(create_result.is_ok()); @@ -127,5 +175,5 @@ pub fn create_id_all_classes(prefix: &str) -> String { #[allow(dead_code)] // Use this test to print out a JWT and UUID if you need it fn non_test_print_jwt() { - dbg!(gen_jwt(1012, "test-segment", 551, None)); + dbg!(gen_jwt(None)); } diff --git a/tests/testkeys/iak-dev.pem.enc b/tests/testkeys/iak-dev.pem.enc new file mode 100644 index 00000000..9ee371d7 --- /dev/null +++ b/tests/testkeys/iak-dev.pem.enc @@ -0,0 +1,4 @@ +9C_R_/!tKs^`K)SU\+\Ken'.t_ 1ZCBmUkKff2¤ fWPEjcr$3Wj@Jv0_I:f+6cq8V*dhq!d9F :,Vɐk8Z&-4gzia. +߸Ee8oN.C/pI0M]i6܇g:K{QÓQQ. hP -D@Hd.btJs7Jݩ:V+|lZ;ⳈVf[*T +[oq{lX +e;j..QXG(,9=*z!!BsdޒmbZfA@7{ \ No newline at end of file diff --git a/tests/testkeys/iak-dev.pem.iron b/tests/testkeys/iak-dev.pem.iron new file mode 100644 index 00000000..e40fe622 Binary files /dev/null and b/tests/testkeys/iak-dev.pem.iron differ diff --git a/tests/testkeys/iak-prod.pem.iron b/tests/testkeys/iak-prod.pem.iron new file mode 100644 index 00000000..4c82e853 Binary files /dev/null and b/tests/testkeys/iak-prod.pem.iron differ diff --git a/tests/testkeys/iak-stage.pem.iron b/tests/testkeys/iak-stage.pem.iron new file mode 100644 index 00000000..ca873653 Binary files /dev/null and b/tests/testkeys/iak-stage.pem.iron differ diff --git a/tests/testkeys/ironcore-config-dev.json b/tests/testkeys/ironcore-config-dev.json new file mode 100644 index 00000000..70d73492 --- /dev/null +++ b/tests/testkeys/ironcore-config-dev.json @@ -0,0 +1,5 @@ +{ + "projectId": 438, + "segmentId": "ironoxide-dev1", + "identityAssertionKeyId": 593 +} diff --git a/tests/testkeys/ironcore-config-prod.json b/tests/testkeys/ironcore-config-prod.json new file mode 100644 index 00000000..a4d342a2 --- /dev/null +++ b/tests/testkeys/ironcore-config-prod.json @@ -0,0 +1,5 @@ +{ + "projectId": 1903, + "segmentId": "ironoxide-tests", + "identityAssertionKeyId": 2173 +} diff --git a/tests/testkeys/ironcore-config-stage.json b/tests/testkeys/ironcore-config-stage.json new file mode 100644 index 00000000..3390ecf1 --- /dev/null +++ b/tests/testkeys/ironcore-config-stage.json @@ -0,0 +1,5 @@ +{ + "projectId": 428, + "segmentId": "ironoxide-staging", + "identityAssertionKeyId": 588 +} diff --git a/tests/testkeys/rsa_keygen.md b/tests/testkeys/rsa_keygen.md deleted file mode 100644 index c4276d14..00000000 --- a/tests/testkeys/rsa_keygen.md +++ /dev/null @@ -1,46 +0,0 @@ -## Why RSA? - -Short answer is that I couldn't get our standard EC private keys to work with `frank-jwt` (and it's the only Rust library that implements ES256). RS256 seems to work. I suspect the private key format we generally use isn't being parsed correctly. - -## Key generation - -For RS256 -``` -openssl genrsa -out rsa_private.pem 2048 -openssl rsa -in rsa_private.pem -pubout -out rsa_public.pem -``` - -## The admin database - -I used the Auth0 service key option to get the basic structure in the database. Then I had to figure out how to extract the right values out of the public key, get them encoded to base64, and in a format ironcore-id would understand. - -The following resources were helpful: -* [SO post](https://crypto.stackexchange.com/questions/18031/how-to-find-modulus-from-a-rsa-public-key) -* [Key parser](https://lapo.it/asn1js/) to understand the format better -* [Hex to base64 encoder](http://tomeko.net/online_tools/hex_to_base64.php) - -### Steps to get the right base64 string - - -``` -openssl rsa -pubin -in pubkey.txt -text -noout -cat pubkey.txt -``` - -These are the `n` and `e` values that ironcore-id expects to be in the format `n`.`e` (base64) - -Use the [Hex to base64 encoder](http://tomeko.net/online_tools/hex_to_base64.php) to encode the Modulus value (n). Save the value away. - -Do the same with the hex value of the exponent. It's probably 0x010001 (65537) which is `AQAB` in base64. Concat that value onto the `n` value, separated by a `.` - -Use psql to insert that value into the db - -Current key was: - -``` -update service_key set public_key = 'APC8lcY7EwzvJHvzlsCth0Q98+RwuWTbkh8Wf/Wp2btoBgfgLaQhI7svAR1e/0cb0uROYUfzsgClxBipsAm3B9gHEtUPtKTU0wFvW+xGgRzTlkhCTDCXcpRG2tgyDMQPh0tzGkEc+6sxnF1euBBxuNpm718SN9IlO2k5gBj7v2hSjlnvPoOt9TV93OTX6CCpAFotrrZf1x0gdwEfuu5rSv7GMXH2Bt/tbogv80I6XOMorSjnyH1VXdEVeNTnbAnfR5DyAXIjiBtRLRftiBZJPwZa4ysxrxrL6umnXYVx0DcZC15ta2JAaB65IoWPbpSKNyc1cxTcT60pNW+ElcCJl3k=.AQAB' where id = 551; - -``` - -IMPORTANT! -*Put in the correct `id` for the service key!* \ No newline at end of file diff --git a/tests/testkeys/rsa_private.json b/tests/testkeys/rsa_private.json new file mode 100644 index 00000000..416f54cc --- /dev/null +++ b/tests/testkeys/rsa_private.json @@ -0,0 +1,5 @@ +{ + "projectId": 1012, + "segmentId": "test-segment", + "identityAssertionKeyId": 551 +} diff --git a/tests/testkeys/rsa_private.pem.enc b/tests/testkeys/rsa_private.pem.enc deleted file mode 100644 index 20adbd79..00000000 Binary files a/tests/testkeys/rsa_private.pem.enc and /dev/null differ diff --git a/tests/user_ops.rs b/tests/user_ops.rs index df9fbe08..04148d34 100644 --- a/tests/user_ops.rs +++ b/tests/user_ops.rs @@ -13,7 +13,7 @@ extern crate serde_json; #[test] fn user_verify_non_existing_user() { - let result = IronOxide::user_verify(&gen_jwt(1012, "test-segment", 551, None).0); + let result = IronOxide::user_verify(&gen_jwt(None).0); assert_eq!(true, result.is_ok(), "User verify call failed unexpectedly"); let option_result = result.unwrap(); assert_eq!(true, option_result.is_none()); @@ -23,33 +23,29 @@ fn user_verify_non_existing_user() { fn user_verify_existing_user() { let account_id: UserId = create_id_all_classes("").try_into().unwrap(); IronOxide::user_create( - &gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0, + &gen_jwt(Some(account_id.id())).0, "foo", &Default::default(), ) .unwrap(); - let result = - IronOxide::user_verify(&gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0) - .unwrap(); + let result = IronOxide::user_verify(&gen_jwt(Some(account_id.id())).0).unwrap(); assert_eq!(true, result.is_some()); let verify_resp = result.unwrap(); assert_eq!(&account_id, verify_resp.account_id()); - assert_eq!(2012, verify_resp.segment_id()); } #[test] fn user_verify_after_create_with_needs_rotation() -> Result<(), IronOxideErr> { let account_id: UserId = Uuid::new_v4().to_string().try_into().unwrap(); IronOxide::user_create( - &gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0, + &gen_jwt(Some(account_id.id())).0, "foo", &UserCreateOpts::new(true), )?; - let result = - IronOxide::user_verify(&gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0)?; + let result = IronOxide::user_verify(&gen_jwt(Some(account_id.id())).0)?; assert_eq!(true, result.is_some()); let verify_resp = result.unwrap(); @@ -59,14 +55,14 @@ fn user_verify_after_create_with_needs_rotation() -> Result<(), IronOxideErr> { fn user_create_good_with_devices() { let account_id: UserId = Uuid::new_v4().to_string().try_into().unwrap(); let result = IronOxide::user_create( - &gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0, + &gen_jwt(Some(account_id.id())).0, "foo", &Default::default(), ); assert!(result.is_ok()); let device = IronOxide::generate_new_device( - &gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0, + &gen_jwt(Some(account_id.id())).0, "foo", &DeviceCreateOpts::new(Some("myDevice".try_into().unwrap())), ); @@ -134,7 +130,7 @@ fn user_add_device_after_rotation() -> Result<(), IronOxideErr> { //add a new device let new_device = IronOxide::generate_new_device( - &common::gen_jwt(1012, "test-segment", 551, Some(user.id())).0, + &common::gen_jwt(Some(user.id())).0, common::USER_PASSWORD, &Default::default(), )?; @@ -153,7 +149,7 @@ fn user_add_device_after_rotation() -> Result<(), IronOxideErr> { fn user_create_with_needs_rotation() -> Result<(), IronOxideErr> { let account_id: UserId = Uuid::new_v4().to_string().try_into().unwrap(); let result = IronOxide::user_create( - &gen_jwt(1012, "test-segment", 551, Some(account_id.id())).0, + &gen_jwt(Some(account_id.id())).0, common::USER_PASSWORD, &UserCreateOpts::new(true), );