diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c50cd75..97df8e7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 1.6.4 + +ABQ 1.6.4 is a patch release. + +Prior to this release, using `abq test` or `abq report` with an RWX organization +access token to connect to a hosted queue that failed to find an appropriate +queue would result in the ABQ invocation falling back to local mode. Now, ABQ +will exit with an error. + ## 1.6.3 ABQ 1.6.3 is a patch release. diff --git a/Cargo.lock b/Cargo.lock index 9289abad..1ea67275 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "abq" -version = "1.6.3" +version = "1.6.4" dependencies = [ "abq_dot_reporter", "abq_hosted", diff --git a/crates/abq_cli/Cargo.toml b/crates/abq_cli/Cargo.toml index 0f3213d1..c02c8501 100644 --- a/crates/abq_cli/Cargo.toml +++ b/crates/abq_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "abq" -version = "1.6.3" +version = "1.6.4" edition = "2021" [dependencies] diff --git a/crates/abq_cli/src/main.rs b/crates/abq_cli/src/main.rs index b33f566f..1e51e108 100644 --- a/crates/abq_cli/src/main.rs +++ b/crates/abq_cli/src/main.rs @@ -664,7 +664,7 @@ struct QueueLocationConfig { fn determine_queue_location(config: QueueLocationConfig) -> QueueLocation { match config.access_token_kind { - Some(AccessTokenKind::Personal) => { + Some(_) => { match ( config.run_id_provided, config.usage_error_from_api, @@ -680,7 +680,7 @@ fn determine_queue_location(config: QueueLocationConfig) -> QueueLocation { }, } } - _ => match config.queue_addr { + None => match config.queue_addr { Some(queue_addr) => QueueLocation::Remote(queue_addr), None => QueueLocation::Ephemeral { opt_tls_key: config.tls_key, diff --git a/crates/abq_cli/tests/cli.rs b/crates/abq_cli/tests/cli.rs index 21eb4e5a..ac282a2c 100644 --- a/crates/abq_cli/tests/cli.rs +++ b/crates/abq_cli/tests/cli.rs @@ -4650,6 +4650,115 @@ fn test_run_with_pat_and_run_id_that_doesnt_exist() { term(queue_proc); } +#[test] +#[with_protocol_version] +#[serial] +fn test_unsupported_queue_with_org_access_token() { + let name = "test_unsupported_queue_with_org_access_token"; + let conf = CSConfigOptions { + use_auth_token: true, + tls: true, + }; + let (queue_proc, ..) = setup_queue!(name, conf); + + let access_token = test_access_token(); + + { + let mut server = Server::new(); + let in_run_id = "test-run-id"; + let queue_mock = server + .mock("GET", "/queue") + .match_header("Authorization", format!("Bearer {}", access_token).as_str()) + .match_header("User-Agent", format!("abq/{}", abq_utils::VERSION).as_str()) + .match_query(Matcher::AnyOf(vec![Matcher::UrlEncoded( + "run_id".to_string(), + in_run_id.to_string(), + )])) + .with_status(200) + .with_header("content-type", "application/json") + .with_body( + json!({ + "usage_error": "Your ABQ version is not supported.", + "rwx_access_token_kind": "organization_access_token", + }) + .to_string(), + ) + .expect(2) + .create(); + + let test_args = { + let args = vec![ + format!("test"), + format!("--worker=1"), + format!("--run-id=test-run-id"), + format!("--access-token={access_token}"), + format!("-n=1"), + ]; + let mut args = conf.extend_args_for_client(args); + args.extend([s!("--"), s!("false")]); + args + }; + + let CmdOutput { + exit_status, + stderr, + stdout, + } = Abq::new(format!("{name}_initial")) + .args(test_args) + .always_capture_stderr(true) + .env([("ABQ_API", server.url())]) + .run(); + + assert!( + !exit_status.success(), + "STDOUT:\n{stdout}\nSTDERR:\n{stderr}" + ); + assert!( + stderr.contains( + "ABQ was unable to find a queue to run against. Your ABQ version is not supported." + ), + "STDOUT:\n{stdout}\nSTDERR:\n{stderr}" + ); + + // abq report --reporter dot --queue-addr ... --run-id ... (--token ...)? + let report_args = { + let args = vec![ + format!("report"), + format!("--reporter=dot"), + format!("--run-id=test-run-id"), + format!("--access-token={access_token}"), + format!("--color=never"), + ]; + conf.extend_args_for_client(args) + }; + + let CmdOutput { + stdout, + stderr, + exit_status, + } = Abq::new(name.to_string() + "_report") + .args(report_args) + .always_capture_stderr(true) + .env([("ABQ_API", server.url())]) + .run(); + + assert!( + !exit_status.success(), + "STDOUT:\n{stdout}\nSTDERR:\n{stderr}" + ); + assert!( + stderr.contains( + "ABQ was unable to find a queue to run against. Your ABQ version is not supported." + ), + "STDOUT:\n{stdout}\nSTDERR:\n{stderr}" + ); + + queue_mock.assert(); + } + + term(queue_proc); +} + #[test] #[with_protocol_version] #[serial]