Skip to content

Commit 66e2afe

Browse files
build(deps): update rand requirement from 0.8 to 0.9 (#3564)
* build(deps): update rand requirement from 0.8 to 0.9 Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](rust-random/rand@0.8.0...0.9.0) --- updated-dependencies: - dependency-name: rand dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * chore: fix rand upgrade * chore: address clippy lint --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede <[email protected]>
1 parent 59961a5 commit 66e2afe

File tree

9 files changed

+23
-58
lines changed

9 files changed

+23
-58
lines changed

actix-http/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ h2 = { version = "0.3.26", optional = true }
132132
# websockets
133133
local-channel = { version = "0.1", optional = true }
134134
base64 = { version = "0.22", optional = true }
135-
rand = { version = "0.8", optional = true }
135+
rand = { version = "0.9", optional = true }
136136
sha1 = { version = "0.10", optional = true }
137137

138138
# openssl/rustls

actix-http/tests/test_server.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use actix_utils::future::{err, ok, ready};
1616
use bytes::Bytes;
1717
use derive_more::derive::{Display, Error};
1818
use futures_util::{stream::once, FutureExt as _, StreamExt as _};
19+
use rand::Rng as _;
1920
use regex::Regex;
2021

2122
#[actix_rt::test]
@@ -164,7 +165,10 @@ async fn chunked_payload() {
164165

165166
for chunk_size in chunk_sizes.iter() {
166167
let mut bytes = Vec::new();
167-
let random_bytes: Vec<u8> = (0..*chunk_size).map(|_| rand::random::<u8>()).collect();
168+
let random_bytes = rand::rng()
169+
.sample_iter(rand::distr::StandardUniform)
170+
.take(*chunk_size)
171+
.collect::<Vec<_>>();
168172

169173
bytes.extend(format!("{:X}\r\n", chunk_size).as_bytes());
170174
bytes.extend(&random_bytes[..]);

actix-multipart/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ local-waker = "0.1"
5050
log = "0.4"
5151
memchr = "2.5"
5252
mime = "0.3"
53-
rand = "0.8"
53+
rand = "0.9"
5454
serde = "1"
5555
serde_json = "1"
5656
serde_plain = "1"

actix-multipart/src/test.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ use actix_web::{
55
web::{BufMut as _, Bytes, BytesMut},
66
};
77
use mime::Mime;
8-
use rand::{
9-
distributions::{Alphanumeric, DistString as _},
10-
thread_rng,
11-
};
8+
use rand::distr::{Alphanumeric, SampleString as _};
129

1310
const CRLF: &[u8] = b"\r\n";
1411
const CRLF_CRLF: &[u8] = b"\r\n\r\n";
@@ -64,7 +61,7 @@ pub fn create_form_data_payload_and_headers(
6461
content_type: Option<Mime>,
6562
file: Bytes,
6663
) -> (Bytes, HeaderMap) {
67-
let boundary = Alphanumeric.sample_string(&mut thread_rng(), 32);
64+
let boundary = Alphanumeric.sample_string(&mut rand::rng(), 32);
6865

6966
create_form_data_payload_and_headers_with_boundary(
7067
&boundary,

actix-web/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ criterion = { version = "0.5", features = ["html_reports"] }
180180
env_logger = "0.11"
181181
flate2 = "1.0.13"
182182
futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
183-
rand = "0.8"
183+
rand = "0.9"
184184
rcgen = "0.13"
185185
rustls-pemfile = "2"
186186
serde = { version = "1", features = ["derive"] }

actix-web/tests/test_server.rs

+7-31
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use openssl::{
2525
ssl::{SslAcceptor, SslMethod},
2626
x509::X509,
2727
};
28-
use rand::{distributions::Alphanumeric, Rng as _};
28+
use rand::distr::{Alphanumeric, SampleString as _};
2929

3030
mod utils;
3131

@@ -188,11 +188,7 @@ async fn body_gzip_large() {
188188

189189
#[actix_rt::test]
190190
async fn test_body_gzip_large_random() {
191-
let data = rand::thread_rng()
192-
.sample_iter(&Alphanumeric)
193-
.take(70_000)
194-
.map(char::from)
195-
.collect::<String>();
191+
let data = Alphanumeric.sample_string(&mut rand::rng(), 70_000);
196192
let srv_data = data.clone();
197193

198194
let srv = actix_test::start_with(actix_test::config().h1(), move || {
@@ -432,11 +428,7 @@ async fn test_zstd_encoding() {
432428

433429
#[actix_rt::test]
434430
async fn test_zstd_encoding_large() {
435-
let data = rand::thread_rng()
436-
.sample_iter(&Alphanumeric)
437-
.take(320_000)
438-
.map(char::from)
439-
.collect::<String>();
431+
let data = Alphanumeric.sample_string(&mut rand::rng(), 320_000);
440432

441433
let srv = actix_test::start_with(actix_test::config().h1(), || {
442434
App::new().service(
@@ -529,11 +521,7 @@ async fn test_gzip_encoding_large() {
529521

530522
#[actix_rt::test]
531523
async fn test_reading_gzip_encoding_large_random() {
532-
let data = rand::thread_rng()
533-
.sample_iter(&Alphanumeric)
534-
.take(60_000)
535-
.map(char::from)
536-
.collect::<String>();
524+
let data = Alphanumeric.sample_string(&mut rand::rng(), 60_000);
537525

538526
let srv = actix_test::start_with(actix_test::config().h1(), || {
539527
App::new().service(web::resource("/").route(web::to(move |body: Bytes| async {
@@ -599,11 +587,7 @@ async fn test_reading_deflate_encoding_large() {
599587

600588
#[actix_rt::test]
601589
async fn test_reading_deflate_encoding_large_random() {
602-
let data = rand::thread_rng()
603-
.sample_iter(&Alphanumeric)
604-
.take(160_000)
605-
.map(char::from)
606-
.collect::<String>();
590+
let data = Alphanumeric.sample_string(&mut rand::rng(), 160_000);
607591

608592
let srv = actix_test::start_with(actix_test::config().h1(), || {
609593
App::new().service(web::resource("/").route(web::to(move |body: Bytes| async {
@@ -648,11 +632,7 @@ async fn test_brotli_encoding() {
648632

649633
#[actix_rt::test]
650634
async fn test_brotli_encoding_large() {
651-
let data = rand::thread_rng()
652-
.sample_iter(&Alphanumeric)
653-
.take(320_000)
654-
.map(char::from)
655-
.collect::<String>();
635+
let data = Alphanumeric.sample_string(&mut rand::rng(), 320_000);
656636

657637
let srv = actix_test::start_with(actix_test::config().h1(), || {
658638
App::new().service(
@@ -737,11 +717,7 @@ mod plus_rustls {
737717

738718
#[actix_rt::test]
739719
async fn test_reading_deflate_encoding_large_random_rustls() {
740-
let data = rand::thread_rng()
741-
.sample_iter(&Alphanumeric)
742-
.take(160_000)
743-
.map(char::from)
744-
.collect::<String>();
720+
let data = Alphanumeric.sample_string(&mut rand::rng(), 160_000);
745721

746722
let srv = actix_test::start_with(actix_test::config().rustls_0_23(tls_config()), || {
747723
App::new().service(web::resource("/").route(web::to(|bytes: Bytes| async {

awc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ log =" 0.4"
116116
mime = "0.3"
117117
percent-encoding = "2.1"
118118
pin-project-lite = "0.2"
119-
rand = "0.8"
119+
rand = "0.9"
120120
serde = "1.0"
121121
serde_json = "1.0"
122122
serde_urlencoded = "0.7"

awc/src/ws.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl WebsocketsRequest {
326326

327327
// Generate a random key for the `Sec-WebSocket-Key` header which is a base64-encoded
328328
// (see RFC 4648 §4) value that, when decoded, is 16 bytes in length (RFC 6455 §1.3).
329-
let sec_key: [u8; 16] = rand::random();
329+
let sec_key = rand::random::<[u8; 16]>();
330330
let key = BASE64_STANDARD.encode(sec_key);
331331

332332
self.head.headers.insert(

awc/tests/test_client.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use base64::prelude::*;
2020
use bytes::Bytes;
2121
use cookie::Cookie;
2222
use futures_util::stream;
23-
use rand::Rng;
23+
use rand::distr::{Alphanumeric, SampleString as _};
2424

2525
mod utils;
2626

@@ -516,11 +516,7 @@ async fn client_gzip_encoding_large() {
516516
#[cfg(feature = "compress-gzip")]
517517
#[actix_rt::test]
518518
async fn client_gzip_encoding_large_random() {
519-
let data = rand::thread_rng()
520-
.sample_iter(&rand::distributions::Alphanumeric)
521-
.take(100_000)
522-
.map(char::from)
523-
.collect::<String>();
519+
let data = Alphanumeric.sample_string(&mut rand::rng(), 100_000);
524520

525521
let srv = actix_test::start(|| {
526522
App::new().service(web::resource("/").route(web::to(|data: Bytes| async {
@@ -562,11 +558,7 @@ async fn client_brotli_encoding() {
562558
#[cfg(feature = "compress-brotli")]
563559
#[actix_rt::test]
564560
async fn client_brotli_encoding_large_random() {
565-
let data = rand::thread_rng()
566-
.sample_iter(&rand::distributions::Alphanumeric)
567-
.take(70_000)
568-
.map(char::from)
569-
.collect::<String>();
561+
let data = Alphanumeric.sample_string(&mut rand::rng(), 70_000);
570562

571563
let srv = actix_test::start(|| {
572564
App::new().service(web::resource("/").route(web::to(|data: Bytes| async {
@@ -607,11 +599,7 @@ async fn client_deflate_encoding() {
607599

608600
#[actix_rt::test]
609601
async fn client_deflate_encoding_large_random() {
610-
let data = rand::thread_rng()
611-
.sample_iter(rand::distributions::Alphanumeric)
612-
.map(char::from)
613-
.take(70_000)
614-
.collect::<String>();
602+
let data = Alphanumeric.sample_string(&mut rand::rng(), 70_000);
615603

616604
let srv = actix_test::start(|| {
617605
App::new().default_service(web::to(|body: Bytes| async {

0 commit comments

Comments
 (0)