Add the git pre-commit hook
Signed-off-by: Luca Fulchir <luca.fulchir@runesauth.com>
This commit is contained in:
parent
e2874451d1
commit
a32dfe098f
24
Readme.md
24
Readme.md
|
@ -15,3 +15,27 @@ you will find the result in `./target/release`
|
||||||
If you want to build the `Hati` server, you don't need to build this library
|
If you want to build the `Hati` server, you don't need to build this library
|
||||||
separately. Just build the server and it will automatically include this lib
|
separately. Just build the server and it will automatically include this lib
|
||||||
|
|
||||||
|
# Developing
|
||||||
|
|
||||||
|
we recommend to use the nix environment, so that you will have
|
||||||
|
exactly the same environment as the developers.
|
||||||
|
|
||||||
|
just enter the repository directory and run
|
||||||
|
|
||||||
|
```
|
||||||
|
nix develop
|
||||||
|
```
|
||||||
|
|
||||||
|
and everything should be done for you.
|
||||||
|
|
||||||
|
## Git
|
||||||
|
|
||||||
|
Please configure a pre-commit hook like the one in `var/git-pre-commit`
|
||||||
|
|
||||||
|
```
|
||||||
|
cp var/git-pre-commit .git/hooks/pre-commit
|
||||||
|
```
|
||||||
|
|
||||||
|
This will run `cargo test --offline` right before your commit,
|
||||||
|
to make sure that everything compiles and that the test pass
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,7 @@ use crate::{
|
||||||
fn test_handshake_dirsync_req() {
|
fn test_handshake_dirsync_req() {
|
||||||
let rand = enc::Random::new();
|
let rand = enc::Random::new();
|
||||||
let secret = enc::Secret::new_rand(&rand);
|
let secret = enc::Secret::new_rand(&rand);
|
||||||
let cipher_send = enc::sym::CipherSend::new(
|
let cipher = enc::sym::CipherKind::XChaCha20Poly1305;
|
||||||
enc::sym::CipherKind::XChaCha20Poly1305,
|
|
||||||
secret,
|
|
||||||
&rand,
|
|
||||||
);
|
|
||||||
|
|
||||||
let (_, exchange_key) =
|
let (_, exchange_key) =
|
||||||
match enc::asym::KeyExchangeKind::X25519DiffieHellman.new_keypair(&rand)
|
match enc::asym::KeyExchangeKind::X25519DiffieHellman.new_keypair(&rand)
|
||||||
|
@ -49,11 +45,7 @@ fn test_handshake_dirsync_req() {
|
||||||
|
|
||||||
let mut bytes = Vec::<u8>::with_capacity(h_req.len());
|
let mut bytes = Vec::<u8>::with_capacity(h_req.len());
|
||||||
bytes.resize(h_req.len(), 0);
|
bytes.resize(h_req.len(), 0);
|
||||||
h_req.serialize(
|
h_req.serialize(cipher.nonce_len(), cipher.tag_len(), &mut bytes);
|
||||||
cipher_send.kind().nonce_len(),
|
|
||||||
cipher_send.kind().tag_len(),
|
|
||||||
&mut bytes,
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut deserialized = match Handshake::deserialize(&bytes) {
|
let mut deserialized = match Handshake::deserialize(&bytes) {
|
||||||
Ok(deserialized) => deserialized,
|
Ok(deserialized) => deserialized,
|
||||||
|
@ -65,10 +57,9 @@ fn test_handshake_dirsync_req() {
|
||||||
if let HandshakeData::DirSync(dirsync::DirSync::Req(r_a)) =
|
if let HandshakeData::DirSync(dirsync::DirSync::Req(r_a)) =
|
||||||
&mut deserialized.data
|
&mut deserialized.data
|
||||||
{
|
{
|
||||||
let enc_start =
|
let enc_start = r_a.encrypted_offset() + cipher.nonce_len().0;
|
||||||
r_a.encrypted_offset() + cipher_send.kind().nonce_len().0;
|
|
||||||
if let Err(e) = r_a.data.deserialize_as_cleartext(
|
if let Err(e) = r_a.data.deserialize_as_cleartext(
|
||||||
&bytes[enc_start..(bytes.len() - cipher_send.kind().tag_len().0)],
|
&bytes[enc_start..(bytes.len() - cipher.tag_len().0)],
|
||||||
) {
|
) {
|
||||||
assert!(false, "DirSync Req Inner serialize: {}", e.to_string());
|
assert!(false, "DirSync Req Inner serialize: {}", e.to_string());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
RUSTFLAGS=-Awarnings exec cargo test --offline --profile dev
|
||||||
|
|
Loading…
Reference in New Issue