diff options
author | Cyborus <cyborus@noreply.codeberg.org> | 2024-05-31 17:24:42 +0200 |
---|---|---|
committer | Cyborus <cyborus@noreply.codeberg.org> | 2024-05-31 17:24:42 +0200 |
commit | 7fa8e0acb764e1f819ca082ad7b3b133b2882e82 (patch) | |
tree | bf27bb484e07e82d6db78eef9183eb99118be926 /src/lib.rs | |
parent | add oauth2 testing (diff) | |
parent | add `/test_repos` to gitignore (diff) | |
download | forgejo-api-7fa8e0acb764e1f819ca082ad7b3b133b2882e82.tar.xz forgejo-api-7fa8e0acb764e1f819ca082ad7b3b133b2882e82.zip |
Merge pull request 'improve integration tests' (#56) from improve-tests into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-api/pulls/56
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -99,11 +99,13 @@ impl Forgejo { password, mfa, } => { - let len = (((username.len() + password.len() + 1) + let unencoded_len = username.len() + password.len() + 1; + let unpadded_len = unencoded_len .checked_mul(4) - .ok_or(ForgejoError::AuthTooLong)?) - / 3) - + 1; + .ok_or(ForgejoError::AuthTooLong)? + .div_ceil(3); + // round up to next multiple of 4, to account for padding + let len = unpadded_len.div_ceil(4) * 4; let mut bytes = vec![0; len]; // panic safety: len cannot be zero |