diff --git a/Cargo.lock b/Cargo.lock index f967b622..c995eff1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,7 +110,7 @@ dependencies = [ "log", "mime", "percent-encoding", - "pin-project 1.0.6", + "pin-project 1.0.7", "rand 0.7.3", "regex", "serde 1.0.125", @@ -292,7 +292,7 @@ dependencies = [ "fxhash", "log", "mime", - "pin-project 1.0.6", + "pin-project 1.0.7", "regex", "serde 1.0.125", "serde_json", @@ -429,10 +429,10 @@ dependencies = [ [[package]] name = "argon2-creds" version = "0.2.1" -source = "git+https://github.com/realaravinth/argon2-creds#99c1769430fbf6b420c063fc0de25a7e84086c6a" +source = "git+https://github.com/realaravinth/argon2-creds#11b490b78c1b4693607b47124e1c0e4718f290f4" dependencies = [ "ammonia", - "derive_builder 0.9.0", + "derive_builder 0.10.2", "derive_more", "lazy_static", "rand 0.8.3", @@ -456,9 +456,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "async-trait" -version = "0.1.48" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf" +checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" dependencies = [ "proc-macro2", "quote", @@ -602,9 +602,9 @@ dependencies = [ [[package]] name = "build_const" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" +checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" @@ -641,11 +641,11 @@ dependencies = [ [[package]] name = "cache-buster" -version = "0.1.0" -source = "git+https://github.com/realaravinth/cache-buster#71d5ef67a2788789922eaa484e10269acbaeb8a7" +version = "0.2.0" +source = "git+https://github.com/realaravinth/cache-buster#874dec8180613b6dc654f82c6ef2f6660ec974e6" dependencies = [ "data-encoding", - "derive_builder 0.10.0", + "derive_builder 0.10.2", "mime", "mime_guess", "serde 1.0.125", @@ -721,9 +721,9 @@ dependencies = [ [[package]] name = "const_fn" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076a6803b0dacd6a88cfe64deba628b01533ff5ef265687e6938280c1afd0a28" +checksum = "402da840495de3f976eaefc3485b7f5eb5b0bf9761f9a47be27fe975b3b8c2ec" [[package]] name = "constant_time_eq" @@ -802,12 +802,12 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.3", + "crossbeam-utils 0.8.4", ] [[package]] @@ -817,7 +817,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f6cb3c7f5b8e51bc3ebb73a2327ad4abdbd119dc13223f14f961d2f38486756" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.3", + "crossbeam-utils 0.8.4", ] [[package]] @@ -833,9 +833,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" dependencies = [ "autocfg", "cfg-if 1.0.0", @@ -873,12 +873,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d6ddad5866bb2170686ed03f6839d31a76e5407d80b1c334a2c24618543ffa" +checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c" dependencies = [ - "darling_core 0.12.3", - "darling_macro 0.12.3", + "darling_core 0.12.4", + "darling_macro 0.12.4", ] [[package]] @@ -897,9 +897,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ced1fd13dc386d5a8315899de465708cf34ee2a6d9394654515214e67bb846" +checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36" dependencies = [ "fnv", "ident_case", @@ -922,11 +922,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a7a1445d54b2f9792e3b31a3e715feabbace393f38dc4ffd49d94ee9bc487d5" +checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a" dependencies = [ - "darling_core 0.12.3", + "darling_core 0.12.4", "quote", "syn", ] @@ -952,11 +952,10 @@ dependencies = [ [[package]] name = "derive_builder" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ef25735c9f0d0c547d2794701600c94abf030ecb740fad1673fa64461f3573" +checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30" dependencies = [ - "derive_builder_core 0.10.0", "derive_builder_macro", ] @@ -974,11 +973,11 @@ dependencies = [ [[package]] name = "derive_builder_core" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3150f1e84602847b99d3eeb702487fc364f7d6c94f634e944a68fdbaea09e457" +checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5" dependencies = [ - "darling 0.12.3", + "darling 0.12.4", "proc-macro2", "quote", "syn", @@ -986,11 +985,11 @@ dependencies = [ [[package]] name = "derive_builder_macro" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca1008bddefdc08d1e734aeb27b94f384390af261b4d1a8fb51fe19c577f05c" +checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73" dependencies = [ - "derive_builder_core 0.10.0", + "derive_builder_core 0.10.2", "syn", ] @@ -1301,7 +1300,7 @@ dependencies = [ "argon2-creds", "cache-buster", "config", - "derive_builder 0.10.0", + "derive_builder 0.10.2", "derive_more", "futures", "lazy_static", @@ -1452,9 +1451,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.3.6" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc35c995b9d93ec174cf9a27d425c7892722101e14993cd227fdb51d70cf9589" +checksum = "4a1ce40d6fc9764887c2fdc7305c3dcc429ba11ff981c1509416afd5697e4437" [[package]] name = "humantime" @@ -1473,9 +1472,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" dependencies = [ "matches", "unicode-bidi", @@ -1573,9 +1572,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lexical-core" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21f866863575d0e1d654fbeeabdc927292fdf862873dc3c96c6f753357e13374" +checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" dependencies = [ "arrayvec", "bitflags", @@ -1586,9 +1585,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "linked-hash-map" @@ -1653,16 +1652,13 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "markup5ever" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae38d669396ca9b707bfc3db254bc382ddb94f57cc5c235f34623a669a01dab" +checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" dependencies = [ "log", "phf", "phf_codegen", - "serde 1.0.125", - "serde_derive", - "serde_json", "string_cache", "string_cache_codegen", "tendril", @@ -1953,11 +1949,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc174859768806e91ae575187ada95c91a29e96a98dc5d2cd9a1fed039501ba6" +checksum = "c7509cc106041c40a4518d2af7a61530e1eed0e6285296a3d8c5472806ccc4a4" dependencies = [ - "pin-project-internal 1.0.6", + "pin-project-internal 1.0.7", ] [[package]] @@ -1973,9 +1969,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a490329918e856ed1b083f244e3bfe2d8c4f336407e4ea9e1a9f479ff09049e5" +checksum = "48c950132583b500556b1efd71d45b319029f2b71518d979fcc208e16b42426f" dependencies = [ "proc-macro2", "quote", @@ -2017,7 +2013,7 @@ version = "0.2.1" source = "git+https://github.com/mcaptcha/pow_sha256#f97858cd639fa2f807603d2515a6ae09191629cd" dependencies = [ "bincode", - "derive_builder 0.10.0", + "derive_builder 0.10.2", "serde 1.0.125", "sha2", ] @@ -2203,18 +2199,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +checksum = "85dd92e586f7355c633911e11f77f3d12f04b1b1bd76a198bd34ae3af8341ef2" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.4.5" +version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" dependencies = [ "aho-corasick", "memchr", @@ -2261,7 +2257,7 @@ dependencies = [ "base64 0.13.0", "blake2b_simd", "constant_time_eq", - "crossbeam-utils 0.8.3", + "crossbeam-utils 0.8.4", ] [[package]] @@ -2385,9 +2381,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "sct" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" dependencies = [ "ring", "untrusted", @@ -2549,9 +2545,9 @@ checksum = "cbce6d4507c7e4a3962091436e56e95290cb71fa302d0d270e32130b75fbff27" [[package]] name = "slab" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" [[package]] name = "smallvec" @@ -2612,9 +2608,9 @@ dependencies = [ "byteorder", "bytes 0.5.6", "crc", - "crossbeam-channel 0.5.0", + "crossbeam-channel 0.5.1", "crossbeam-queue", - "crossbeam-utils 0.8.3", + "crossbeam-utils 0.8.4", "either", "futures-channel", "futures-core", @@ -2798,9 +2794,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.69" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" +checksum = "ad184cc9470f9117b2ac6817bfe297307418819ba40552f9b3846f05c33d5373" dependencies = [ "proc-macro2", "quote", @@ -3022,7 +3018,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" dependencies = [ - "pin-project 1.0.6", + "pin-project 1.0.7", "tracing", ] @@ -3112,9 +3108,9 @@ checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "unicode_categories" @@ -3152,9 +3148,9 @@ dependencies = [ [[package]] name = "utf-8" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "validator" diff --git a/Cargo.toml b/Cargo.toml index 296f58e1..8b7130ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ actix-cors= "0.5.4" mime_guess = "2.0.3" rust-embed = "5.9.0" -cache-buster = { version = "0.1", git = "https://github.com/realaravinth/cache-buster" } +cache-buster = { version = "0.2.0", git = "https://github.com/realaravinth/cache-buster" } futures = "0.3.14" @@ -68,7 +68,7 @@ sailfish = "0.3.2" serde_yaml = "0.8.17" serde_json = "1" yaml-rust = "0.4.5" -cache-buster = { version = "0.1", git = "https://github.com/realaravinth/cache-buster" } +cache-buster = { version = "0.2.0", git = "https://github.com/realaravinth/cache-buster" } mime = "0.3.16" [dev-dependencies] diff --git a/build.rs b/build.rs index e14b6343..77d28a8f 100644 --- a/build.rs +++ b/build.rs @@ -55,5 +55,5 @@ fn cache_bust() { .build() .unwrap(); - config.process().unwrap().to_env(); + config.process().unwrap(); } diff --git a/src/api/v1/auth.rs b/src/api/v1/auth.rs index b2250d94..209fbac0 100644 --- a/src/api/v1/auth.rs +++ b/src/api/v1/auth.rs @@ -62,7 +62,7 @@ pub async fn signup( // } if let Some(email) = &payload.email { - data.creds.email(Some(&email))?; + data.creds.email(&email)?; } let mut secret; @@ -223,7 +223,7 @@ pub async fn set_email( let username = id.identity().unwrap(); - data.creds.email(Some(&payload.email))?; + data.creds.email(&payload.email)?; let res = sqlx::query!( "UPDATE mcaptcha_users set email = $1 diff --git a/src/cache_buster_data.json b/src/cache_buster_data.json new file mode 100644 index 00000000..f59f62bc --- /dev/null +++ b/src/cache_buster_data.json @@ -0,0 +1 @@ +{"map":{"./static/img/svg/github.svg":"./prod/img/svg/github.FA9EB1C66F548EC2C7598B94BA6A17275E1EA383D42B6C83351A2388C773E621.svg","./static/img/svg/globe.svg":"./prod/img/svg/globe.44C2A069EBD637663E938ECE7B8E4EC2A8BDE049A8A044EC68D9CB69AE8C592E.svg","./static/img/svg/message-square.svg":"./prod/img/svg/message-square.E246A6B2AAEFCE8A62B9BDD2D155D3B4923C3E48325EAEF099D509A2D7BB4DD1.svg","./static/img/svg/shield.svg":"./prod/img/svg/shield.13AFE15DCB4882B4A940CFDC3E2088A733CD4E6F97F25B211D87C7C9D6DBA2B6.svg","./static/img/svg/filter.svg":"./prod/img/svg/filter.6D5FBD96BA2E2020663AAC4994A991295917D73F3592C07EE103647B655A2275.svg","./static/img/svg/moon.svg":"./prod/img/svg/moon.1E151D68949CA3B2DC7DE34BC25B7586E4175AC3BA7F56DDBB34227334EF7155.svg","./static/img/svg/toggle-left.svg":"./prod/img/svg/toggle-left.E421950C5922E84015F0A86F272AE5637A2ED96E267D2C962543F5994E5D1172.svg","./static/img/svg/menu.svg":"./prod/img/svg/menu.A2C4DD00686F5D23F78885AC4CE3E075FCA78DFBDEA70407667FBBD9801B7A75.svg","./static/img/icon.png":"./prod/img/icon.CC75A040D5F432E5DC9043D10B94BF1FC3BAE1D02A8C2030F655E642EAD4A32C.png","./static/img/svg/key.svg":"./prod/img/svg/key.F0AACBED8D0F7A279977392F92F4DA73C35E905AC73B3C83320D54856E627EEC.svg","./static/img/svg/help-circle.svg":"./prod/img/svg/help-circle.BE230ABD2E05EB05EF6C5B7D04D35A3A43637EF1E046DEF3D244425609B99F81.svg","./static/img/svg/file.svg":"./prod/img/svg/file.F9E376D9F78FFD918D8D592A8B2D97EAAC14E638B5A7AE3C58DDB075375D8E0E.svg","./static/img/icon-trans.png":"./prod/img/icon-trans.7920418313D84DCDB2491E02E52E4BEF374970C216E85BD721274EE51241ECD4.png","./static/img/svg/shield-off.svg":"./prod/img/svg/shield-off.85394A6AD92D550F8EBA72AAB095E078E7A0E3359DF81174532C8D1AF53B5876.svg","./static/img/svg/eye-off.svg":"./prod/img/svg/eye-off.939360B335D1D35B57C3E2070129D14ABB168E4AC137B5BE4F6F8BD450B712F5.svg","./static/img/svg/credit-card.svg":"./prod/img/svg/credit-card.DF612AFE367A7B31410F2F6CD3C7B515B0F1889C0107EA695D840DFFA492E07D.svg","./static/img/svg/settings.svg":"./prod/img/svg/settings.910C6241743C9C694141971BE8E1C4016A1A5BF203E4E9D676D4CE93BD518F4C.svg","./static/img/svg/user.svg":"./prod/img/svg/user.B164ECD2C4A09DC5189F1F252487E2AC6A33646BEA67AF9C528CDA61FE5E146F.svg","./static/img/svg/toggle-right.svg":"./prod/img/svg/toggle-right.15BF49887941593CE3FE09FA73E3CAF1F4B1E8ABCB42A23D85B4FCBC24FDF5AA.svg","./static/img/svg/eye.svg":"./prod/img/svg/eye.9DE4D24D3C9B055D02B94A8AD65E8C0C644852381FDD131A64448B6DA7859167.svg","./static/img/svg/tag.svg":"./prod/img/svg/tag.E0BC111B8E81BBFC62B6A9E7E4AC162B7085A6543D995B7A0030CB7632901BD4.svg","./static/bundle/main.css":"./prod/bundle/main.C7B0ACE647935B5E61BD692A0EB6AFF167CAB2F80483079378CF7A18D7FF9466.css","./static/img/svg/file-text.svg":"./prod/img/svg/file-text.CF57DF252051E7E81C240D36AF1DB8A9DDAF282F9A5E8C338408FE88A6545A02.svg","./static/bundle/main.js":"./prod/bundle/main.736EA02160A042CFB6310C65CB61D8F2578A457254FBDBD1F00009320D8BF903.js","./static/img/svg/bell.svg":"./prod/img/svg/bell.9DA292704EE9907EFDB870F4510C97336977CA27FBFAAD83CF46F8E22D3828F7.svg","./static/img/svg/home.svg":"./prod/img/svg/home.28C26C2D3E4013D24D755A589A80D8DD5C49DA5397032E3F09B76BC3A2C314ED.svg","./static/img/svg/log-out.svg":"./prod/img/svg/log-out.92AB4384FD41D9AFE4735C480361BB64789CD767B7DD0FF3C6F56287B3D4498E.svg"},"base_dir":"./prod"} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index a84f635a..3addae19 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,10 @@ pub use settings::Settings; lazy_static! { pub static ref SETTINGS: Settings = Settings::new().unwrap(); pub static ref S: String = env::var("S").unwrap(); - pub static ref FILES: FileMap = FileMap::load(); + pub static ref FILES: FileMap = { + let map = include_str!("cache_buster_data.json"); + FileMap::new(&map) + }; pub static ref JS: &'static str = FILES.get("./static/bundle/main.js").unwrap(); pub static ref CSS: &'static str = FILES.get("./static/bundle/main.css").unwrap(); } diff --git a/src/static_assets.rs b/src/static_assets.rs index 08cdd439..193c25ba 100644 --- a/src/static_assets.rs +++ b/src/static_assets.rs @@ -50,23 +50,23 @@ pub fn services(cfg: &mut web::ServiceConfig) { cfg.service(dist); } -//#[cfg(test)] -//mod tests { -// use actix_web::http::StatusCode; -// use actix_web::test; -// -// use super::*; -// use crate::*; -// -// #[actix_rt::test] -// async fn static_assets_work() { -// let mut app = test::init_service(App::new().configure(services)).await; -// -// let resp = test::call_service( -// &mut app, -// test::TestRequest::get().uri(&*crate::JS).to_request(), -// ) -// .await; -// assert_eq!(resp.status(), StatusCode::OK); -// } -//} +#[cfg(test)] +mod tests { + use actix_web::http::StatusCode; + use actix_web::test; + + use super::*; + use crate::*; + + #[actix_rt::test] + async fn static_assets_work() { + let mut app = test::init_service(App::new().configure(services)).await; + + let resp = test::call_service( + &mut app, + test::TestRequest::get().uri(&*crate::JS).to_request(), + ) + .await; + assert_eq!(resp.status(), StatusCode::OK); + } +} diff --git a/src/templates/mod.rs b/src/templates/mod.rs index 4a7b300e..9ea40217 100644 --- a/src/templates/mod.rs +++ b/src/templates/mod.rs @@ -29,24 +29,28 @@ pub fn services(cfg: &mut ServiceConfig) { cfg.service(panel::sitekey::add_sitekey); } -//#[cfg(not(tarpaulin_include))] -//#[cfg(test)] -//mod tests { -// use actix_web::http::StatusCode; -// use actix_web::test; -// -// use super::*; -// use crate::*; -// -// #[actix_rt::test] -// async fn templates_work() { -// let mut app = test::init_service(App::new().configure(services)).await; -// let urls = vec!["/", "/join", "/panel"]; -// -// for url in urls.iter() { -// let resp = -// test::call_service(&mut app, test::TestRequest::get().uri(url).to_request()).await; -// assert_eq!(resp.status(), StatusCode::OK); -// } -// } -//} +#[cfg(not(tarpaulin_include))] +#[cfg(test)] +mod tests { + use actix_web::http::StatusCode; + use actix_web::test; + + use super::*; + use crate::*; + + #[actix_rt::test] + async fn templates_work() { + let mut app = test::init_service(App::new().configure(services)).await; + let urls = vec!["/", "/join", "/login", "/sitekey/add"]; + + for url in urls.iter() { + let resp = + test::call_service(&mut app, test::TestRequest::get().uri(url).to_request()).await; + if url == urls.get(0).unwrap() { + assert_eq!(resp.status(), StatusCode::TEMPORARY_REDIRECT); + } else { + assert_eq!(resp.status(), StatusCode::OK); + } + } + } +}