mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 13:20:42 +00:00
fixing clippy issues
Signed-off-by: Till Wegmueller <toasterson@gmail.com>
This commit is contained in:
parent
59ae8ea4cc
commit
640fc4f611
2 changed files with 408 additions and 285 deletions
|
|
@ -6,6 +6,7 @@
|
|||
use sha2::Digest as Sha2Digest;
|
||||
#[allow(unused_imports)]
|
||||
use sha3::Digest as Sha3Digest;
|
||||
use std::fmt::Display;
|
||||
use std::str::FromStr;
|
||||
use std::{convert::TryInto, result::Result as StdResult};
|
||||
use strum::{Display as StrumDisplay, EnumString};
|
||||
|
|
@ -106,9 +107,14 @@ impl Digest {
|
|||
DigestAlgorithm::SHA3512Half | DigestAlgorithm::SHA3256 => {
|
||||
format!("{:x}", sha3::Sha3_256::digest(b))
|
||||
}
|
||||
DigestAlgorithm::SHA3512 | _ => {
|
||||
DigestAlgorithm::SHA3512 => {
|
||||
format!("{:x}", sha3::Sha3_512::digest(b))
|
||||
}
|
||||
x => {
|
||||
return Err(DigestError::UnknownAlgorithm {
|
||||
algorithm: x.to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
Ok(Digest {
|
||||
|
|
@ -117,28 +123,11 @@ impl Digest {
|
|||
hash,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_string(&self) -> String {
|
||||
format!(
|
||||
"{}:{}:{}",
|
||||
match self.source {
|
||||
DigestSource::UncompressedFile => "file",
|
||||
DigestSource::GzipCompressed => "gzip",
|
||||
DigestSource::GNUElf => "gelf",
|
||||
DigestSource::GNUElfUnsigned => "gelf.unsigned",
|
||||
DigestSource::Unknown | _ => "unknown",
|
||||
},
|
||||
match self.algorithm {
|
||||
DigestAlgorithm::SHA1 => "sha1",
|
||||
DigestAlgorithm::SHA256 => "sha256t",
|
||||
DigestAlgorithm::SHA512Half => "sha512t_256",
|
||||
DigestAlgorithm::SHA512 => "sha512t",
|
||||
DigestAlgorithm::SHA3256 => "sha3256t",
|
||||
DigestAlgorithm::SHA3512Half => "sha3512t_256",
|
||||
DigestAlgorithm::SHA3512 => "sha3512t",
|
||||
},
|
||||
self.hash
|
||||
)
|
||||
impl Display for Digest {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}:{}:{}", self.source, self.algorithm, self.hash)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// MPL was not distributed with this file, You can
|
||||
// obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub mod actions;
|
||||
pub mod digest;
|
||||
pub mod payload;
|
||||
|
|
@ -10,11 +11,11 @@ pub mod payload;
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::actions::{Manifest, Property, Dir, File, Dependency, Facet, Link};
|
||||
use crate::actions::{Attr};
|
||||
use std::collections::{HashMap};
|
||||
use crate::payload::Payload;
|
||||
use crate::actions::Attr;
|
||||
use crate::actions::{Dependency, Dir, Facet, File, Link, Manifest, Property};
|
||||
use crate::digest::{Digest, DigestAlgorithm, DigestSource};
|
||||
use crate::payload::Payload;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use maplit::hashmap;
|
||||
|
||||
|
|
@ -39,8 +40,20 @@ set name=info.source-url value=\"http://www.pgpool.net/download.php?f=pgpool-II-
|
|||
set name=pkg.summary value=\"'XZ Utils - loss-less file compression application and library.'\"");
|
||||
|
||||
let mut optional_hash = HashMap::new();
|
||||
optional_hash.insert(String::from("optional"), Property{key: String::from("optional"), value:String::from("testing")});
|
||||
optional_hash.insert(String::from("optionalWithString"), Property{key: String::from("optionalWithString"), value:String::from("test ing")});
|
||||
optional_hash.insert(
|
||||
String::from("optional"),
|
||||
Property {
|
||||
key: String::from("optional"),
|
||||
value: String::from("testing"),
|
||||
},
|
||||
);
|
||||
optional_hash.insert(
|
||||
String::from("optionalWithString"),
|
||||
Property {
|
||||
key: String::from("optionalWithString"),
|
||||
value: String::from("test ing"),
|
||||
},
|
||||
);
|
||||
|
||||
let test_results = vec![
|
||||
Attr{
|
||||
|
|
@ -147,11 +160,13 @@ set name=pkg.summary value=\"'XZ Utils - loss-less file compression application
|
|||
|
||||
#[test]
|
||||
fn parse_direcory_actions() {
|
||||
let manifest_string = String::from("dir group=bin mode=0755 owner=root path=etc/nginx
|
||||
let manifest_string = String::from(
|
||||
"dir group=bin mode=0755 owner=root path=etc/nginx
|
||||
dir group=bin mode=0755 owner=root path=usr/share/nginx
|
||||
dir group=bin mode=0755 owner=root path=usr/share/nginx/html
|
||||
dir group=bin mode=0755 owner=webservd path=var/nginx/logs
|
||||
dir group=bin mode=0755 owner=root path=\"var/nginx\"");
|
||||
dir group=bin mode=0755 owner=root path=\"var/nginx\"",
|
||||
);
|
||||
|
||||
let test_results = vec![
|
||||
Dir {
|
||||
|
|
@ -160,25 +175,29 @@ dir group=bin mode=0755 owner=root path=\"var/nginx\"");
|
|||
owner: String::from("root"),
|
||||
path: String::from("etc/nginx"),
|
||||
..Dir::default()
|
||||
},Dir{
|
||||
},
|
||||
Dir {
|
||||
group: String::from("bin"),
|
||||
mode: String::from("0755"),
|
||||
owner: String::from("root"),
|
||||
path: String::from("usr/share/nginx"),
|
||||
..Dir::default()
|
||||
},Dir{
|
||||
},
|
||||
Dir {
|
||||
group: String::from("bin"),
|
||||
mode: String::from("0755"),
|
||||
owner: String::from("root"),
|
||||
path: String::from("usr/share/nginx/html"),
|
||||
..Dir::default()
|
||||
},Dir{
|
||||
},
|
||||
Dir {
|
||||
group: String::from("bin"),
|
||||
mode: String::from("0755"),
|
||||
owner: String::from("webservd"),
|
||||
path: String::from("var/nginx/logs"),
|
||||
..Dir::default()
|
||||
},Dir{
|
||||
},
|
||||
Dir {
|
||||
group: String::from("bin"),
|
||||
mode: String::from("0755"),
|
||||
owner: String::from("root"),
|
||||
|
|
@ -187,7 +206,6 @@ dir group=bin mode=0755 owner=root path=\"var/nginx\"");
|
|||
},
|
||||
];
|
||||
|
||||
|
||||
let res = Manifest::parse_string(manifest_string);
|
||||
assert!(res.is_ok(), "error during Manifest parsing: {:?}", res);
|
||||
let manifest = res.unwrap();
|
||||
|
|
@ -238,15 +256,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "42007aaee6bd54977eb33f91db28f931ab11c39787ba9f7851b6baf0d142185b".to_string(),
|
||||
hash:
|
||||
"42007aaee6bd54977eb33f91db28f931ab11c39787ba9f7851b6baf0d142185b"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "ec144533fa077af1d5b152d8c7549f113902021d71808adb12ea3f92bda9fd66".to_string(),
|
||||
hash:
|
||||
"ec144533fa077af1d5b152d8c7549f113902021d71808adb12ea3f92bda9fd66"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -258,13 +280,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "975".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "1855".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("72e0496a02e72e7380b0b62cdc8410108302876f"),
|
||||
|
|
@ -276,15 +300,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "c0c3640d6e61b53a3dc4228adff7532ec6b5d09bf1847991a3aaa5eb3e04d19a".to_string(),
|
||||
hash:
|
||||
"c0c3640d6e61b53a3dc4228adff7532ec6b5d09bf1847991a3aaa5eb3e04d19a"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "e1999bae58ef887d81dc686b794429a9dea0e7674b631c2a08f07fb9b34440e2".to_string(),
|
||||
hash:
|
||||
"e1999bae58ef887d81dc686b794429a9dea0e7674b631c2a08f07fb9b34440e2"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -296,16 +324,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "1067".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "2844".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "restart_fmri".to_string(),
|
||||
value: "svc:/system/manifest-import:default".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("95de71d58b37f9f74bede0e91bc381d6059fc2d7"),
|
||||
|
|
@ -317,15 +348,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "b592728ea1dcd6dd0924e1e6767e217ad70ec6973086911d8bc07d44695b9f0e".to_string(),
|
||||
hash:
|
||||
"b592728ea1dcd6dd0924e1e6767e217ad70ec6973086911d8bc07d44695b9f0e"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "8407d82b497c4a865841ab8874207cc5a4d581ba574d66074ef5f92f05ee13cf".to_string(),
|
||||
hash:
|
||||
"8407d82b497c4a865841ab8874207cc5a4d581ba574d66074ef5f92f05ee13cf"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -337,13 +372,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "327".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "494".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("7dd71afcfb14e105e80b0c0d7fce370a28a41f0a"),
|
||||
|
|
@ -355,15 +392,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "204038cd5fbbcdd2c3d24acb7f41b1e861c51d689f53202ec69b43bdba01cb60".to_string(),
|
||||
hash:
|
||||
"204038cd5fbbcdd2c3d24acb7f41b1e861c51d689f53202ec69b43bdba01cb60"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "34bad6066578cf03289b0c957cb4f01a9353f91b3b95079d69bf9e12dd569279".to_string(),
|
||||
hash:
|
||||
"34bad6066578cf03289b0c957cb4f01a9353f91b3b95079d69bf9e12dd569279"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -375,13 +416,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "381".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "612".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("cbf596ddb3433a8e0d325f3c188bec9c1bb746b3"),
|
||||
|
|
@ -393,15 +436,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "d260c064680ec58135d9a290ed3cfd64274db769701ab3df2bfdeb653a864518".to_string(),
|
||||
hash:
|
||||
"d260c064680ec58135d9a290ed3cfd64274db769701ab3df2bfdeb653a864518"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "4924c0f4bdc37b832afd281ad07b0bf339c8c3a0e2d95e076998d46fab76a084".to_string(),
|
||||
hash:
|
||||
"4924c0f4bdc37b832afd281ad07b0bf339c8c3a0e2d95e076998d46fab76a084"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -414,13 +461,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "448".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "1077".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("da38e2a0dded838afbe0eade6cb837ac30fd8046"),
|
||||
|
|
@ -432,15 +481,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "baeeb2df301f8764568a86884c127e90faf39bee4ff0e53fb4a890955e605cee".to_string(),
|
||||
hash:
|
||||
"baeeb2df301f8764568a86884c127e90faf39bee4ff0e53fb4a890955e605cee"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "5c6f541692556eacbde4ea1536de3c1af2cd8e9980fc4edca36851a97ed671ba".to_string(),
|
||||
hash:
|
||||
"5c6f541692556eacbde4ea1536de3c1af2cd8e9980fc4edca36851a97ed671ba"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -453,13 +506,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "430".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "1007".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("407cb51b397ba4ad90a2246640a81af18e2e917a"),
|
||||
|
|
@ -471,15 +526,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "06381b2c4a28fe88c0d908f1cd81453c9482358c8195163e294b8def8924b366".to_string(),
|
||||
hash:
|
||||
"06381b2c4a28fe88c0d908f1cd81453c9482358c8195163e294b8def8924b366"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "d66022b08971eaf9ddf3230a991b0d8352fcefe0f797305a94b5ca0574d70ff5".to_string(),
|
||||
hash:
|
||||
"d66022b08971eaf9ddf3230a991b0d8352fcefe0f797305a94b5ca0574d70ff5"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -492,13 +551,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "938".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "2837".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("19ec7fb71e7f00d7e8a1cfc1013490f0cfee572b"),
|
||||
|
|
@ -510,15 +571,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "92d4df1df754d3e2cd8c52aba7415680c86097803b437bf0edcd8d022ab6aa8c".to_string(),
|
||||
hash:
|
||||
"92d4df1df754d3e2cd8c52aba7415680c86097803b437bf0edcd8d022ab6aa8c"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "2ad3bb0540d800f2115691c96e8ed35b9b91eb5c248bea199da22ffd102cc847".to_string(),
|
||||
hash:
|
||||
"2ad3bb0540d800f2115691c96e8ed35b9b91eb5c248bea199da22ffd102cc847"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -531,13 +596,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "749".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "2223".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("e39dbc36680b717ec902fadc805a302f1cf62245"),
|
||||
|
|
@ -549,15 +616,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "8217c6955d644400707c4ecf1539ece4ee2fd1be4838654860f2ef2ecacdebd4".to_string(),
|
||||
hash:
|
||||
"8217c6955d644400707c4ecf1539ece4ee2fd1be4838654860f2ef2ecacdebd4"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "46566d205da4d67a6e12a1d3d2f78e3602770ce42ef2c117ee95b821aec90100".to_string(),
|
||||
hash:
|
||||
"46566d205da4d67a6e12a1d3d2f78e3602770ce42ef2c117ee95b821aec90100"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -570,13 +641,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "990".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "5231".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("d143ca7a6aac765d28724af54d969a4bd2202383"),
|
||||
|
|
@ -588,15 +661,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "cc9263a836b4db441340d2e041adf10136c9a8aa31259b868000f88c84032ba1".to_string(),
|
||||
hash:
|
||||
"cc9263a836b4db441340d2e041adf10136c9a8aa31259b868000f88c84032ba1"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "cf0cd12b5f3f1d9d15378e1a1bacaaff7589bf2c129312b277b66ea3418acc54".to_string(),
|
||||
hash:
|
||||
"cf0cd12b5f3f1d9d15378e1a1bacaaff7589bf2c129312b277b66ea3418acc54"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -609,13 +686,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "997".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "2798".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("379c1e2a2a5ffb8c91a07328d4c9be2bc58799fd"),
|
||||
|
|
@ -627,15 +706,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "e6dd7076b6319abc3fcd04554fede95c8cc40f1e21a83772c36577f939e81cb6".to_string(),
|
||||
hash:
|
||||
"e6dd7076b6319abc3fcd04554fede95c8cc40f1e21a83772c36577f939e81cb6"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "48efb28df3607f1a8b67eab95d4ca19526e8351d10529d97cb4af05250f8ee95".to_string(),
|
||||
hash:
|
||||
"48efb28df3607f1a8b67eab95d4ca19526e8351d10529d97cb4af05250f8ee95"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -648,13 +731,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "275".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "636".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("cc2fcdb4605dcac23d59f667889ccbdfdc6e3668"),
|
||||
|
|
@ -666,15 +751,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "eb133ae0a357df02b4b02615bc47dc2e5328105dac2dbcbd647667e9bbc3b2fd".to_string(),
|
||||
hash:
|
||||
"eb133ae0a357df02b4b02615bc47dc2e5328105dac2dbcbd647667e9bbc3b2fd"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "e5a2625a67f5502c5911d7e7a850030b6af89929e182b2da74ecf6e79df0e9d2".to_string(),
|
||||
hash:
|
||||
"e5a2625a67f5502c5911d7e7a850030b6af89929e182b2da74ecf6e79df0e9d2"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -687,13 +776,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "284".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "664".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("e10f2d42c9e581901d810928d01a3bf8f3372838"),
|
||||
|
|
@ -705,15 +796,19 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "7620f21db4c06f3eb863c0cb0a8b3f62c435abd2f8f47794c42f08ad434d90dd".to_string(),
|
||||
hash:
|
||||
"7620f21db4c06f3eb863c0cb0a8b3f62c435abd2f8f47794c42f08ad434d90dd"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "ca16a95ddd6ef2043969db20915935829b8ccb6134588e1710b24baf45afd7bb".to_string(),
|
||||
hash:
|
||||
"ca16a95ddd6ef2043969db20915935829b8ccb6134588e1710b24baf45afd7bb"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -726,13 +821,15 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "1197".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "3610".to_string(),
|
||||
},
|
||||
],
|
||||
..File::default()
|
||||
}, File{
|
||||
},
|
||||
File {
|
||||
payload: Some(Payload {
|
||||
primary_identifier: Digest {
|
||||
hash: String::from("6d5f820bb1d67594c7b757c79ef6f9242df49e98"),
|
||||
|
|
@ -744,25 +841,33 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
..Digest::default()
|
||||
},
|
||||
Digest {
|
||||
hash: "add9bfb171c2a173b8f12d375884711527f40e592d100a337a9fae078c8beabd".to_string(),
|
||||
hash:
|
||||
"add9bfb171c2a173b8f12d375884711527f40e592d100a337a9fae078c8beabd"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GNUElf
|
||||
source: DigestSource::GNUElf,
|
||||
},
|
||||
Digest {
|
||||
hash: "add9bfb171c2a173b8f12d375884711527f40e592d100a337a9fae078c8beabd".to_string(),
|
||||
hash:
|
||||
"add9bfb171c2a173b8f12d375884711527f40e592d100a337a9fae078c8beabd"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GNUElfUnsigned
|
||||
source: DigestSource::GNUElfUnsigned,
|
||||
},
|
||||
Digest {
|
||||
hash: "3d87b058a8e69b3a8dfab142f5e856549dcd531a371e3ca4d2be391655b0d076".to_string(),
|
||||
hash:
|
||||
"3d87b058a8e69b3a8dfab142f5e856549dcd531a371e3ca4d2be391655b0d076"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::UncompressedFile
|
||||
source: DigestSource::UncompressedFile,
|
||||
},
|
||||
Digest {
|
||||
hash: "7f93c48194b3e164ea35a9d2ddff310215769dbd27b45e9ab72beef1cce0d4f6".to_string(),
|
||||
hash:
|
||||
"7f93c48194b3e164ea35a9d2ddff310215769dbd27b45e9ab72beef1cce0d4f6"
|
||||
.to_string(),
|
||||
algorithm: DigestAlgorithm::SHA512Half,
|
||||
source: DigestSource::GzipCompressed
|
||||
}
|
||||
source: DigestSource::GzipCompressed,
|
||||
},
|
||||
],
|
||||
..Payload::default()
|
||||
}),
|
||||
|
|
@ -774,16 +879,20 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
Property {
|
||||
key: "elfarch".to_string(),
|
||||
value: "i386".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "elfbits".to_string(),
|
||||
value: "64".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "elfhash".to_string(),
|
||||
value: "25b0cdd7736cddad78ce91b61385a8fdde91f7b2".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.csize".to_string(),
|
||||
value: "657230".to_string(),
|
||||
},Property{
|
||||
},
|
||||
Property {
|
||||
key: "pkg.size".to_string(),
|
||||
value: "1598048".to_string(),
|
||||
},
|
||||
|
|
@ -814,7 +923,10 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
assert_eq!(file.preserve, test_results[pos].preserve);
|
||||
if let Some(payload_expected) = &test_results[pos].payload {
|
||||
assert_ne!(file.payload, None);
|
||||
assert_eq!(file.payload.as_ref().unwrap().primary_identifier.hash, payload_expected.primary_identifier.hash);
|
||||
assert_eq!(
|
||||
file.payload.as_ref().unwrap().primary_identifier.hash,
|
||||
payload_expected.primary_identifier.hash
|
||||
);
|
||||
}
|
||||
|
||||
for (vpos, val) in file.properties.iter().enumerate() {
|
||||
|
|
@ -824,9 +936,33 @@ file path=usr/lib/golang/1.16/src/runtime/runtime-gdb_test.go.~1~");
|
|||
|
||||
if let Some(payload) = &file.payload {
|
||||
for (vpos, val) in payload.additional_identifiers.iter().enumerate() {
|
||||
assert_eq!(val.hash, test_results[pos].payload.as_ref().unwrap().additional_identifiers[vpos].hash);
|
||||
assert_eq!(val.source, test_results[pos].payload.as_ref().unwrap().additional_identifiers[vpos].source);
|
||||
assert_eq!(val.algorithm, test_results[pos].payload.as_ref().unwrap().additional_identifiers[vpos].algorithm);
|
||||
assert_eq!(
|
||||
val.hash,
|
||||
test_results[pos]
|
||||
.payload
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.additional_identifiers[vpos]
|
||||
.hash
|
||||
);
|
||||
assert_eq!(
|
||||
val.source,
|
||||
test_results[pos]
|
||||
.payload
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.additional_identifiers[vpos]
|
||||
.source
|
||||
);
|
||||
assert_eq!(
|
||||
val.algorithm,
|
||||
test_results[pos]
|
||||
.payload
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.additional_identifiers[vpos]
|
||||
.algorithm
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -852,7 +988,8 @@ depend facet.version-lock.system/mozilla-nss=true fmri=system/mozilla-nss@3.51.1
|
|||
..Dependency::default()
|
||||
},
|
||||
Dependency {
|
||||
fmri: "pkg:/system/data/hardware-registry@2020.2.22,5.11-2020.0.1.19951".to_string(),
|
||||
fmri: "pkg:/system/data/hardware-registry@2020.2.22,5.11-2020.0.1.19951"
|
||||
.to_string(),
|
||||
dependency_type: "incorporate".to_string(),
|
||||
facets: hashmap! {
|
||||
"version-lock.system/data/hardware-registry".to_string() => Facet{
|
||||
|
|
@ -893,21 +1030,28 @@ depend facet.version-lock.system/mozilla-nss=true fmri=system/mozilla-nss@3.51.1
|
|||
assert_eq!(manifest.dependencies.len(), test_results.len());
|
||||
for (pos, dependency) in manifest.dependencies.iter().enumerate() {
|
||||
assert_eq!(dependency.fmri, test_results[pos].fmri);
|
||||
assert_eq!(dependency.dependency_type, test_results[pos].dependency_type);
|
||||
assert_eq!(
|
||||
dependency.dependency_type,
|
||||
test_results[pos].dependency_type
|
||||
);
|
||||
for (_, (key, facet)) in dependency.facets.iter().enumerate() {
|
||||
let fres = test_results[pos].facets.get(key);
|
||||
assert!(fres.is_some(), "error no facet with name: {:?} found", facet.name);
|
||||
assert!(
|
||||
fres.is_some(),
|
||||
"error no facet with name: {:?} found",
|
||||
facet.name
|
||||
);
|
||||
let f = fres.unwrap();
|
||||
assert_eq!(facet.name, f.name);
|
||||
assert_eq!(facet.value, f.value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_line_breaks() {
|
||||
let manifest_string = String::from("link \
|
||||
let manifest_string = String::from(
|
||||
"link \
|
||||
path=usr/lib/cups/backend/http \
|
||||
target=ipp
|
||||
file Solaris/desktop-print-management mode=0555 \
|
||||
|
|
@ -921,73 +1065,62 @@ file Solaris/svc-cupsd mode=0644 path=lib/svc/method/svc-cupsd
|
|||
|
||||
# SMF help
|
||||
file Solaris/ManageCUPS.html mode=0444 \
|
||||
path=usr/lib/help/auths/locale/C/ManageCUPS.html");
|
||||
path=usr/lib/help/auths/locale/C/ManageCUPS.html",
|
||||
);
|
||||
|
||||
let file_results = vec![
|
||||
File {
|
||||
path: "usr/lib/cups/bin/desktop-print-management".to_string(),
|
||||
mode: "0555".to_string(),
|
||||
properties: vec![
|
||||
Property{
|
||||
properties: vec![Property {
|
||||
key: "original-path".to_string(),
|
||||
value: "Solaris/desktop-print-management".to_string(),
|
||||
}
|
||||
],
|
||||
}],
|
||||
..File::default()
|
||||
},
|
||||
File {
|
||||
path: "usr/lib/cups/bin/desktop-print-management-applet".to_string(),
|
||||
mode: "0555".to_string(),
|
||||
properties: vec![
|
||||
Property{
|
||||
properties: vec![Property {
|
||||
key: "original-path".to_string(),
|
||||
value: "Solaris/desktop-print-management-applet".to_string(),
|
||||
}
|
||||
],
|
||||
}],
|
||||
..File::default()
|
||||
},
|
||||
File {
|
||||
path: "usr/lib/cups/backend/smb".to_string(),
|
||||
mode: "0555".to_string(),
|
||||
properties: vec![
|
||||
Property{
|
||||
properties: vec![Property {
|
||||
key: "original-path".to_string(),
|
||||
value: "Solaris/smb".to_string(),
|
||||
}
|
||||
],
|
||||
}],
|
||||
..File::default()
|
||||
},
|
||||
File {
|
||||
path: "lib/svc/method/svc-cupsd".to_string(),
|
||||
mode: "0644".to_string(),
|
||||
properties: vec![
|
||||
Property{
|
||||
properties: vec![Property {
|
||||
key: "original-path".to_string(),
|
||||
value: "Solaris/svc-cupsd".to_string(),
|
||||
}
|
||||
],
|
||||
}],
|
||||
..File::default()
|
||||
},
|
||||
File {
|
||||
path: "usr/lib/help/auths/locale/C/ManageCUPS.html".to_string(),
|
||||
mode: "0444".to_string(),
|
||||
properties: vec![
|
||||
Property{
|
||||
properties: vec![Property {
|
||||
key: "original-path".to_string(),
|
||||
value: "Solaris/ManageCUPS.html".to_string(),
|
||||
}
|
||||
],
|
||||
}],
|
||||
..File::default()
|
||||
},
|
||||
];
|
||||
|
||||
let link_results = vec![
|
||||
Link{
|
||||
let link_results = vec![Link {
|
||||
path: "usr/lib/cups/backend/http".to_string(),
|
||||
target: "ipp".to_string(),
|
||||
..Link::default()
|
||||
},
|
||||
];
|
||||
}];
|
||||
|
||||
let res = Manifest::parse_string(manifest_string);
|
||||
assert!(res.is_ok(), "error during Manifest parsing: {:?}", res);
|
||||
|
|
@ -996,7 +1129,10 @@ file Solaris/ManageCUPS.html mode=0444 \
|
|||
for (pos, file) in manifest.files.iter().enumerate() {
|
||||
assert_eq!(file.path, file_results[pos].path);
|
||||
assert_eq!(file.properties[0].key, file_results[pos].properties[0].key);
|
||||
assert_eq!(file.properties[0].value, file_results[pos].properties[0].value);
|
||||
assert_eq!(
|
||||
file.properties[0].value,
|
||||
file_results[pos].properties[0].value
|
||||
);
|
||||
assert_eq!(file.mode, file_results[pos].mode);
|
||||
}
|
||||
|
||||
|
|
@ -1004,16 +1140,17 @@ file Solaris/ManageCUPS.html mode=0444 \
|
|||
assert_eq!(link.path, link_results[pos].path);
|
||||
assert_eq!(link.target, link_results[pos].target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_unicode() {
|
||||
let manifest_string = String::from("link \
|
||||
let manifest_string = String::from(
|
||||
"link \
|
||||
path=usr/lib/cups/пертинах/http \
|
||||
target=Про
|
||||
# SMF blub
|
||||
link path=usr/lib/cups/пертинах/http target=blub");
|
||||
link path=usr/lib/cups/пертинах/http target=blub",
|
||||
);
|
||||
|
||||
let link_results = vec![
|
||||
Link {
|
||||
|
|
@ -1036,8 +1173,5 @@ link path=usr/lib/cups/пертинах/http target=blub");
|
|||
assert_eq!(link.path, link_results[pos].path);
|
||||
assert_eq!(link.target, link_results[pos].target);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue