Skip to content

Commit c33f230

Browse files
cargo fmt
1 parent ff751dd commit c33f230

File tree

3 files changed

+170
-53
lines changed

3 files changed

+170
-53
lines changed

src/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ use rabbitmq_http_client::commons::{ExchangeType, SupportedProtocol};
2727
use rabbitmq_http_client::commons::{MessageTransferAcknowledgementMode, UserLimitTarget};
2828
use rabbitmq_http_client::commons::{PolicyTarget, VirtualHostLimitTarget};
2929
use rabbitmq_http_client::password_hashing::{HashingAlgorithm, HashingError};
30+
use rabbitmq_http_client::requests::shovels::OwnedShovelParams;
3031
use rabbitmq_http_client::requests::{
3132
Amqp10ShovelDestinationParams, Amqp10ShovelParams, Amqp10ShovelSourceParams,
3233
Amqp091ShovelDestinationParams, Amqp091ShovelParams, Amqp091ShovelSourceParams,
3334
DEFAULT_FEDERATION_PREFETCH, EnforcedLimitParams, ExchangeFederationParams,
3435
FEDERATION_UPSTREAM_COMPONENT, FederationResourceCleanupMode, FederationUpstreamParams,
3536
PolicyParams, QueueFederationParams, RuntimeParameterDefinition,
3637
};
37-
use rabbitmq_http_client::requests::shovels::OwnedShovelParams;
3838

3939
use rabbitmq_http_client::transformers::{TransformationChain, VirtualHostTransformationChain};
4040
use rabbitmq_http_client::{password_hashing, requests, responses};

tests/shovel_destination_uri_modification_tests.rs

Lines changed: 69 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use predicates::prelude::*;
1919
use std::str;
2020

2121
#[test]
22-
fn test_disable_tls_peer_verification_for_all_destination_uris_basic() -> Result<(), Box<dyn std::error::Error>> {
22+
fn test_disable_tls_peer_verification_for_all_destination_uris_basic()
23+
-> Result<(), Box<dyn std::error::Error>> {
2324
let vh = "test_disable_tls_peer_verification_for_all_destination_uris_basic";
2425
let shovel_name = "test_basic_dest_shovel";
2526

@@ -67,7 +68,8 @@ fn test_disable_tls_peer_verification_for_all_destination_uris_basic() -> Result
6768
#[test]
6869
fn test_disable_tls_peer_verification_for_all_destination_uris_with_existing_verify_param()
6970
-> Result<(), Box<dyn std::error::Error>> {
70-
let vh = "test_disable_tls_peer_verification_for_all_destination_uris_with_existing_verify_param";
71+
let vh =
72+
"test_disable_tls_peer_verification_for_all_destination_uris_with_existing_verify_param";
7173
let shovel_name = "test_existing_dest_shovel";
7274

7375
delete_vhost(vh).ok();
@@ -106,14 +108,19 @@ fn test_disable_tls_peer_verification_for_all_destination_uris_with_existing_ver
106108
]);
107109

108110
let output = run_succeeds(["parameters", "list_all"]);
109-
let stdout = output.stdout(predicate::str::contains(shovel_name))
111+
let stdout = output
112+
.stdout(predicate::str::contains(shovel_name))
110113
.stdout(predicate::str::contains("verify=verify_none"))
111114
.stdout(predicate::str::contains("dest_key1=xyz"))
112115
.stdout(predicate::str::contains("dest_key2=abc"))
113116
.stdout(predicate::str::contains("cacertfile=/path/to/dest_ca.pem"))
114-
.stdout(predicate::str::contains("certfile=/path/to/dest_client.pem"))
117+
.stdout(predicate::str::contains(
118+
"certfile=/path/to/dest_client.pem",
119+
))
115120
.stdout(predicate::str::contains("keyfile=/path/to/dest_client.key"))
116-
.stdout(predicate::str::contains("server_name_indication=dest.example.com"))
121+
.stdout(predicate::str::contains(
122+
"server_name_indication=dest.example.com",
123+
))
117124
.stdout(predicate::str::contains("dest_param=value456"))
118125
.stdout(predicate::str::contains("another_dest_param=def"))
119126
.stdout(predicate::str::contains("heartbeat=30"));
@@ -130,39 +137,59 @@ fn test_disable_tls_peer_verification_for_all_destination_uris_with_existing_ver
130137
if in_our_shovel {
131138
shovel_section.push_str(line);
132139
shovel_section.push('\n');
133-
if line.contains("└─") || (in_our_shovel && line.contains("├─") && !line.contains(&shovel_name)) {
140+
if line.contains("└─")
141+
|| (in_our_shovel && line.contains("├─") && !line.contains(&shovel_name))
142+
{
134143
break;
135144
}
136145
}
137146
}
138147

139-
let dest_uri_lines: Vec<&str> = shovel_section.lines()
148+
let dest_uri_lines: Vec<&str> = shovel_section
149+
.lines()
140150
.filter(|line| line.contains("dest-uri"))
141151
.collect();
142-
assert!(!dest_uri_lines.is_empty(), "Could not find dest-uri in shovel section");
152+
assert!(
153+
!dest_uri_lines.is_empty(),
154+
"Could not find dest-uri in shovel section"
155+
);
143156

144157
let dest_uri_content = dest_uri_lines[0];
145158
let dest_verify_count = dest_uri_content.matches("verify=").count();
146-
assert_eq!(dest_verify_count, 1, "Expected exactly 1 verify parameter in destination URI, found {}", dest_verify_count);
159+
assert_eq!(
160+
dest_verify_count, 1,
161+
"Expected exactly 1 verify parameter in destination URI, found {}",
162+
dest_verify_count
163+
);
147164

148-
assert!(dest_uri_content.contains("verify=verify_none"), "Destination URI should contain verify=verify_none");
149-
assert!(!dest_uri_content.contains("verify=verify_peer"), "Destination URI should not contain verify=verify_peer");
165+
assert!(
166+
dest_uri_content.contains("verify=verify_none"),
167+
"Destination URI should contain verify=verify_none"
168+
);
169+
assert!(
170+
!dest_uri_content.contains("verify=verify_peer"),
171+
"Destination URI should not contain verify=verify_peer"
172+
);
150173

151174
delete_vhost(vh).expect("failed to delete a virtual host");
152175

153176
Ok(())
154177
}
155178

