Skip to content

Commit

Permalink
Not forcing Mauth, avoid performance on empty scenarios and find more…
Browse files Browse the repository at this point in the history
… scenarios
  • Loading branch information
JordiPolo committed Feb 7, 2021
1 parent 59175a0 commit aa4702b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, macos, windows]
build: [linux, macos]
include:
- build: linux
os: ubuntu-20.04
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "minos"
version = "0.3.1"
version = "0.3.3"
authors = ["Jordi Polo Carres <[email protected]>"]
description = """
Minos is a command line tool to generate and run scenarios against
Expand Down
9 changes: 5 additions & 4 deletions crates/daedalus/src/known_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ impl<'a> ConversionView<'a> {
// a pattern may be /users/{uuid}/friends/{uuid2}
// TODO: use the logic above to use non "/" if possible
pub(crate) fn retrieve_known_path(&self, pattern: &str) -> Option<String> {
let mut result = String::new();

for (path, keys) in self.paths.clone() {
for (_path, keys) in self.paths.clone() {
let mut result = pattern.to_owned();
for (key, value) in keys {
let random_value = &value.0.choose(&mut rand::thread_rng()).unwrap();
result = str::replace(pattern, &format!("{{{}}}", key), random_value)
// We want to accumulate the changes of result on itself so things with multiple variables like
// /resource/{id}{tag} gets every variable replaced and saved
result = str::replace(&result, &format!("{{{}}}", key), random_value)
}
if !result.contains('{') {
return Some(result);
Expand Down
33 changes: 16 additions & 17 deletions src/authentication.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
use mauth_client::*;
use tracing::info;

pub struct Authentication {
mauth_info: mauth_client::MAuthInfo
mauth_info: Option<mauth_client::MAuthInfo>
}

impl Authentication {
pub fn new() -> Self {
let auth = match MAuthInfo::from_default_file() {
Err(_) => {
info!("Mauth file not found on ~/.mauth_config.yml or incorrect format.");
None
},
Ok(file) => Some(file)
};
Authentication {
mauth_info: MAuthInfo::from_default_file().expect("Mauth file missing")
mauth_info: auth
}
}
pub fn authenticate(&self, mut requ: &mut hyper::Request<hyper::Body>) {
// on empty body we digest "" TODO: Support request bodies
let (_, body_digest) = MAuthInfo::build_body_with_digest("".to_string());
self.mauth_info.sign_request_v2(&mut requ, &body_digest);
self.mauth_info.sign_request_v1(&mut requ, &body_digest);
}
}

/*
pub struct Authentication {}
impl Authentication {
pub fn new() -> Self {
Authentication {}
if let Some(mauth_info) = &self.mauth_info {
// on empty body we digest "" TODO: Support request bodies
let (_, body_digest) = MAuthInfo::build_body_with_digest("".to_string());
mauth_info.sign_request_v2(&mut requ, &body_digest);
mauth_info.sign_request_v1(&mut requ, &body_digest);
}
}
pub fn authenticate(&self, mut _requ: &mut hyper::Request<hyper::Body>) {}
}
*/
5 changes: 5 additions & 0 deletions src/command_performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub fn run<'a>(
service: &service::Service,
command: PerformanceCommand,
) {

let config = config(command);
//let goose_attack = default_attack(command);

Expand All @@ -36,6 +37,10 @@ pub fn run<'a>(
let url = reqwest::Url::parse(&request.uri().to_string()).unwrap();
req_list.push((url, request.headers().clone()));
}
if req_list.is_empty() {
println!("There are 0 scenarios to run performance testing. Consider using a conversions file.");
return;
}
}

// let mut taskset = taskset!("WebsiteUser");
Expand Down

0 comments on commit aa4702b

Please sign in to comment.