Skip to content

Commit 81cd80d

Browse files
committed
fix clippy
1 parent 01a01ee commit 81cd80d

File tree

2 files changed

+43
-29
lines changed

2 files changed

+43
-29
lines changed

src/sinks/aws_kinesis/firehose/integration_tests.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use crate::{
1313
aws::{create_client, AwsAuthentication, ImdsAuthentication, RegionOrEndpoint},
1414
config::{ProxyConfig, SinkConfig, SinkContext},
1515
sinks::{
16-
elasticsearch::{BulkConfig, ElasticsearchAuth, ElasticsearchCommon, ElasticsearchConfig},
16+
elasticsearch::{
17+
BulkConfig, ElasticsearchAuthConfig, ElasticsearchCommon, ElasticsearchConfig,
18+
},
1719
util::{BatchConfig, Compression, TowerRequestConfig},
1820
},
1921
template::Template,
@@ -73,7 +75,7 @@ async fn firehose_put_records() {
7375
sleep(Duration::from_secs(5)).await;
7476

7577
let config = ElasticsearchConfig {
76-
auth: Some(ElasticsearchAuth::Aws(AwsAuthentication::Default {
78+
auth: Some(ElasticsearchAuthConfig::Aws(AwsAuthentication::Default {
7779
load_timeout_secs: Some(5),
7880
imds: ImdsAuthentication::default(),
7981
region: None,

src/sinks/elasticsearch/integration_tests.rs

+39-27
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{
1818
config::{ProxyConfig, SinkConfig, SinkContext},
1919
http::HttpClient,
2020
sinks::{
21-
util::{BatchConfig, Compression, SinkBatchSettings},
21+
util::{auth::Auth, BatchConfig, Compression, SinkBatchSettings},
2222
HealthcheckError,
2323
},
2424
test_util::{
@@ -58,14 +58,16 @@ impl ElasticsearchCommon {
5858
builder = builder.header(&header[..], &value[..]);
5959
}
6060

61-
if let Some(auth) = &self.http_auth {
62-
builder = auth.apply_builder(builder);
63-
}
64-
6561
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+
}
6971
}
7072

7173
let proxy = ProxyConfig::default();
@@ -251,12 +253,13 @@ async fn auto_version_http() {
251253
.expect("Config error");
252254
}
253255

256+
#[cfg(feature = "aws-core")]
254257
#[tokio::test]
255258
async fn auto_version_https() {
256259
trace_init();
257260

258261
let config = ElasticsearchConfig {
259-
auth: Some(ElasticsearchAuth::Basic {
262+
auth: Some(ElasticsearchAuthConfig::Basic {
260263
user: "elastic".to_string(),
261264
password: "vector".to_string().into(),
262265
}),
@@ -276,16 +279,19 @@ async fn auto_version_https() {
276279
.expect("Config error");
277280
}
278281

282+
#[cfg(feature = "aws-core")]
279283
#[tokio::test]
280284
async fn auto_version_aws() {
281285
trace_init();
282286

283287
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+
)),
289295
endpoints: vec![aws_server()],
290296
aws: Some(RegionOrEndpoint::with_region(String::from("localstack"))),
291297
api_version: ElasticsearchApiVersion::Auto,
@@ -358,7 +364,7 @@ async fn insert_events_over_https() {
358364

359365
run_insert_tests(
360366
ElasticsearchConfig {
361-
auth: Some(ElasticsearchAuth::Basic {
367+
auth: Some(ElasticsearchAuthConfig::Basic {
362368
user: "elastic".to_string(),
363369
password: "vector".to_string().into(),
364370
}),
@@ -378,17 +384,20 @@ async fn insert_events_over_https() {
378384
.await;
379385
}
380386

387+
#[cfg(feature = "aws-core")]
381388
#[tokio::test]
382389
async fn insert_events_on_aws() {
383390
trace_init();
384391

385392
run_insert_tests(
386393
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+
)),
392401
endpoints: vec![aws_server()],
393402
aws: Some(RegionOrEndpoint::with_region(String::from("localstack"))),
394403
api_version: ElasticsearchApiVersion::V6,
@@ -401,17 +410,20 @@ async fn insert_events_on_aws() {
401410
.await;
402411
}
403412

413+
#[cfg(feature = "aws-core")]
404414
#[tokio::test]
405415
async fn insert_events_on_aws_with_compression() {
406416
trace_init();
407417

408418
run_insert_tests(
409419
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+
)),
415427
endpoints: vec![aws_server()],
416428
aws: Some(RegionOrEndpoint::with_region(String::from("localstack"))),
417429
compression: Compression::gzip_default(),
@@ -498,7 +510,7 @@ async fn distributed_insert_events() {
498510

499511
// Assumes that behind https_server and http_server addresses lies the same server
500512
let mut config = ElasticsearchConfig {
501-
auth: Some(ElasticsearchAuth::Basic {
513+
auth: Some(ElasticsearchAuthConfig::Basic {
502514
user: "elastic".into(),
503515
password: "vector".to_string().into(),
504516
}),
@@ -524,7 +536,7 @@ async fn distributed_insert_events_failover() {
524536
trace_init();
525537

526538
let mut config = ElasticsearchConfig {
527-
auth: Some(ElasticsearchAuth::Basic {
539+
auth: Some(ElasticsearchAuthConfig::Basic {
528540
user: "elastic".into(),
529541
password: "vector".to_string().into(),
530542
}),

0 commit comments

Comments
 (0)