@@ -145,15 +145,19 @@ fn create_request(
145
145
path : & str ,
146
146
headers : Option < HashMap < & ' static str , String > > ,
147
147
payload : Option < serde_json:: Value > ,
148
- settings : Option < & Settings >
148
+ settings : Option < & Settings > ,
149
149
) -> test:: TestRequest {
150
150
let test_settings = get_test_settings ( ) ;
151
151
let settings = settings. unwrap_or ( & test_settings) ;
152
152
let mut req = test:: TestRequest :: with_uri ( path)
153
153
. method ( method. clone ( ) )
154
154
. insert_header ( (
155
155
"Authorization" ,
156
- create_hawk_header ( method. as_str ( ) , settings. port , & ( ReverseProxyState :: from_settings ( & settings) . get_webroot ( ) + path) ) ,
156
+ create_hawk_header (
157
+ method. as_str ( ) ,
158
+ settings. port ,
159
+ & ( ReverseProxyState :: from_settings ( & settings) . get_webroot ( ) + path) ,
160
+ ) ,
157
161
) )
158
162
. insert_header ( ( "Accept" , "application/json" ) )
159
163
. insert_header ( (
@@ -237,9 +241,7 @@ async fn test_endpoint(
237
241
238
242
let app = match settings. clone ( ) {
239
243
None => init_app ! ( ) . await ,
240
- Some ( settings) => {
241
- init_app ! ( settings) . await
242
- }
244
+ Some ( settings) => init_app ! ( settings) . await ,
243
245
} ;
244
246
245
247
let req = create_request ( & method, path, None , None , settings. as_ref ( ) ) . to_request ( ) ;
@@ -539,7 +541,7 @@ async fn invalid_content_type() {
539
541
540
542
let mut headers = HashMap :: new ( ) ;
541
543
headers. insert ( "Content-Type" , "application/javascript" . to_owned ( ) ) ;
542
- let req = create_request (
544
+ let req = create_request (
543
545
& http:: Method :: PUT ,
544
546
path,
545
547
Some ( headers. clone ( ) ) ,
@@ -709,8 +711,14 @@ async fn reject_old_ios() {
709
711
#[ actix_rt:: test]
710
712
async fn info_configuration_xlm ( ) {
711
713
let app = init_app ! ( ) . await ;
712
- let req =
713
- create_request ( & http:: Method :: GET , "/1.5/42/info/configuration" , None , None , None ) . to_request ( ) ;
714
+ let req = create_request (
715
+ & http:: Method :: GET ,
716
+ "/1.5/42/info/configuration" ,
717
+ None ,
718
+ None ,
719
+ None ,
720
+ )
721
+ . to_request ( ) ;
714
722
let response = app. call ( req) . await . unwrap ( ) ;
715
723
assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
716
724
let xlm = response. headers ( ) . get ( X_LAST_MODIFIED ) ;
@@ -734,7 +742,14 @@ async fn overquota() {
734
742
let app = init_app ! ( settings) . await ;
735
743
736
744
// Clear out any data that's already in the store.
737
- let req = create_request ( & http:: Method :: DELETE , "/1.5/42/storage" , None , None , Some ( & settings) ) . to_request ( ) ;
745
+ let req = create_request (
746
+ & http:: Method :: DELETE ,
747
+ "/1.5/42/storage" ,
748
+ None ,
749
+ None ,
750
+ Some ( & settings) ,
751
+ )
752
+ . to_request ( ) ;
738
753
let resp = app. call ( req) . await . unwrap ( ) ;
739
754
assert ! ( resp. response( ) . status( ) . is_success( ) ) ;
740
755
@@ -785,7 +800,14 @@ async fn overquota() {
785
800
786
801
// XXX: this should run as cleanup regardless of test failure but it's
787
802
// difficult. e.g. FutureExt::catch_unwind isn't compatible w/ actix-web
788
- let req = create_request ( & http:: Method :: DELETE , "/1.5/42/storage" , None , None , Some ( & settings) ) . to_request ( ) ;
803
+ let req = create_request (
804
+ & http:: Method :: DELETE ,
805
+ "/1.5/42/storage" ,
806
+ None ,
807
+ None ,
808
+ Some ( & settings) ,
809
+ )
810
+ . to_request ( ) ;
789
811
let resp = app. call ( req) . await . unwrap ( ) ;
790
812
assert ! ( resp. response( ) . status( ) . is_success( ) ) ;
791
813
}
@@ -798,7 +820,14 @@ async fn lbheartbeat_max_pool_size_check() {
798
820
let app = init_app ! ( settings) . await ;
799
821
800
822
// Test all is well.
801
- let lb_req = create_request ( & http:: Method :: GET , "/__lbheartbeat__" , None , None , Some ( & settings) ) . to_request ( ) ;
823
+ let lb_req = create_request (
824
+ & http:: Method :: GET ,
825
+ "/__lbheartbeat__" ,
826
+ None ,
827
+ None ,
828
+ Some ( & settings) ,
829
+ )
830
+ . to_request ( ) ;
802
831
let sresp = app. call ( lb_req) . await . unwrap ( ) ;
803
832
let status = sresp. status ( ) ;
804
833
// dbg!(status, test::read_body(sresp).await);
@@ -823,8 +852,14 @@ async fn lbheartbeat_max_pool_size_check() {
823
852
824
853
// check duration for exhausted connections
825
854
actix_rt:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
826
- let req =
827
- create_request ( & http:: Method :: GET , "/__lbheartbeat__" , Some ( headers) , None , Some ( & settings) ) . to_request ( ) ;
855
+ let req = create_request (
856
+ & http:: Method :: GET ,
857
+ "/__lbheartbeat__" ,
858
+ Some ( headers) ,
859
+ None ,
860
+ Some ( & settings) ,
861
+ )
862
+ . to_request ( ) ;
828
863
let sresp = app. call ( req) . await . unwrap ( ) ;
829
864
let status = sresp. status ( ) ;
830
865
let body = test:: read_body ( sresp) . await ;
@@ -838,8 +873,14 @@ async fn lbheartbeat_max_pool_size_check() {
838
873
let mut headers: HashMap < & str , String > = HashMap :: new ( ) ;
839
874
headers. insert ( "TEST_CONNECTIONS" , "5" . to_owned ( ) ) ;
840
875
headers. insert ( "TEST_IDLES" , "5" . to_owned ( ) ) ;
841
- let req =
842
- create_request ( & http:: Method :: GET , "/__lbheartbeat__" , Some ( headers) , None , Some ( & settings) ) . to_request ( ) ;
876
+ let req = create_request (
877
+ & http:: Method :: GET ,
878
+ "/__lbheartbeat__" ,
879
+ Some ( headers) ,
880
+ None ,
881
+ Some ( & settings) ,
882
+ )
883
+ . to_request ( ) ;
843
884
let sresp = app. call ( req) . await . unwrap ( ) ;
844
885
let status = sresp. status ( ) ;
845
886
// dbg!(status, test::read_body(sresp).await);
@@ -854,13 +895,27 @@ async fn lbheartbeat_ttl_check() {
854
895
855
896
let app = init_app ! ( settings) . await ;
856
897
857
- let lb_req = create_request ( & http:: Method :: GET , "/__lbheartbeat__" , None , None , Some ( & settings) ) . to_request ( ) ;
898
+ let lb_req = create_request (
899
+ & http:: Method :: GET ,
900
+ "/__lbheartbeat__" ,
901
+ None ,
902
+ None ,
903
+ Some ( & settings) ,
904
+ )
905
+ . to_request ( ) ;
858
906
let sresp = app. call ( lb_req) . await . unwrap ( ) ;
859
907
assert ! ( sresp. status( ) . is_success( ) ) ;
860
908
861
909
actix_rt:: time:: sleep ( Duration :: from_secs ( 3 ) ) . await ;
862
910
863
- let lb_req = create_request ( & http:: Method :: GET , "/__lbheartbeat__" , None , None , Some ( & settings) ) . to_request ( ) ;
911
+ let lb_req = create_request (
912
+ & http:: Method :: GET ,
913
+ "/__lbheartbeat__" ,
914
+ None ,
915
+ None ,
916
+ Some ( & settings) ,
917
+ )
918
+ . to_request ( ) ;
864
919
let sresp = app. call ( lb_req) . await . unwrap ( ) ;
865
920
assert_eq ! ( sresp. status( ) , StatusCode :: INTERNAL_SERVER_ERROR ) ;
866
921
}
0 commit comments