Skip to content

Commit

Permalink
Update base64 requirement from 0.13 to 0.21 (#33)
Browse files Browse the repository at this point in the history
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](marshallpierce/rust-base64@v0.13.0...v0.21.0)

---
updated-dependencies:
- dependency-name: base64
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
dependabot[bot] authored Jan 9, 2023
1 parent f3d1cd7 commit 584888a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
6 changes: 3 additions & 3 deletions src/imp/http_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)))
}
}
}
Expand All @@ -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)))
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/imp/other.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@


/// Convenience wrapper over base64 crate's breaking changes
pub(crate) fn base64_encode<T: AsRef<[u8]>>(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.
///
Expand All @@ -13,6 +22,20 @@ pub(crate) fn converge<A>(result: Result<A, A>) -> 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;
Expand Down

0 comments on commit 584888a

Please sign in to comment.