@@ -18,7 +18,7 @@ use crate::{
18
18
config:: { ProxyConfig , SinkConfig , SinkContext } ,
19
19
http:: HttpClient ,
20
20
sinks:: {
21
- util:: { BatchConfig , Compression , SinkBatchSettings } ,
21
+ util:: { auth :: Auth , BatchConfig , Compression , SinkBatchSettings } ,
22
22
HealthcheckError ,
23
23
} ,
24
24
test_util:: {
@@ -58,14 +58,16 @@ impl ElasticsearchCommon {
58
58
builder = builder. header ( & header[ ..] , & value[ ..] ) ;
59
59
}
60
60
61
- if let Some ( auth) = & self . http_auth {
62
- builder = auth. apply_builder ( builder) ;
63
- }
64
-
65
61
let mut request = builder. body ( Bytes :: new ( ) ) ?;
66
-
67
- if let Some ( credentials_provider) = & self . aws_auth {
68
- sign_request ( & mut request, credentials_provider, & self . region ) . await ?;
62
+ if let Some ( auth) = & self . auth {
63
+ match auth {
64
+ Auth :: Basic ( http_auth) => http_auth. apply ( & mut request) ,
65
+ #[ cfg( feature = "aws-core" ) ]
66
+ Auth :: Aws {
67
+ credentials_provider : provider,
68
+ region,
69
+ } => sign_request ( & mut request, provider, & Some ( region. clone ( ) ) ) . await ?,
70
+ }
69
71
}
70
72
71
73
let proxy = ProxyConfig :: default ( ) ;
@@ -251,12 +253,13 @@ async fn auto_version_http() {
251
253
. expect ( "Config error" ) ;
252
254
}
253
255
256
+ #[ cfg( feature = "aws-core" ) ]
254
257
#[ tokio:: test]
255
258
async fn auto_version_https ( ) {
256
259
trace_init ( ) ;
257
260
258
261
let config = ElasticsearchConfig {
259
- auth : Some ( ElasticsearchAuth :: Basic {
262
+ auth : Some ( ElasticsearchAuthConfig :: Basic {
260
263
user : "elastic" . to_string ( ) ,
261
264
password : "vector" . to_string ( ) . into ( ) ,
262
265
} ) ,
@@ -276,16 +279,19 @@ async fn auto_version_https() {
276
279
. expect ( "Config error" ) ;
277
280
}
278
281
282
+ #[ cfg( feature = "aws-core" ) ]
279
283
#[ tokio:: test]
280
284
async fn auto_version_aws ( ) {
281
285
trace_init ( ) ;
282
286
283
287
let config = ElasticsearchConfig {
284
- auth : Some ( ElasticsearchAuth :: Aws ( AwsAuthentication :: Default {
285
- load_timeout_secs : Some ( 5 ) ,
286
- imds : ImdsAuthentication :: default ( ) ,
287
- region : None ,
288
- } ) ) ,
288
+ auth : Some ( ElasticsearchAuthConfig :: Aws (
289
+ crate :: aws:: AwsAuthentication :: Default {
290
+ load_timeout_secs : Some ( 5 ) ,
291
+ imds : ImdsAuthentication :: default ( ) ,
292
+ region : None ,
293
+ } ,
294
+ ) ) ,
289
295
endpoints : vec ! [ aws_server( ) ] ,
290
296
aws : Some ( RegionOrEndpoint :: with_region ( String :: from ( "localstack" ) ) ) ,
291
297
api_version : ElasticsearchApiVersion :: Auto ,
@@ -358,7 +364,7 @@ async fn insert_events_over_https() {
358
364
359
365
run_insert_tests (
360
366
ElasticsearchConfig {
361
- auth : Some ( ElasticsearchAuth :: Basic {
367
+ auth : Some ( ElasticsearchAuthConfig :: Basic {
362
368
user : "elastic" . to_string ( ) ,
363
369
password : "vector" . to_string ( ) . into ( ) ,
364
370
} ) ,
@@ -378,17 +384,20 @@ async fn insert_events_over_https() {
378
384
. await ;
379
385
}
380
386
387
+ #[ cfg( feature = "aws-core" ) ]
381
388
#[ tokio:: test]
382
389
async fn insert_events_on_aws ( ) {
383
390
trace_init ( ) ;
384
391
385
392
run_insert_tests (
386
393
ElasticsearchConfig {
387
- auth : Some ( ElasticsearchAuth :: Aws ( AwsAuthentication :: Default {
388
- load_timeout_secs : Some ( 5 ) ,
389
- imds : ImdsAuthentication :: default ( ) ,
390
- region : None ,
391
- } ) ) ,
394
+ auth : Some ( ElasticsearchAuthConfig :: Aws (
395
+ crate :: aws:: AwsAuthentication :: Default {
396
+ load_timeout_secs : Some ( 5 ) ,
397
+ imds : ImdsAuthentication :: default ( ) ,
398
+ region : None ,
399
+ } ,
400
+ ) ) ,
392
401
endpoints : vec ! [ aws_server( ) ] ,
393
402
aws : Some ( RegionOrEndpoint :: with_region ( String :: from ( "localstack" ) ) ) ,
394
403
api_version : ElasticsearchApiVersion :: V6 ,
@@ -401,17 +410,20 @@ async fn insert_events_on_aws() {
401
410
. await ;
402
411
}
403
412
413
+ #[ cfg( feature = "aws-core" ) ]
404
414
#[ tokio:: test]
405
415
async fn insert_events_on_aws_with_compression ( ) {
406
416
trace_init ( ) ;
407
417
408
418
run_insert_tests (
409
419
ElasticsearchConfig {
410
- auth : Some ( ElasticsearchAuth :: Aws ( AwsAuthentication :: Default {
411
- load_timeout_secs : Some ( 5 ) ,
412
- imds : ImdsAuthentication :: default ( ) ,
413
- region : None ,
414
- } ) ) ,
420
+ auth : Some ( ElasticsearchAuthConfig :: Aws (
421
+ crate :: aws:: AwsAuthentication :: Default {
422
+ load_timeout_secs : Some ( 5 ) ,
423
+ imds : ImdsAuthentication :: default ( ) ,
424
+ region : None ,
425
+ } ,
426
+ ) ) ,
415
427
endpoints : vec ! [ aws_server( ) ] ,
416
428
aws : Some ( RegionOrEndpoint :: with_region ( String :: from ( "localstack" ) ) ) ,
417
429
compression : Compression :: gzip_default ( ) ,
@@ -498,7 +510,7 @@ async fn distributed_insert_events() {
498
510
499
511
// Assumes that behind https_server and http_server addresses lies the same server
500
512
let mut config = ElasticsearchConfig {
501
- auth : Some ( ElasticsearchAuth :: Basic {
513
+ auth : Some ( ElasticsearchAuthConfig :: Basic {
502
514
user : "elastic" . into ( ) ,
503
515
password : "vector" . to_string ( ) . into ( ) ,
504
516
} ) ,
@@ -524,7 +536,7 @@ async fn distributed_insert_events_failover() {
524
536
trace_init ( ) ;
525
537
526
538
let mut config = ElasticsearchConfig {
527
- auth : Some ( ElasticsearchAuth :: Basic {
539
+ auth : Some ( ElasticsearchAuthConfig :: Basic {
528
540
user : "elastic" . into ( ) ,
529
541
password : "vector" . to_string ( ) . into ( ) ,
530
542
} ) ,
0 commit comments