diff --git a/Cargo.lock b/Cargo.lock index 4c1051e4..3d7839fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" [[package]] name = "api" @@ -113,9 +113,9 @@ dependencies = [ "openapiv3", "rand", "redis", - "reqwest 0.12.4", + "reqwest", "segment", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "strum", @@ -165,7 +165,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -176,7 +176,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -256,7 +256,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -554,16 +554,6 @@ version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147be55d677052dabc6b22252d5dd0fd4c29c8c27aa4f2fbef0f94aa003b406f" -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -721,7 +711,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -743,7 +733,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core 0.20.8", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -813,7 +803,7 @@ dependencies = [ "quote", "strum", "strum_macros", - "syn 2.0.60", + "syn 2.0.63", "thiserror", ] @@ -862,9 +852,9 @@ dependencies = [ [[package]] name = "deunicode" -version = "1.4.4" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322ef0094744e63628e6f0eb2295517f79276a5b342a4c2ff3042566ca181d4e" +checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" [[package]] name = "digest" @@ -898,7 +888,7 @@ dependencies = [ "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -907,15 +897,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - [[package]] name = "enum-as-inner" version = "0.4.0" @@ -956,9 +937,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -986,7 +967,7 @@ dependencies = [ "moka", "mongodb", "redis", - "reqwest 0.12.4", + "reqwest", "serde", "serde_json", "testcontainers-modules", @@ -1041,7 +1022,7 @@ dependencies = [ "http 1.1.0", "rand", "rand_core", - "semver 1.0.22", + "semver 1.0.23", "serde_json", "url-escape", "uuid", @@ -1150,7 +1131,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1510,20 +1491,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http 0.2.12", - "hyper 0.14.28", - "rustls 0.21.12", - "tokio", - "tokio-rustls 0.24.1", -] - [[package]] name = "hyper-rustls" version = "0.26.0" @@ -1659,9 +1626,9 @@ dependencies = [ [[package]] name = "integrationos-domain" -version = "3.1.1" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f9cd2eec62bc686c90c2340ed7f411338c70946a6ee980996826f862a07b3fa" +checksum = "537d6cb715828df2e2f0366504ac4027790da4a86469a0b9fa6e1755078000eb" dependencies = [ "aes", "anyhow", @@ -1690,8 +1657,8 @@ dependencies = [ "prost", "rand", "redis", - "reqwest 0.12.4", - "semver 1.0.22", + "reqwest", + "semver 1.0.23", "serde", "serde_json", "sha2", @@ -1779,7 +1746,7 @@ checksum = "e0445474069bad4c2b01856976d83c796521ae9298ba718ecf26041767eb68b2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1990,7 +1957,7 @@ checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2169,11 +2136,10 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", "rand", @@ -2341,7 +2307,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2372,7 +2338,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2465,7 +2431,7 @@ checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" dependencies = [ "proc-macro-rules-macros", "proc-macro2", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2477,14 +2443,14 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -2501,15 +2467,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +checksum = "9554e3ab233f0a932403704f1a1d08c30d5ccd931adfdfa1e8b5a19b52c1d55a" dependencies = [ "anyhow", "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2709,47 +2675,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", - "hyper-rustls 0.24.2", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls 0.21.12", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration", - "tokio", - "tokio-rustls 0.24.1", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots 0.25.4", - "winreg 0.50.0", -] - [[package]] name = "reqwest" version = "0.12.4" @@ -2764,7 +2689,7 @@ dependencies = [ "http-body 1.0.0", "http-body-util", "hyper 1.3.1", - "hyper-rustls 0.26.0", + "hyper-rustls", "hyper-util", "ipnet", "js-sys", @@ -2833,9 +2758,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_version" @@ -2852,7 +2777,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.22", + "semver 1.0.23", ] [[package]] @@ -2925,9 +2850,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" @@ -2952,15 +2877,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" +checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -2989,12 +2914,12 @@ dependencies = [ [[package]] name = "segment" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12485833e00457a6bbba60397d3f19362751a0caefe27f6755fff1a2be4fd601" +checksum = "5bdca318192c89bb31bffa2ef8e9e9898bc80f15a78db2fdd41cd051f1b41d01" dependencies = [ "async-trait", - "reqwest 0.11.27", + "reqwest", "serde", "serde_json", "thiserror", @@ -3012,9 +2937,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] @@ -3027,9 +2952,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.200" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] @@ -3045,20 +2970,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.200" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "indexmap 2.2.6", "itoa", @@ -3329,7 +3254,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -3351,9 +3276,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" dependencies = [ "proc-macro2", "quote", @@ -3372,27 +3297,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tagptr" version = "0.2.0" @@ -3439,22 +3343,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -3559,7 +3463,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -3689,7 +3593,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -4031,7 +3935,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "wasm-bindgen-shared", ] @@ -4065,7 +3969,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4347,22 +4251,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.33" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087eca3c1eaf8c47b94d02790dd086cd594b912d2043d4de4bfdd466b3befb7c" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.33" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f4b6c273f496d8fd4eaf18853e6b448760225dc030ff2c485a786859aea6393" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d19a2c17..0b6e4132 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ futures-util = "0.3.28" handlebars = "4.4.0" http = "1.1.0" http-serde-ext = "1.0.2" -integrationos-domain = "3.1.0" +integrationos-domain = "4.0.0" js-sandbox-ios = "0.1.0" jsonpath_lib = "0.3.0" jsonwebtoken = "8.3.0" diff --git a/api/src/endpoints/mod.rs b/api/src/endpoints/mod.rs index 0311e526..b098fbfb 100644 --- a/api/src/endpoints/mod.rs +++ b/api/src/endpoints/mod.rs @@ -209,7 +209,6 @@ where }, Err(e) => { error!("Error reading from store: {e}"); - println!("{:?}", e); return Err(internal_server_error!()); } }; @@ -231,7 +230,6 @@ where .try_get_with(query.as_ref().map(|q| q.0.clone()), async { let query = shape_mongo_filter(query, None, None); - println!("{:?}", query); let store = T::get_store(state.app_stores.clone()); let count = store.count(query.filter.clone(), None); let find = store.get_many( @@ -243,16 +241,12 @@ where ); let res = match try_join!(count, find) { - Ok((total, rows)) => { - println!("{:?}", total); - - Arc::new(ReadResponse { - rows, - skip: query.skip, - limit: query.limit, - total, - }) - } + Ok((total, rows)) => Arc::new(ReadResponse { + rows, + skip: query.skip, + limit: query.limit, + total, + }), Err(e) => { error!("Error reading from store: {e}"); return Err(internal_server_error!()); diff --git a/api/tests/api_tests/auth_tests.rs b/api/tests/api_tests/auth_tests.rs index a84c1eee..216d9d22 100644 --- a/api/tests/api_tests/auth_tests.rs +++ b/api/tests/api_tests/auth_tests.rs @@ -1,10 +1,5 @@ use super::test_server::{ApiResponse, TestServer, PUBLIC_PATHS}; -use api::endpoints::event_access::CreateEventAccessPayloadWithOwnership; -use fake::{Fake, Faker}; -use http::{ - header::{AUTHORIZATION, CONTENT_TYPE}, - Method, StatusCode, -}; +use http::{Method, StatusCode}; use serde_json::{json, Value}; #[tokio::test] @@ -50,31 +45,3 @@ async fn test_404() { ); } } - -#[tokio::test] -async fn test_jwt() { - let server = TestServer::new(None).await; - let jwt_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NTc5ZDUxMGE2ZTQyMTAyMzM0NjI0ZjAiLCJlbWFpbCI6ImVtYWlsQHRlc3QuY29tIiwidXNlcm5hbWUiOiJ1c2VybmFtZSIsInVzZXJLZXkiOiJ1c2VyS2V5IiwiZmlyc3ROYW1lIjoiUGF1bCIsImxhc3ROYW1lIjoiSy4iLCJidWlsZGFibGVJZCI6ImJ1aWxkLTI2MTU4YWFlNzNjMDQ4YTU4YzdhNzU2NjcyNmU4OGY0IiwiY29udGFpbmVySWQiOiJjb250YWluZXItZDRmMGY4YjktMWE1Ni00ODQxLTg1OTctZmQzZDkwZGQ0OWI5IiwicG9pbnRlcnMiOlsiXzFfazFjbkI0Y1hGMzYtYUJJc2gtY1ZWTlZNZllGeE41MWlFTlQ1azlqcXFEbURWZlpJTjVVREhlN0JKRnJaUVJqTm54aEdaOUJNUGdlNjB6RVdVUnROaTUxdTIwdDJiYVJoQ3ZkYms5TkNIblNSV010WldhMmFlVW0wWUpreU1PNGNEUjdVUW5oVmNac3RqUEdfN0lfcV9ya015cjlwaFZoZ1VBa3BCaDVDTlQ2VDIwTDJGTFpoMFVtdldLVzloV3IzN0JWV19tb0hZODFZeUEiLCJfMV81WVU2Uk1kMHRwUVh3YnNvUWtHaUkzT1hPRlhrbms3TUVhaVdTQ1hoUWZKYzZ5N3RqZGROZGRjbXdWRjJmcTRSTktla0ZXRk80M0FMQWNJTVdIYkdYbW9IVVRaelV1eXhMalJ5MDI5Z0tGMlViRTFmTzZVRzR5QWhzbFBJMlpOZXNnT2NiakY1eUdwajdJbkdHNUFVck13NGY0bVdfR29FZVp1ZXBBd2E0WHhzNHB2TXd5d241djc1VzV0dFNJRGtLTHFqUlNUQlczaHpLUSJdLCJpc0J1aWxkYWJsZUNvcmUiOnRydWUsImlhdCI6MTcwMzEwODkwNCwiZXhwIjozMTU3NDYzMTA4OTA0LCJhdWQiOiJidWlsZGFibGUtdXNlcnMiLCJpc3MiOiJidWlsZGFibGUifQ.ecKXIGxXLWd6OearftRZVpGRhyDUVZFrYlwzhr-iG0A"; - let event_access: CreateEventAccessPayloadWithOwnership = Faker.fake(); - let event_access = serde_json::to_value(&event_access).unwrap(); - - let res = server - .send_request_with_headers::( - "v1/public/event-access/default", - Method::POST, - None, - Some(&event_access), - Some( - vec![ - (AUTHORIZATION.to_string(), format!("Bearer {jwt_token}")), - (CONTENT_TYPE.to_string(), "application/json".to_string()), - ] - .into_iter() - .collect(), - ), - ) - .await - .unwrap(); - - assert_eq!(res.code, StatusCode::OK); -} diff --git a/api/tests/api_tests/get_tests.rs b/api/tests/api_tests/get_tests.rs index b4537622..24634413 100644 --- a/api/tests/api_tests/get_tests.rs +++ b/api/tests/api_tests/get_tests.rs @@ -38,7 +38,6 @@ async fn test_get_events() { } #[tokio::test] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_get_expanded_common_model() { let server = TestServer::new(None).await; diff --git a/api/tests/api_tests/passthrough_tests.rs b/api/tests/api_tests/passthrough_tests.rs index 2d5ec358..6e3622bd 100644 --- a/api/tests/api_tests/passthrough_tests.rs +++ b/api/tests/api_tests/passthrough_tests.rs @@ -14,7 +14,6 @@ use mockito::Server; use serde_json::Value; #[tokio::test] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_passthrough_api() { let mut server = TestServer::new(None).await; let (connection, conn_def) = server.create_connection(Environment::Live).await; @@ -33,8 +32,7 @@ async fn test_passthrough_api() { .expect(1) .with_status(200) .with_body(response_body.clone()) - .create_async() - .await; + .create(); let create_model_definition_payload = CreateConnectionModelDefinitionRequest { connection_platform: connection.platform.to_string(), @@ -43,7 +41,7 @@ async fn test_passthrough_api() { title: Faker.fake(), name: Faker.fake(), model_name: Faker.fake(), - action_name: Faker.fake::(), + action_name: CrudAction::Create, base_url: mock_server.url() + &url_path, path: "customers".to_string(), auth_method: AuthMethod::BearerToken { @@ -103,7 +101,7 @@ async fn test_passthrough_api() { ), ) .await - .unwrap(); + .expect("Failed to call universal API"); // assert_eq!(call_universal_api.code, StatusCode::OK); assert_eq!( diff --git a/api/tests/api_tests/schema_tests.rs b/api/tests/api_tests/schema_tests.rs index a154acaf..93f29f0d 100644 --- a/api/tests/api_tests/schema_tests.rs +++ b/api/tests/api_tests/schema_tests.rs @@ -3,7 +3,6 @@ use http::{Method, StatusCode}; use serde_json::Value; #[tokio::test] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_connection_oauth_definition_schema_api() { let server = TestServer::new(None).await; let res = server diff --git a/api/tests/api_tests/test_crud.rs b/api/tests/api_tests/test_crud.rs index 9d4887cb..3d2ff332 100644 --- a/api/tests/api_tests/test_crud.rs +++ b/api/tests/api_tests/test_crud.rs @@ -81,7 +81,7 @@ macro_rules! crud { } crud!( - #[ignore = "Until we have a JWT token generated we can not test this"], + #[tokio::test], test_connection_definitions_crud, ConnectionDefinition, connection_definition, @@ -89,7 +89,7 @@ crud!( ); crud!( - #[ignore = "Until we have a JWT token generated we can not test this"], + #[tokio::test], test_connection_model_definitions_crud, ConnectionModelDefinition, connection_model_definition, @@ -97,7 +97,7 @@ crud!( ); crud!( - #[ignore = "Until we have a JWT token generated we can not test this"], + #[tokio::test], test_connection_model_schema_crud, ConnectionModelSchema, connection_model_schema, @@ -105,7 +105,6 @@ crud!( ); #[tokio::test] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_common_model_crud() { let server = TestServer::new(None).await; diff --git a/api/tests/api_tests/test_server/mod.rs b/api/tests/api_tests/test_server/mod.rs index ddf9359d..1632bcc0 100644 --- a/api/tests/api_tests/test_server/mod.rs +++ b/api/tests/api_tests/test_server/mod.rs @@ -13,24 +13,22 @@ use fake::{Fake, Faker}; use http::StatusCode; use http::{header::AUTHORIZATION, Method}; use integrationos_domain::{ + access_key_data::AccessKeyData, + access_key_prefix::AccessKeyPrefix, algebra::{CryptoExt, MongoStore, StoreExt}, + api_model_config::{AuthMethod, SamplesInput, SchemasInput}, + connection_definition::{ConnectionDefinition, ConnectionDefinitionType}, + connection_model_definition::{ + ConnectionModelDefinition, CrudAction, CrudMapping, PlatformInfo, + }, create_secret_response::{CreateSecretAuthor, CreateSecretResponse}, + environment::Environment, + event_access::EventAccess, + event_type::EventType, get_secret_request::GetSecretRequest, - IntegrationOSError, - { - access_key_data::AccessKeyData, - access_key_prefix::AccessKeyPrefix, - api_model_config::{AuthMethod, SamplesInput, SchemasInput}, - connection_definition::{ConnectionDefinition, ConnectionDefinitionType}, - connection_model_definition::{ - ConnectionModelDefinition, CrudAction, CrudMapping, PlatformInfo, - }, - environment::Environment, - event_access::EventAccess, - event_type::EventType, - AccessKey, Connection, Store, - }, + AccessKey, Claims, Connection, IntegrationOSError, Store, }; +use jsonwebtoken::EncodingKey; use mockito::{Matcher, Server as MockServer, ServerGuard}; use mongodb::Client; use rand::Rng; @@ -79,6 +77,7 @@ pub struct TestServer { client: reqwest::Client, pub mock_server: ServerGuard, pub secrets_client: Arc, + pub token: String, } #[derive(Debug, Clone, Default)] @@ -156,6 +155,7 @@ impl TestServer { // Random database name let db_name = db_name.unwrap_or_else(|| Uuid::new_v4().to_string()); + let token_secret = "atveroeosetaccusamusetiustoodiodignissimosducimus".to_string(); let config = Config::init_from_hashmap(&HashMap::from([ ("CONTROL_DATABASE_URL".to_string(), db.clone()), @@ -172,6 +172,7 @@ impl TestServer { ("MOCK_LLM".to_string(), "true".to_string()), ("CACHE_SIZE".to_string(), "0".to_string()), ("REDIS_URL".to_string(), redis), + ("JWT_SECRET".to_string(), token_secret.clone()), ])) .unwrap(); @@ -244,6 +245,27 @@ impl TestServer { tokio::time::sleep(Duration::from_millis(50)).await; + let token = jsonwebtoken::encode( + &jsonwebtoken::Header::default(), + &Claims { + id: "6579d510a6e42102334624f0".to_string(), + email: "email@test.com".to_string(), + username: "username".to_string(), + user_key: "userKey".to_string(), + first_name: "Paul".to_string(), + last_name: "K.".to_string(), + buildable_id: "buildable-26158aae73c048a58c7a7566726e88f4".to_string(), + container_id: "container-d4f0f8b9-1a56-4841-8597-fd3d90dd49b9".to_string(), + pointers: vec!["_1_k1cnB4cXF36-aBIsh-cVVNMYfXN51iENT5k9jqqDmDVfZIN5UDHe7BFrZQRjNnxgGZ9BMPg60zEWURtNi51u20t2baRhCvdbk9NCHnSRWMtZWa2aeUm0YKzyM4ScDR7UQnhVcsstjPG_7I_q_rMy5r9phVhgUAkPBh5CNT6T20L2FLZh0UmvWKW9hW37BVW_moHY81YyI".to_string()], + is_buildable_core: true, + iat: 1703108904, + exp: 3157463108904, + aud: "buildable-users".to_string(), + iss: "buildable".to_string(), + }, + &EncodingKey::from_secret(token_secret.as_bytes()), + ); + Self { port, config, @@ -254,6 +276,7 @@ impl TestServer { client: reqwest::Client::new(), mock_server: MockServer::new_async().await, secrets_client, + token: format!("Bearer {}", token.expect("Failed to encode token")), } } @@ -264,8 +287,17 @@ impl TestServer { key: Option<&str>, payload: Option<&T>, ) -> Result> { - self.send_request_with_headers(path, method, key, payload, None) - .await + self.send_request_with_auth_headers( + path, + method, + key, + payload, + Some(BTreeMap::from_iter(vec![( + AUTHORIZATION.to_string(), + self.token.clone(), + )])), + ) + .await } pub async fn send_request_with_headers( @@ -299,6 +331,28 @@ impl TestServer { }) } + pub async fn send_request_with_auth_headers( + &self, + path: &str, + method: http::Method, + key: Option<&str>, + payload: Option<&T>, + headers: Option>, + ) -> Result> { + let headers = match headers { + Some(h) => h + .into_iter() + .chain(vec![(AUTHORIZATION.to_string(), self.token.clone())]) + .collect(), + None => vec![(AUTHORIZATION.to_string(), self.token.clone())], + }; + + let headers = BTreeMap::from_iter(headers); + + self.send_request_with_headers(path, method, key, payload, Some(headers)) + .await + } + #[allow(dead_code)] pub async fn create_connection( &mut self, @@ -338,7 +392,6 @@ impl TestServer { let api_config = match test_connection.platform_info { PlatformInfo::Api(ref mut api_config_data) => api_config_data.clone(), - _ => panic!(), }; let mut mock = self @@ -351,6 +404,7 @@ impl TestServer { AUTHORIZATION.as_str(), format!("Bearer {bearer_key}").as_str(), ); + if let Some(ref headers) = api_config.headers { for k in headers.keys() { let val: Vec = headers diff --git a/api/tests/api_tests/transaction_tests.rs b/api/tests/api_tests/transaction_tests.rs index 20fca8a0..3ec91087 100644 --- a/api/tests/api_tests/transaction_tests.rs +++ b/api/tests/api_tests/transaction_tests.rs @@ -1,5 +1,4 @@ -use std::time::Duration; - +use crate::test_server::{test_core::TestCore, test_gateway::TestGateway, TestServer}; use api::endpoints::{pipeline::CreatePipelineRequest, ReadResponse}; use fake::{Fake, Faker}; use http::{Method, StatusCode}; @@ -8,8 +7,7 @@ use integrationos_domain::{ Transaction, }; use serde_json::{json, Value}; - -use crate::test_server::{test_core::TestCore, test_gateway::TestGateway, TestServer}; +use std::time::Duration; #[tokio::test(flavor = "multi_thread")] #[ignore = "Prometheus GlobalRecorder conflicts with other tests. It passes when run individually."] @@ -26,9 +24,7 @@ async fn test_event_core() { pipeline.source.events = vec![event_name.clone()]; pipeline.middleware = vec![]; pipeline.destination = Faker.fake(); - let PlatformInfo::Api(api_config) = conn_def.platform_info else { - panic!(); - }; + let PlatformInfo::Api(api_config) = conn_def.platform_info; pipeline.destination.platform = connection.platform.clone(); pipeline.destination.connection_key = connection.key; pipeline.destination.action = Action::Passthrough { diff --git a/api/tests/api_tests/unified_tests.rs b/api/tests/api_tests/unified_tests.rs index 1c7088da..1b1f6803 100644 --- a/api/tests/api_tests/unified_tests.rs +++ b/api/tests/api_tests/unified_tests.rs @@ -25,7 +25,6 @@ use serde_json::Value; use std::time::Duration; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_unified_api_get_many() { let mut server = TestServer::new(None).await; let (connection, _) = server.create_connection(Environment::Live).await; @@ -77,15 +76,12 @@ async fn test_unified_api_get_many() { .await .unwrap(); - println!("{:?}", res); - assert_eq!(res.code, StatusCode::OK); mock.assert_async().await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_unified_api_get_one() { let mut server = TestServer::new(None).await; let (connection, _) = server.create_connection(Environment::Live).await; @@ -144,7 +140,7 @@ async fn test_unified_api_get_one() { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "Until we have a JWT token generated we can not test this"] +#[ignore = "Unimplemented"] async fn test_unified_api_get_count() { let mut server = TestServer::new(None).await; let (connection, _) = server.create_connection(Environment::Live).await; @@ -201,7 +197,6 @@ async fn test_unified_api_get_count() { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_unified_api_update() { let mut server = TestServer::new(None).await; let (connection, _) = server.create_connection(Environment::Live).await; @@ -262,7 +257,6 @@ async fn test_unified_api_update() { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_unified_api_delete() { let mut server = TestServer::new(None).await; let (connection, _) = server.create_connection(Environment::Live).await; @@ -321,7 +315,6 @@ async fn test_unified_api_delete() { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_unified_api_create() { let mut server = TestServer::new(None).await; let (connection, _) = server.create_connection(Environment::Live).await; @@ -380,7 +373,6 @@ async fn test_unified_api_create() { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "Until we have a JWT token generated we can not test this"] async fn test_unified_metrics() { let mut server = TestServer::new(None).await; let (connection, _) = server.create_connection(Environment::Live).await; @@ -420,7 +412,7 @@ async fn test_unified_metrics() { ), ) .await - .unwrap(); + .expect("Failed to send request"); assert_eq!(res.code, StatusCode::OK); mock.assert_async().await; diff --git a/event-core/tests/mock_destination.rs b/event-core/tests/mock_destination.rs index 71ee537e..d971d053 100644 --- a/event-core/tests/mock_destination.rs +++ b/event-core/tests/mock_destination.rs @@ -12,22 +12,19 @@ use fake::{ use http::Method; use integrationos_domain::{ algebra::CryptoExt, - create_secret_response::CreateSecretResponse, + api_model_config::{ApiModelConfig, AuthMethod, SamplesInput, SchemasInput}, + connection_model_definition::{ + ConnectionModelDefinition, CrudAction, PlatformInfo, TestConnection, + }, + create_secret_response::{CreateSecretAuthor, CreateSecretResponse}, + destination::Action, + environment::Environment, get_secret_request::GetSecretRequest, id::{prefix::IdPrefix, Id}, - IntegrationOSError, - { - api_model_config::{ApiModelConfig, AuthMethod, SamplesInput, SchemasInput}, - connection_model_definition::{ - ConnectionModelDefinition, CrudAction, PlatformInfo, TestConnection, - }, - destination::Action, - environment::Environment, - ownership::Ownership, - record_metadata::RecordMetadata, - settings::Settings, - Connection, ConnectionType, Pipeline, Throughput, - }, + ownership::Ownership, + record_metadata::RecordMetadata, + settings::Settings, + Connection, ConnectionType, IntegrationOSError, Pipeline, Throughput, }; use mockito::Server; use mongodb::Client; @@ -104,10 +101,7 @@ pub async fn seed_db(config: &EventCoreConfig, base_url: String) -> Id { id: Id::new_with_uuid(IdPrefix::Connection, ts, uuid), platform_version: "platformVersion".to_string(), connection_definition_id: Id::new_with_uuid(IdPrefix::ConnectionDefinition, ts, uuid), - r#type: ConnectionType::Api { - model_configs: vec![stripe_model_config], - oauth_configs: vec![], - }, + r#type: ConnectionType::Api, name: "name".to_string(), key: "key".into(), group: "group".to_string(), @@ -194,7 +188,14 @@ async fn test_send_to_destination() { _key: String, _value: &serde_json::Value, ) -> Result { - unimplemented!() + // FIXME: Created at SHOULD NOT be an f64 + Ok(CreateSecretResponse { + id: "id".into(), + buildable_id: "buildable_id".into(), + created_at: 0.0, + author: CreateSecretAuthor { id: "id".into() }, + encrypted_secret: "encrypted_secret".into(), + }) } } diff --git a/event-core/tests/mock_storage.rs b/event-core/tests/mock_storage.rs index f8b248d3..870ccf28 100644 --- a/event-core/tests/mock_storage.rs +++ b/event-core/tests/mock_storage.rs @@ -226,7 +226,7 @@ impl MockStorage { } #[tokio::test] -#[ignore = "Until we have a JWT token generated we can not test this"] +#[ignore = "Pipeline is not being used"] async fn run_dispatcher() { let mut event: Event = Faker.fake(); event.access_key = "id_live_1_abcd".to_owned();