From 584888af8ed168131d4b6333755ccad716fb2868 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jan 2023 14:36:52 -0600 Subject: [PATCH] Update base64 requirement from 0.13 to 0.21 (#33) Updates the requirements on [base64](https://github.com/marshallpierce/rust-base64) to permit the latest version. - [Release notes](https://github.com/marshallpierce/rust-base64/releases) - [Changelog](https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md) - [Commits](https://github.com/marshallpierce/rust-base64/compare/v0.13.0...v0.21.0) --- updated-dependencies: - dependency-name: base64 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.toml | 2 +- src/imp/http_proxy.rs | 6 +++--- src/imp/other.rs | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cfd583f..98a51ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ rust-version = "1.64" version = "0.0.7-alpha" [dependencies] -base64 = "0.13" +base64 = "0.21" byteorder = "1.4" const-str = "0.5" serde = { version = "1.0", features = ["derive"] } diff --git a/src/imp/http_proxy.rs b/src/imp/http_proxy.rs index e3220e0..72068b5 100644 --- a/src/imp/http_proxy.rs +++ b/src/imp/http_proxy.rs @@ -12,7 +12,7 @@ use serde_json::Deserializer; use crate::errors::{DecLibraryError, DecUseError}; use crate::imp::content_type; use crate::imp::hyper_proxy::HyperHttpClient; -use crate::imp::other::converge; +use crate::imp::other::{base64_encode, converge}; use crate::model::{RegistryAuth, RegistryConfig}; use crate::responses::ErrorResponse; @@ -140,7 +140,7 @@ impl DockerEngineHttpClient { let json = serde_json::to_string(&auth) .map_err(DecLibraryError::RegistryAuthJsonEncodingError)?; - Ok(Some(base64::encode(json))) + Ok(Some(base64_encode(json))) } } } @@ -153,7 +153,7 @@ impl DockerEngineHttpClient { let json = serde_json::to_string(registry_config) .map_err(DecLibraryError::RegistryAuthJsonEncodingError)?; - Ok(Some(base64::encode(json))) + Ok(Some(base64_encode(json))) } } } diff --git a/src/imp/other.rs b/src/imp/other.rs index 38932d9..15022cb 100644 --- a/src/imp/other.rs +++ b/src/imp/other.rs @@ -1,4 +1,13 @@ + +/// Convenience wrapper over base64 crate's breaking changes +pub(crate) fn base64_encode>(input: T) -> String { + use base64::engine::general_purpose::STANDARD; + use base64::Engine; + + STANDARD.encode(input) +} + /// Some functions convert/extract input parameters that represent failure information. /// That information is converted to an error result type. /// @@ -13,6 +22,20 @@ pub(crate) fn converge(result: Result) -> A { } } +#[cfg(test)] +mod test_base64_encode { + use super::base64_encode; + + //noinspection SpellCheckingInspection + #[test] + fn encodes() { + let input: [u8; 4] = [2, 3, 4, 5]; + + let expected = "AgMEBQ=="; + assert_eq!(expected, base64_encode(input)); + } +} + #[cfg(test)] mod test_converge { use super::converge;