156179
#[test]
157-
fn test_disable_tls_peer_verification_for_all_destination_uris_amqp10() -> Result<(), Box<dyn std::error::Error>> {
180+
fn test_disable_tls_peer_verification_for_all_destination_uris_amqp10()
181+
-> Result<(), Box<dyn std::error::Error>> {
158182
let vh = "test_disable_tls_peer_verification_for_all_destination_uris_amqp10";
159183
let shovel_name = "test_amqp10_dest_shovel";
160184

161185
delete_vhost(vh).ok();
162186
run_succeeds(["declare", "vhost", "--name", vh]);
163187

164188
let amqps_source = format!("amqps://localhost:5671/{}", vh);
165-
let amqps_destination = format!("amqps://localhost:5671/{}?verify=verify_peer&certfile=/path/to/client.pem", vh);
189+
let amqps_destination = format!(
190+
"amqps://localhost:5671/{}?verify=verify_peer&certfile=/path/to/client.pem",
191+
vh
192+
);
166193

167194
run_succeeds([
168195
"-V",
@@ -211,7 +238,10 @@ fn test_disable_tls_peer_verification_for_all_destination_uris_with_dummy_query_
211238

212239
let amqps_base = format!("amqps://localhost:5671/{}", vh);
213240
let source_uri = format!("{}?source_abc=123&source_heartbeat=5", amqps_base);
214-
let dest_uri = format!("{}?dest_xyz=456&dest_heartbeat=10&channel_max=100&another_dummy=example", amqps_base);
241+
let dest_uri = format!(
242+
"{}?dest_xyz=456&dest_heartbeat=10&channel_max=100&another_dummy=example",
243+
amqps_base
244+
);
215245

216246
run_succeeds([
217247
"-V",
@@ -239,7 +269,8 @@ fn test_disable_tls_peer_verification_for_all_destination_uris_with_dummy_query_
239269
]);
240270

241271
let output = run_succeeds(["parameters", "list_all"]);
242-
let stdout = output.stdout(predicate::str::contains(shovel_name))
272+
let stdout = output
273+
.stdout(predicate::str::contains(shovel_name))
243274
.stdout(predicate::str::contains("verify=verify_none"))
244275
.stdout(predicate::str::contains("dest_xyz=456"))
245276
.stdout(predicate::str::contains("dest_heartbeat=10"))
@@ -258,23 +289,39 @@ fn test_disable_tls_peer_verification_for_all_destination_uris_with_dummy_query_
258289
if in_our_shovel {
259290
shovel_section.push_str(line);
260291
shovel_section.push('\n');
261-
if line.contains("└─") || (in_our_shovel && line.contains("├─") && !line.contains(&shovel_name)) {
292+
if line.contains("└─")
293+
|| (in_our_shovel && line.contains("├─") && !line.contains(&shovel_name))
294+
{
262295
break;
263296
}
264297
}
265298
}
266299

267-
let dest_uri_lines: Vec<&str> = shovel_section.lines()
300+
let dest_uri_lines: Vec<&str> = shovel_section
301+
.lines()
268302
.filter(|line| line.contains("dest-uri"))
269303
.collect();
270-
assert!(!dest_uri_lines.is_empty(), "Could not find dest-uri in shovel section");
304+
assert!(
305+
!dest_uri_lines.is_empty(),
306+
"Could not find dest-uri in shovel section"
307+
);
271308

272309
let dest_uri_content = dest_uri_lines[0];
273310
let dest_verify_count = dest_uri_content.matches("verify=").count();
274-
assert_eq!(dest_verify_count, 1, "Expected exactly 1 verify parameter in destination URI, found {}", dest_verify_count);
311+
assert_eq!(
312+
dest_verify_count, 1,
313+
"Expected exactly 1 verify parameter in destination URI, found {}",
314+
dest_verify_count
315+
);
275316

276-
assert!(dest_uri_content.contains("verify=verify_none"), "Destination URI should contain verify=verify_none");
277-
assert!(!dest_uri_content.contains("verify=verify_peer"), "Destination URI should not contain verify=verify_peer");
317+
assert!(
318+
dest_uri_content.contains("verify=verify_none"),
319+
"Destination URI should contain verify=verify_none"
320+
);
321+
assert!(
322+
!dest_uri_content.contains("verify=verify_peer"),
323+
"Destination URI should not contain verify=verify_peer"
324+
);
278325

279326
delete_vhost(vh).expect("failed to delete a virtual host");
280327

@@ -297,4 +344,4 @@ fn test_disable_tls_peer_verification_for_all_destination_uris_no_shovels()
297344
delete_vhost(vh).expect("failed to delete a virtual host");
298345

299346
Ok(())
300-
}
347+
}

0 commit comments

Comments
 (0)