From a1e09caddf27429fe37693fac92d43b4e14ff997 Mon Sep 17 00:00:00 2001 From: dawkaka Date: Sat, 22 Jul 2023 14:57:09 +0000 Subject: [PATCH 1/7] remove nested request --- src/base_request.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/base_request.rs b/src/base_request.rs index 33c6a48..fc9ad1c 100644 --- a/src/base_request.rs +++ b/src/base_request.rs @@ -22,6 +22,7 @@ pub struct TestPlan { pub struct TestStage { name: Option, dump: Option, + #[serde(flatten)] request: RequestConfig, #[serde_as(as = "EnumMap")] asserts: Vec, @@ -316,7 +317,6 @@ fn format_url( let target_key = elements.last().unwrap_or(&""); let output_key = format!("{}_{}", target_stage, target_key); if let Some(value) = outputs.get(&output_key) { - println!("{}", value); url = url.replace(&var, &value.to_string()); } else { return Err(AssertionError { @@ -607,12 +607,11 @@ mod tests { --- - name: stage1 stages: - - request: - POST: {} - headers: - Content-Type: application/json - json: - task: hit the gym + - POST: {} + headers: + Content-Type: application/json + json: + task: hit the gym asserts: ok: $.resp.json.task == "hit the gym" ok: $.resp.status == 201 @@ -621,10 +620,10 @@ mod tests { boolean: $.resp.json.completed outputs: todoResp: $.resp.json.resp_string - - request: - GET: {} - json: - req_string: $.outputs.todoResp + + - GET: {} + json: + req_string: $.outputs.todoResp asserts: ok: $.resp.status == 200 array: $.resp.json.tasks @@ -635,13 +634,11 @@ mod tests { null: $.resp.json.null_val outputs: todoId: $.resp.json.tasks[0].id - - request: - PUT: {} + - PUT: {} asserts: ok: $.resp.json.completed ok: $.resp.json.id == $.stages[1].outputs.todoId - - request: - DELETE: {} + - DELETE: {} asserts: ok: $.resp.json.id == $.stages[-2].outputs.todoId boolean: $.resp.json.completed From eabcf2320233b8020ae5db033866a7e641c1876a Mon Sep 17 00:00:00 2001 From: dawkaka Date: Sat, 22 Jul 2023 14:57:27 +0000 Subject: [PATCH 2/7] remove nested request --- test.tp.yaml | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/test.tp.yaml b/test.tp.yaml index 84dfd1e..721931b 100644 --- a/test.tp.yaml +++ b/test.tp.yaml @@ -1,12 +1,11 @@ --- - name: stage1 stages: - - request: - POST: http://localhost:3000/todos - headers: - Content-Type: application/json - json: - number: 5 + - POST: http://localhost:3000/todos + headers: + Content-Type: application/json + json: + number: 5 asserts: ok: $.resp.json.number == 5 ok: $.resp.status == 201 @@ -16,8 +15,7 @@ - name: TODO api testing stages: - name: fetches TODO items - GET - request: - GET: http://localhost:3000/todos + GET: http://localhost:3000/todos asserts: ok: $.resp.status == 200 array: $.resp.json.tasks @@ -28,31 +26,28 @@ null: $.resp.json.resp_null - name: TODO ad items - POST - request: - POST: http://localhost:3000/todos - headers: - Content-Type: application/json - json: - task: "run tests" + POST: http://localhost:3000/todos + headers: + Content-Type: application/json + json: + task: "run tests" asserts: ok: $.resp.status == 201 outputs: todoItem: $.resp.json.id - name: deletes TODO items - DELETE - request: - DELETE: "http://localhost:3000/todos/$.stages[1].outputs.todoItem" + DELETE: "http://localhost:3000/todos/$.stages[1].outputs.todoItem" asserts: string: $.resp.json.task number: $.resp.json.id ok: $.resp.json.id == $.stages[-1].outputs.todoItem - name: Adds Todo item - POST - request: - POST: http://localhost:3000/todos/ - json: - task: "run tests" + POST: http://localhost:3000/todos/ + json: + task: "run tests" asserts: ok: $.resp.status == 201 ok: $.resp.json.task == "run tests" - #ok: $.resp.json.completed + #ok: $.resp.json.completed \ No newline at end of file From 3284027636fd76a65da6c2df180556d865d7b5a2 Mon Sep 17 00:00:00 2001 From: dawkaka Date: Sat, 22 Jul 2023 19:28:29 +0000 Subject: [PATCH 3/7] feat: add env variables support --- .env | 1 + Cargo.toml | 1 + src/base_request.rs | 98 ++++++++++++++++++++++++++++++++------------- src/main.rs | 4 ++ test.tp.yaml | 2 +- 5 files changed, 77 insertions(+), 29 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..92c5810 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +STATUS=201 \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 6bf1e7f..9be26db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ rhai = "1.15.0" jsonpath_lib = "0.3.0" jsonpath = "0.1.1" regex = "1.8.4" +dotenv = "0.15.0" anyhow = "1.0" claim = "0.5.0" miette = {version="5.9.0", features=["fancy"]} diff --git a/src/base_request.rs b/src/base_request.rs index fc9ad1c..ac4095e 100644 --- a/src/base_request.rs +++ b/src/base_request.rs @@ -9,6 +9,8 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use serde_with::{serde_as, EnumMap}; use std::collections::HashMap; +use std::env; +use std::env::VarError; use thiserror::Error; #[derive(Debug, Serialize, Deserialize)] @@ -169,22 +171,10 @@ pub async fn base_request( ctx.stage.clone().unwrap_or(ctx.stage_index.to_string()) ); let mut request_builder = match &stage.request.http_method { - HttpMethod::GET(url) => { - let url = format_url(&ctx, url, &outputs_map)?; - client.get(url) - } - HttpMethod::POST(url) => { - let url = format_url(&ctx, url, &outputs_map)?; - client.post(url) - } - HttpMethod::PUT(url) => { - let url = format_url(&ctx, url, &outputs_map)?; - client.put(url) - } - HttpMethod::DELETE(url) => { - let url = format_url(&ctx, url, &outputs_map)?; - client.delete(url) - } + HttpMethod::GET(url) => client.get(format_url(&ctx, url, &outputs_map)), + HttpMethod::POST(url) => client.post(format_url(&ctx, url, &outputs_map)), + HttpMethod::PUT(url) => client.put(format_url(&ctx, url, &outputs_map)), + HttpMethod::DELETE(url) => client.delete(format_url(&ctx, url, &outputs_map)), }; if let Some(headers) = &stage.request.headers { for (name, value) in headers { @@ -194,6 +184,16 @@ pub async fn base_request( let v = value.replace(&normalized_jsonp_key, &v.to_string()); value = v.to_owned(); } + for env_var in get_env_variable_paths(&value) { + match get_env_variable(&env_var) { + Ok(val) => value = value.replace(&env_var, &val), + Err(err) => { + let error_message = + format!("Error getting environment variable {}: {}", env_var, err); + log::error!(target:"testkit","{}", error_message) + } + } + } request_builder = request_builder.header(name, value); } } @@ -207,6 +207,16 @@ pub async fn base_request( let normalized_jsonp_key = format!("$.outputs.{}", k); j_string = j_string.replace(&normalized_jsonp_key, &v.to_string()); } + for env_var in get_env_variable_paths(&j_string) { + match get_env_variable(&env_var) { + Ok(val) => j_string = j_string.replace(&env_var, &val), + Err(err) => { + let error_message = + format!("Error getting environment variable {}: {}", env_var, err); + log::error!(target:"testkit","{}", error_message) + } + } + } let clean_json: Value = serde_json::from_str(&j_string)?; request_builder = request_builder.json(&clean_json); } @@ -298,12 +308,12 @@ fn get_var_stage(input: &str, current_stage: u32) -> Option { } } -// Replacce output variables with actual values in request url +// Replace output variables with actual values in request url fn format_url( ctx: &TestContext, original_url: &String, outputs: &HashMap, -) -> Result { +) -> String { let mut url = original_url.clone(); let output_vars: Vec = url .split("/") @@ -319,17 +329,22 @@ fn format_url( if let Some(value) = outputs.get(&output_key) { url = url.replace(&var, &value.to_string()); } else { - return Err(AssertionError { - advice: Some(format!( - "{}: could not resolve output variable path to any real value", - var - )), - src: NamedSource::new(&ctx.file, var.clone()), - bad_bit: (0, var.len()).into(), - }); + let error_message = format!("Output variable not found: {}", var); + log::error!(target:"testkit","{}", error_message) } } - Ok(url) + + for env_var in get_env_variable_paths(&original_url) { + match get_env_variable(&env_var) { + Ok(val) => url = url.replace(&env_var, &val), + Err(err) => { + let error_message = + format!("Error getting environment variable {}: {}", env_var, err); + log::error!(target:"testkit","{}", error_message) + } + } + } + url } fn find_all_output_vars( @@ -355,6 +370,21 @@ fn find_all_output_vars( val_map } +fn get_env_variable_paths(val: &String) -> Vec { + let regex_pattern = r#"\$\.(env\.[A-Za-z_][A-Za-z0-9_]*)"#; + let regex = Regex::new(regex_pattern).unwrap(); + let env_vars: Vec = regex + .find_iter(&val) + .map(|v| v.as_str().to_string()) + .collect(); + env_vars +} + +fn get_env_variable(env_key_path: &String) -> Result { + let key = env_key_path.split(".").last().unwrap_or_default(); + env::var(key) +} + // 1. First we extract a list of jsonpaths // 2. Build a json with all the fields which can be referenced via jsonpath // 3. Apply the jsonpaths over this json and save their values to a map @@ -385,6 +415,18 @@ fn evaluate_expressions<'a, T: Clone + 'static>( }); } } + + for env_var in get_env_variable_paths(&original_expr) { + match get_env_variable(&env_var) { + Ok(val) => expr = expr.replace(&env_var, &val), + Err(err) => { + let error_message = + format!("Error getting environment variable {}: {}", env_var, err); + log::error!(target:"testkit","{}", error_message) + } + } + } + for path in paths { match select(&object, &path) { Ok(selected_value) => { @@ -614,7 +656,7 @@ mod tests { task: hit the gym asserts: ok: $.resp.json.task == "hit the gym" - ok: $.resp.status == 201 + ok: $.resp.status == $.env.STATUS number: $.resp.json.id string: $.resp.json.task boolean: $.resp.json.completed diff --git a/src/main.rs b/src/main.rs index 5e2e2ef..54d9564 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,13 +3,17 @@ mod base_request; extern crate log; use base_cli::BaseCli; use base_request::TestContext; +extern crate dotenv; +use dotenv::dotenv; use env_logger::Builder; use log::LevelFilter; +use std::env; use std::fs; use std::str::FromStr; #[tokio::main] async fn main() { + dotenv().ok(); let base_cli = BaseCli::parse(); let mut builder = Builder::from_default_env(); diff --git a/test.tp.yaml b/test.tp.yaml index 721931b..8ec89f1 100644 --- a/test.tp.yaml +++ b/test.tp.yaml @@ -8,7 +8,7 @@ number: 5 asserts: ok: $.resp.json.number == 5 - ok: $.resp.status == 201 + ok: $.resp.status == $.env.STATUS number: $.resp.json.number outputs: null From 8334c741944f8a98429562f8f7043c24a864a677 Mon Sep 17 00:00:00 2001 From: dawkaka Date: Sun, 23 Jul 2023 12:14:42 +0000 Subject: [PATCH 4/7] add exist assertion --- src/base_request.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/base_request.rs b/src/base_request.rs index ac4095e..88b4f8b 100644 --- a/src/base_request.rs +++ b/src/base_request.rs @@ -47,6 +47,8 @@ pub enum Assert { IsBoolean(String), #[serde(rename = "null")] IsNull(String), + #[serde(rename = "exist")] + Exist(String), // Add other assertion types as needed } @@ -474,6 +476,9 @@ fn evaluate_value<'a, T: Clone + 'static>( match select(&object, expr) { Ok(selected_value) => { if let Some(selected_value) = selected_value.first() { + if value_type == "exist" { + return Ok((true, expr.clone())); + } match selected_value { Value::Array(v) => { if value_type == "empty" { @@ -543,6 +548,8 @@ async fn check_assertions( } Assert::IsNull(expr) => evaluate_value::(ctx.clone(), expr, &json_body, "null") .map(|(e, eval_expr)| ("NULL ", e == true, expr, eval_expr)), + Assert::Exist(expr) => evaluate_value::(ctx.clone(), expr, &json_body, "exist") + .map(|(e, eval_expr)| ("NULL ", e == true, expr, eval_expr)), }; match eval_result { From e25a76d090b2464b5898efdc7b465c41cf7a93e8 Mon Sep 17 00:00:00 2001 From: dawkaka Date: Sun, 23 Jul 2023 19:24:19 +0000 Subject: [PATCH 5/7] feat: real world postman collection to testkit --- .gitignore | 3 +- realworld.yaml | 533 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 535 insertions(+), 1 deletion(-) create mode 100644 realworld.yaml diff --git a/.gitignore b/.gitignore index f72af91..53bafb2 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ Cargo.lock test_server/node_modules/ node_modules/ -.vscode \ No newline at end of file +.vscode +.env \ No newline at end of file diff --git a/realworld.yaml b/realworld.yaml new file mode 100644 index 0000000..741e4a0 --- /dev/null +++ b/realworld.yaml @@ -0,0 +1,533 @@ +--- +- name: Auth + stages: + - name: Register + POST: '$.env.APIURL/users' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + json: '{"user":{"email":"$.env.EMAIL", "password":"$.env.PASSWORD", "username":"$.env.USERNAME"}}' + asserts: + exists: $.resp.json.user + exists: $.resp.json.user.email + exists: $.resp.json.user.username + exists: $.resp.json.user.bio + exists: $.resp.json.user.image + exists: $.resp.json.user.token + - name: Login + POST: '$.env.APIURL/users/login' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + json: '{"user":{"email":"$.env.EMAIL", "password":"$.env.PASSWORD"}}' + asserts: + exists: $.resp.body.json.user + exists: $.resp.body.json.user.email + exists: $.resp.body.json.user.username + exists: $.resp.body.json.user.bio + exists: $.resp.body.json.user.image + exists: $.resp.body.json.user.token + + - name: Login and Remember Token + POST: '$.env.APIURL/users/login' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + json: '{"user":{"email":"$.env.EMAIL", "password":"$.env.PASSWORD"}}' + asserts: + exists: $.resp.body.json.user + exists: $.resp.body.json.user.email + exists: $.resp.body.json.user.username + exists: $.resp.body.json.user.bio + exists: $.resp.body.json.user.image + exists: $.resp.body.json.user.token + + - name: Current User + GET: '$.env.APIURL/user' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: 'Token $.env.TOKEN' + asserts: + exists: $.resp.json.user + exists: $.resp.json.user.email + exists: $.resp.json.user.username + exists: $.resp.json.user.bio + exists: $.resp.json.user.image + exists: $.resp.json.user.token + + - name: Update User + PUT: '$.env.APIURL/user' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: 'Token $.env.TOKEN' + json: '{"user":{"email":"$.env.EMAIL"}}' + asserts: + exists: $.resp.json.user + exists: $.resp.json.user.email + exists: $.resp.json.user.username + exists: $.resp.json.user.bio + exists: $.resp.json.user.image + exists: $.resp.json.user.token +- name: Articles + stages: + - name: Get All Articles + GET: '$.env.APIURL/articles' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.articles + array: $.resp.body.json.articles + exists: $.resp.body.json.articlesCount + number: $.resp.body.json.articlesCount + exists: $.resp.body.json.articles[0].title + exists: $.resp.body.json.articles[0].slug + exists: $.resp.body.json.articles[0].body + exists: $.resp.body.json.articles[0].createdAt + date: $.resp.body.json.articles[0].createdAt + exists: $.resp.body.json.articles[0].updatedAt + date: $.resp.body.json.articles[0].updatedAt + exists: $.resp.body.json.articles[0].description + exists: $.resp.body.json.articles[0].tagList + array: $.resp.body.json.articles[0].tagList + exists: $.resp.body.json.articles[0].author + exists: $.resp.body.json.articles[0].favorited + exists: $.resp.body.json.articles[0].favoritesCount + number: $.resp.body.json.articles[0].favoritesCount + - name: Get Articles by Author + GET: $.env.APIURL/articles?author=johnjacob + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.articles + array: $.resp.body.json.articles + exists: $.resp.body.json.articlesCount + number: $.resp.body.json.articlesCount + exists: $.resp.body.json.articles[0].title + exists: $.resp.body.json.articles[0].slug + exists: $.resp.body.json.articles[0].body + exists: $.resp.body.json.articles[0].createdAt + date: $.resp.body.json.articles[0].createdAt + exists: $.resp.body.json.articles[0].updatedAt + date: $.resp.body.json.articles[0].updatedAt + exists: $.resp.body.json.articles[0].description + exists: $.resp.body.json.articles[0].tagList + array: $.resp.body.json.articles[0].tagList + exists: $.resp.body.json.articles[0].author + exists: $.resp.body.json.articles[0].favorited + boolean: $.resp.body.json.articles[0].favorited + exists: $.resp.body.json.articles[0].favoritesCount + number: $.resp.body.json.articles[0].favoritesCount + ok: $.resp.body.json.articlesCount == $.resp.body.json.articles.length() + - name: Get Articles Favorited by Username + GET: $.envn.APIURL/articles?favorited=$.envn.USERNAME + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.articles + array: $.resp.body.json.articles + exists: $.resp.body.json.articlesCount + number: $.resp.body.json.articlesCount + exists: $.resp.body.json.articles[0].title + exists: $.resp.body.json.articles[0].slug + exists: $.resp.body.json.articles[0].body + exists: $.resp.body.json.articles[0].createdAt + date: $.resp.body.json.articles[0].createdAt + exists: $.resp.body.json.articles[0].updatedAt + date: $.resp.body.json.articles[0].updatedAt + exists: $.resp.body.json.articles[0].description + exists: $.resp.body.json.articles[0].tagList + array: $.resp.body.json.articles[0].tagList + exists: $.resp.body.json.articles[0].author + exists: $.resp.body.json.articles[0].favorited + exists: $.resp.body.json.articles[0].favoritesCount + number: $.resp.body.json.articles[0].favoritesCount + ok: $.resp.body.json.articlesCount == $.resp.body.json.articles.length() + - name: Get Articles by Tag + GET: $.env.APIURL/articles?tag=dragons + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.articles + array: $.resp.body.json.articles + exists: $.resp.body.json.articlesCount + number: $.resp.body.json.articlesCount + exists: $.resp.body.json.articles[0].title + exists: $.resp.body.json.articles[0].slug + exists: $.resp.body.json.articles[0].body + exists: $.resp.body.json.articles[0].createdAt + date: $.resp.body.json.articles[0].createdAt + exists: $.resp.body.json.articles[0].updatedAt + date: $.resp.body.json.articles[0].updatedAt + exists: $.resp.body.json.articles[0].description + exists: $.resp.body.json.articles[0].tagList + array: $.resp.body.json.articles[0].tagList + exists: $.resp.body.json.articles[0].author + exists: $.resp.body.json.articles[0].favorited + exists: $.resp.body.json.articles[0].favoritesCount + number: $.resp.body.json.articles[0].favoritesCount + ok: $.resp.body.json.articlesCount == $.resp.body.json.articles.length() + - name: Create an Article + POST: $.env.APIURL/articles + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.token + json: '{"article":{"title":"How to train your dragon", "description":"Ever wonder how?", "body":"Very carefully.", "tagList":["training", "dragons"]}}' + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.article + eq: $.resp.body.json.article.title, "How to train your dragon" + eq: $.resp.body.json.article.description, "Ever wonder how?" + eq: $.resp.body.json.article.body, "Very carefully." + eq: $.resp.body.json.article.tagList, ["training", "dragons"] + date: $.resp.body.json.article.createdAt + date: $.resp.body.json.article.updatedAt + exists: $.resp.body.json.article.author + ok: $.resp.body.json.article.favorited == false + ok: $.resp.body.json.article.favoritesCount == 0 + - name: Get Feed Articles + GET: $.env.APIURL/articles/feed + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.token + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.articles + array: $.resp.body.json.articles + exists: $.resp.body.json.articlesCount + number: $.resp.body.json.articlesCount + ok: $.resp.body.json.articlesCount, $.resp.body.json.articles.length + ok: $.resp.body.json.articles.length() > 0 + exists: $.resp.body.json.articles[0].title + exists: $.resp.body.json.articles[0].slug + exists: $.resp.body.json.articles[0].body + exists: $.resp.body.json.articles[0].createdAt + date: $.resp.body.json.articles[0].createdAt + exists: $.resp.body.json.articles[0].updatedAt + date: $.resp.body.json.articles[0].updatedAt + exists: $.resp.body.json.articles[0].description + exists: $.resp.body.json.articles[0].tagList + array: $.resp.body.json.articles[0].tagList + exists: $.resp.body.json.articles[0].author + exists: $.resp.body.json.articles[0].favorited + exists: $.resp.body.json.articles[0].favoritesCount + number: $.resp.body.json.articles[0].favoritesCount + - name: Get Articles by Author + request: + method: GET + url: + raw: '$.envn.APIURL/articles?author=$.envn.USERNAME' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + - key: Authorization + value: Token $.envn.TOKEN + body: + mode: raw + raw: '' + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.articles + array: $.resp.body.json.articles + exists: $.resp.body.json.articlesCount + number: $.resp.body.json.articlesCount + ok: $.resp.body.json.articlesCount == $.resp.body.json.articles.length() + exists: $.resp.body.json.articles[0].title + exists: $.resp.body.json.articles[0].slug + exists: $.resp.body.json.articles[0].body + exists: $.resp.body.json.articles[0].createdAt + date: $.resp.body.json.articles[0].createdAt + exists: $.resp.body.json.articles[0].updatedAt + date: $.resp.body.json.articles[0].updatedAt + exists: $.resp.body.json.articles[0].description + exists: $.resp.body.json.articles[0].tagList + array: $.resp.body.json.articles[0].tagList + exists: $.resp.body.json.articles[0].author + exists: $.resp.body.json.articles[0].favorited + exists: $.resp.body.json.articles[0].favoritesCount + number: $.resp.body.json.articles[0].favoritesCount + - name: Get Single Article by Slug + GET: $.envn.APIURL/articles/{{slug}}' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.envn.TOKEN + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.article + exists: $.resp.body.json.article.title + exists: $.resp.body.json.article.slug + exists: $.resp.body.json.article.body + exists: $.resp.body.json.article.createdAt + date: $.resp.body.json.article.createdAt + exists: $.resp.body.json.article.updatedAt + date: $.resp.body.json.article.updatedAt + exists: $.resp.body.json.article.description + exists: $.resp.body.json.article.tagList + array: $.resp.body.json.article.tagList + exists: $.resp.body.json.article.author + exists: $.resp.body.json.article.favorited + exists: $.resp.body.json.article.favoritesCount + number: $.resp.body.json.article.favoritesCount + - name: Articles by Tag + GET: '$.env.APIURL/articles?tag=dragons' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + asserts: + ok: $.resp.status == 200 + exist: $.resp.body.json.articles + exists: $.resp.body.json.articlesCount + number: $.resp.body.json.articlesCount + exist: $.resp.body.json.articles[0] + exists: $.resp.body.json.articles[0].title + exists: $.resp.body.json.articles[0].slug + exists: $.resp.body.json.articles[0].body + exists: $.resp.body.json.articles[0].createdAt + date: $.resp.body.json.articles[0].createdAt + exists: $.resp.body.json.articles[0].updatedAt + date: $.resp.body.json.articles[0].updatedAt + exists: $.resp.body.json.articles[0].description + exists: $.resp.body.json.articles[0].tagList + array: $.resp.body.json.articles[0].tagList + ok: $.resp.body.json.articles[0].tagList[0] == dragons + ok: $.resp.body.json.articles[0].tagList[1] == training + exists: $.resp.body.json.articles[0].author + exists: $.resp.body.json.articles[0].favorited + exists: $.resp.body.json.articles[0].favoritesCount + number: $.resp.body.json.articles[0].favoritesCount + - name: Update Article + PUT: '$.env.APIURL/articles/{{slug}}' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + json: '{"article":{"body":"With two hands"}}' + asserts: + ok: $.resp.status == 200 + exist: $.resp.body.json.article + exists: $.resp.body.json.article.title + exists: $.resp.body.json.article.slug + exists: $.resp.body.json.article.body + exists: $.resp.body.json.article.createdAt + date: $.resp.body.json.article.createdAt + exists: $.resp.body.json.article.updatedAt + date: $.resp.body.json.article.updatedAt + exists: $.resp.body.json.article.description + exists: $.resp.body.json.article.tagList + array: $.resp.body.json.article.tagList + exists: $.resp.body.json.article.author + exists: $.resp.body.json.article.favorited + exists: $.resp.body.json.article.favoritesCount + number: $.resp.body.json.article.favoritesCount + - name: Favorite Article + POST: '$.env.APIURL/articles/{{slug}}/favorite' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + asserts: + ok: $.resp.status == 200 + exist: $.resp.body.json.article + exists: $.resp.body.json.article.title + exists: $.resp.body.json.article.slug + exists: $.resp.body.json.article.body + exists: $.resp.body.json.article.createdAt + date: $.resp.body.json.article.createdAt + exists: $.resp.body.json.article.updatedAt + date: $.resp.body.json.article.updatedAt + exists: $.resp.body.json.article.description + exists: $.resp.body.json.article.tagList + array: $.resp.body.json.article.tagList + exists: $.resp.body.json.article.author + exists: $.resp.body.json.article.favorited + ok: $.resp.body.json.article.favorited == true + exists: $.resp.body.json.article.favoritesCount + number: $.resp.body.json.article.favoritesCount + ok: $.resp.body.json.article.favoritesCount > 0 + - name: Articles Favorited by Username + GET: '$.env.APIURL/articles?favorited={{USERNAME}}' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + asserts: + ok: $.resp.status == 200 + exist: $.resp.body.json.articles + exists: $.resp.body.json.articlesCount + number: $.resp.body.json.articlesCount + exist: $.resp.body.json.articles[0] + exists: $.resp.body.json.articles[0].title + exists: $.resp.body.json.articles[0].slug + exists: $.resp.body.json.articles[0].body + exists: $.resp.body.json.articles[0].createdAt + date: $.resp.body.json.articles[0].createdAt + exists: $.resp.body.json.articles[0].updatedAt + date: $.resp.body.json.articles[0].updatedAt + exists: $.resp.body.json.articles[0].description + exists: $.resp.body.json.articles[0].tagList + array: $.resp.body.json.articles[0].tagList + exists: $.resp.body.json.articles[0].author + exists: $.resp.body.json.articles[0].favorited + ok: $.resp.body.json.articles[0].favorited, true + exists: $.resp.body.json.articles[0].favoritesCount + number: $.resp.body.json.articles[0].favoritesCount + ok: $.resp.body.json.articles[0].favoritesCount == 1 + - name: Unfavorite Article + DELETE: '$.env.APIURL/articles/{{slug}}/favorite' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + asserts: + ok: $.resp.status == 200 + exist: $.resp.body.json.article + exists: $.resp.body.json.article.title + exists: $.resp.body.json.article.slug + exists: $.resp.body.json.article.body + exists: $.resp.body.json.article.createdAt + date: $.resp.body.json.article.createdAt + exists: $.resp.body.json.article.updatedAt + date: $.resp.body.json.article.updatedAt + exists: $.resp.body.json.article.description + exists: $.resp.body.json.article.tagList + array: $.resp.body.json.article.tagList + exists: $.resp.body.json.article.author + exists: $.resp.body.json.article.favorited + eq: $.resp.body.json.article.favorited, false + exists: $.resp.body.json.article.favoritesCount + number: $.resp.body.json.article.favoritesCount + - name: Create Comment for Article + POST: '$.env.APIURL/articles/{{slug}}/comments' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + json: '{"comment":{"body":"Thank you so much!"}}' + asserts: + ok: $.resp.status == 200 + exist: $.resp.body.json.comment + exists: $.resp.body.json.comment.id + exists: $.resp.body.json.comment.body + exists: $.resp.body.json.comment.createdAt + date: $.resp.body.json.comment.createdAt + exists: $.resp.body.json.comment.updatedAt + date: $.resp.body.json.comment.updatedAt + exists: $.resp.body.json.comment.author + - name: All Comments for Article + GET: '$.env.APIURL/articles/{{slug}}/comments' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + asserts: + ok: $.resp.status == 200 + exist: $.resp.body.json.comments + exists: $.resp.body.json.comments[0].id + exists: $.resp.body.json.comments[0].body + exists: $.resp.body.json.comments[0].createdAt + date: $.resp.body.json.comments[0].createdAt + exists: $.resp.body.json.comments[0].updatedAt + date: $.resp.body.json.comments[0].updatedAt + exists: $.resp.body.json.comments[0].author + - name: All Comments for Article without login + GET: '$.env.APIURL/articles/{{slug}}/comments' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + asserts: + ok: $.resp.status == 200 + exist: $.resp.body.json.comments + exists: $.resp.body.json.comments[0].id + exists: $.resp.body.json.comments[0].body + exists: $.resp.body.json.comments[0].createdAt + date: $.resp.body.json.comments[0].createdAt + exists: $.resp.body.json.comments[0].updatedAt + date: $.resp.body.json.comments[0].updatedAt + exists: $.resp.body.json.comments[0].author + - name: Delete Comment for Article + DELETE: '$.env.APIURL/articles/{{slug}}/comments/{{commentId}}' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + asserts: + ok: $.resp.status == 200 + exist: $.resp.body.json.comment + exists: $.resp.body.json.comment.id + exists: $.resp.body.json.comment.body + exists: $.resp.body.json.comment.createdAt + date: $.resp.body.json.comment.createdAt + exists: $.resp.body.json.comment.updatedAt + date: $.resp.body.json.comment.updatedAt + exists: $.resp.body.json.comment.author + - name: Delete Article + DELETE: '$.env.APIURL/articles/{{slug}}' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + asserts: + ok: $.resp.status == 200 + - name: Profile + GET: '$.env.APIURL/profiles/celeb_{{USERNAME}}' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.profile + exists: $.resp.body.json.profile.username + exists: $.resp.body.json.profile.bio + exists: $.resp.body.json.profile.image + exists: $.resp.body.json.profile.following + - name: Follow Profile + POST: '$.env.APIURL/profiles/celeb_{{USERNAME}}/follow' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + Authorization: Token $.env.TOKEN + json: '{"user":{"email":"{{EMAIL}}"}}' + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.profile + exists: $.resp.body.json.profile.username + exists: $.resp.body.json.profile.bio + exists: $.resp.body.json.profile.image + exists: $.resp.body.json.profile.following + ok: $.resp.body.json.profile.following == true + - name: Unfollow Profile + DELETE: '$.env.APIURL/profiles/celeb_{{USERNAME}}/follow' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.profile + exists: $.resp.body.json.profile.username + exists: $.resp.body.json.profile.bio + exists: $.resp.body.json.profile.image + exists: $.resp.body.json.profile.following + ok: $.resp.body.json.profile.following == false + - name: All Tags + GET: '$.env.APIURL/tags' + headers: + Content-Type: application/json + X-Requested-With: XMLHttpRequest + asserts: + ok: $.resp.status == 200 + exists: $.resp.body.json.tags + array: $.resp.body.json.tags \ No newline at end of file From d9ab71d2d1d10963abe3d35b83338bd61f5388a3 Mon Sep 17 00:00:00 2001 From: dawkaka Date: Mon, 24 Jul 2023 16:26:38 +0000 Subject: [PATCH 6/7] exist to exists --- src/base_request.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/base_request.rs b/src/base_request.rs index 88b4f8b..bac82c1 100644 --- a/src/base_request.rs +++ b/src/base_request.rs @@ -47,8 +47,8 @@ pub enum Assert { IsBoolean(String), #[serde(rename = "null")] IsNull(String), - #[serde(rename = "exist")] - Exist(String), + #[serde(rename = "exists")] + Exists(String), // Add other assertion types as needed } @@ -476,7 +476,7 @@ fn evaluate_value<'a, T: Clone + 'static>( match select(&object, expr) { Ok(selected_value) => { if let Some(selected_value) = selected_value.first() { - if value_type == "exist" { + if value_type == "exists" { return Ok((true, expr.clone())); } match selected_value { @@ -548,7 +548,7 @@ async fn check_assertions( } Assert::IsNull(expr) => evaluate_value::(ctx.clone(), expr, &json_body, "null") .map(|(e, eval_expr)| ("NULL ", e == true, expr, eval_expr)), - Assert::Exist(expr) => evaluate_value::(ctx.clone(), expr, &json_body, "exist") + Assert::Exists(expr) => evaluate_value::(ctx.clone(), expr, &json_body, "exists") .map(|(e, eval_expr)| ("NULL ", e == true, expr, eval_expr)), }; From 56006ead616112203b2823037196e9993a2a023e Mon Sep 17 00:00:00 2001 From: dawkaka Date: Mon, 24 Jul 2023 16:26:59 +0000 Subject: [PATCH 7/7] date to string --- realworld.yaml | 112 ++++++++++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 47 deletions(-) diff --git a/realworld.yaml b/realworld.yaml index 741e4a0..f7b70db 100644 --- a/realworld.yaml +++ b/realworld.yaml @@ -87,9 +87,9 @@ exists: $.resp.body.json.articles[0].slug exists: $.resp.body.json.articles[0].body exists: $.resp.body.json.articles[0].createdAt - date: $.resp.body.json.articles[0].createdAt + string: $.resp.body.json.articles[0].createdAt exists: $.resp.body.json.articles[0].updatedAt - date: $.resp.body.json.articles[0].updatedAt + string: $.resp.body.json.articles[0].updatedAt exists: $.resp.body.json.articles[0].description exists: $.resp.body.json.articles[0].tagList array: $.resp.body.json.articles[0].tagList @@ -112,9 +112,9 @@ exists: $.resp.body.json.articles[0].slug exists: $.resp.body.json.articles[0].body exists: $.resp.body.json.articles[0].createdAt - date: $.resp.body.json.articles[0].createdAt + string: $.resp.body.json.articles[0].createdAt exists: $.resp.body.json.articles[0].updatedAt - date: $.resp.body.json.articles[0].updatedAt + string: $.resp.body.json.articles[0].updatedAt exists: $.resp.body.json.articles[0].description exists: $.resp.body.json.articles[0].tagList array: $.resp.body.json.articles[0].tagList @@ -139,9 +139,9 @@ exists: $.resp.body.json.articles[0].slug exists: $.resp.body.json.articles[0].body exists: $.resp.body.json.articles[0].createdAt - date: $.resp.body.json.articles[0].createdAt + string: $.resp.body.json.articles[0].createdAt exists: $.resp.body.json.articles[0].updatedAt - date: $.resp.body.json.articles[0].updatedAt + string: $.resp.body.json.articles[0].updatedAt exists: $.resp.body.json.articles[0].description exists: $.resp.body.json.articles[0].tagList array: $.resp.body.json.articles[0].tagList @@ -165,9 +165,9 @@ exists: $.resp.body.json.articles[0].slug exists: $.resp.body.json.articles[0].body exists: $.resp.body.json.articles[0].createdAt - date: $.resp.body.json.articles[0].createdAt + string: $.resp.body.json.articles[0].createdAt exists: $.resp.body.json.articles[0].updatedAt - date: $.resp.body.json.articles[0].updatedAt + string: $.resp.body.json.articles[0].updatedAt exists: $.resp.body.json.articles[0].description exists: $.resp.body.json.articles[0].tagList array: $.resp.body.json.articles[0].tagList @@ -190,8 +190,8 @@ eq: $.resp.body.json.article.description, "Ever wonder how?" eq: $.resp.body.json.article.body, "Very carefully." eq: $.resp.body.json.article.tagList, ["training", "dragons"] - date: $.resp.body.json.article.createdAt - date: $.resp.body.json.article.updatedAt + string: $.resp.body.json.article.createdAt + string: $.resp.body.json.article.updatedAt exists: $.resp.body.json.article.author ok: $.resp.body.json.article.favorited == false ok: $.resp.body.json.article.favoritesCount == 0 @@ -213,9 +213,9 @@ exists: $.resp.body.json.articles[0].slug exists: $.resp.body.json.articles[0].body exists: $.resp.body.json.articles[0].createdAt - date: $.resp.body.json.articles[0].createdAt + string: $.resp.body.json.articles[0].createdAt exists: $.resp.body.json.articles[0].updatedAt - date: $.resp.body.json.articles[0].updatedAt + string: $.resp.body.json.articles[0].updatedAt exists: $.resp.body.json.articles[0].description exists: $.resp.body.json.articles[0].tagList array: $.resp.body.json.articles[0].tagList @@ -247,9 +247,9 @@ exists: $.resp.body.json.articles[0].slug exists: $.resp.body.json.articles[0].body exists: $.resp.body.json.articles[0].createdAt - date: $.resp.body.json.articles[0].createdAt + string: $.resp.body.json.articles[0].createdAt exists: $.resp.body.json.articles[0].updatedAt - date: $.resp.body.json.articles[0].updatedAt + string: $.resp.body.json.articles[0].updatedAt exists: $.resp.body.json.articles[0].description exists: $.resp.body.json.articles[0].tagList array: $.resp.body.json.articles[0].tagList @@ -257,8 +257,10 @@ exists: $.resp.body.json.articles[0].favorited exists: $.resp.body.json.articles[0].favoritesCount number: $.resp.body.json.articles[0].favoritesCount + outputs: + slug: $.resp.body.json.articles[0].slug - name: Get Single Article by Slug - GET: $.envn.APIURL/articles/{{slug}}' + GET: $.envn.APIURL/articles/$.stages[-1].slug' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -270,9 +272,9 @@ exists: $.resp.body.json.article.slug exists: $.resp.body.json.article.body exists: $.resp.body.json.article.createdAt - date: $.resp.body.json.article.createdAt + string: $.resp.body.json.article.createdAt exists: $.resp.body.json.article.updatedAt - date: $.resp.body.json.article.updatedAt + string: $.resp.body.json.article.updatedAt exists: $.resp.body.json.article.description exists: $.resp.body.json.article.tagList array: $.resp.body.json.article.tagList @@ -296,9 +298,9 @@ exists: $.resp.body.json.articles[0].slug exists: $.resp.body.json.articles[0].body exists: $.resp.body.json.articles[0].createdAt - date: $.resp.body.json.articles[0].createdAt + string: $.resp.body.json.articles[0].createdAt exists: $.resp.body.json.articles[0].updatedAt - date: $.resp.body.json.articles[0].updatedAt + string: $.resp.body.json.articles[0].updatedAt exists: $.resp.body.json.articles[0].description exists: $.resp.body.json.articles[0].tagList array: $.resp.body.json.articles[0].tagList @@ -308,8 +310,10 @@ exists: $.resp.body.json.articles[0].favorited exists: $.resp.body.json.articles[0].favoritesCount number: $.resp.body.json.articles[0].favoritesCount + outputs: + slug: $.resp.body.json.articles[0].slug - name: Update Article - PUT: '$.env.APIURL/articles/{{slug}}' + PUT: '$.env.APIURL/articles/$.stages[-1].outputs.slug' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -322,9 +326,9 @@ exists: $.resp.body.json.article.slug exists: $.resp.body.json.article.body exists: $.resp.body.json.article.createdAt - date: $.resp.body.json.article.createdAt + string: $.resp.body.json.article.createdAt exists: $.resp.body.json.article.updatedAt - date: $.resp.body.json.article.updatedAt + string: $.resp.body.json.article.updatedAt exists: $.resp.body.json.article.description exists: $.resp.body.json.article.tagList array: $.resp.body.json.article.tagList @@ -332,8 +336,10 @@ exists: $.resp.body.json.article.favorited exists: $.resp.body.json.article.favoritesCount number: $.resp.body.json.article.favoritesCount + outputs: + slug: $.resp.body.json.articles[0].slug - name: Favorite Article - POST: '$.env.APIURL/articles/{{slug}}/favorite' + POST: '$.env.APIURL/articles/$.stages[-1].outputs.slug/favorite' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -345,9 +351,9 @@ exists: $.resp.body.json.article.slug exists: $.resp.body.json.article.body exists: $.resp.body.json.article.createdAt - date: $.resp.body.json.article.createdAt + string: $.resp.body.json.article.createdAt exists: $.resp.body.json.article.updatedAt - date: $.resp.body.json.article.updatedAt + string: $.resp.body.json.article.updatedAt exists: $.resp.body.json.article.description exists: $.resp.body.json.article.tagList array: $.resp.body.json.article.tagList @@ -358,7 +364,7 @@ number: $.resp.body.json.article.favoritesCount ok: $.resp.body.json.article.favoritesCount > 0 - name: Articles Favorited by Username - GET: '$.env.APIURL/articles?favorited={{USERNAME}}' + GET: '$.env.APIURL/articles?favorited=$.env.USERNAME' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -373,9 +379,9 @@ exists: $.resp.body.json.articles[0].slug exists: $.resp.body.json.articles[0].body exists: $.resp.body.json.articles[0].createdAt - date: $.resp.body.json.articles[0].createdAt + string: $.resp.body.json.articles[0].createdAt exists: $.resp.body.json.articles[0].updatedAt - date: $.resp.body.json.articles[0].updatedAt + string: $.resp.body.json.articles[0].updatedAt exists: $.resp.body.json.articles[0].description exists: $.resp.body.json.articles[0].tagList array: $.resp.body.json.articles[0].tagList @@ -385,8 +391,10 @@ exists: $.resp.body.json.articles[0].favoritesCount number: $.resp.body.json.articles[0].favoritesCount ok: $.resp.body.json.articles[0].favoritesCount == 1 + outputs: + slug: $.resp.body.json.articles[0].slug - name: Unfavorite Article - DELETE: '$.env.APIURL/articles/{{slug}}/favorite' + DELETE: '$.env.APIURL/articles/$.stages[-1].outputs.slug/favorite' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -398,9 +406,9 @@ exists: $.resp.body.json.article.slug exists: $.resp.body.json.article.body exists: $.resp.body.json.article.createdAt - date: $.resp.body.json.article.createdAt + string: $.resp.body.json.article.createdAt exists: $.resp.body.json.article.updatedAt - date: $.resp.body.json.article.updatedAt + string: $.resp.body.json.article.updatedAt exists: $.resp.body.json.article.description exists: $.resp.body.json.article.tagList array: $.resp.body.json.article.tagList @@ -409,8 +417,10 @@ eq: $.resp.body.json.article.favorited, false exists: $.resp.body.json.article.favoritesCount number: $.resp.body.json.article.favoritesCount + outputs: + slug: $.resp.body.json.articles[0].slug - name: Create Comment for Article - POST: '$.env.APIURL/articles/{{slug}}/comments' + POST: '$.env.APIURL/articles/$.stages[-1].outputs.slug/comments' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -422,12 +432,14 @@ exists: $.resp.body.json.comment.id exists: $.resp.body.json.comment.body exists: $.resp.body.json.comment.createdAt - date: $.resp.body.json.comment.createdAt + string: $.resp.body.json.comment.createdAt exists: $.resp.body.json.comment.updatedAt - date: $.resp.body.json.comment.updatedAt + string: $.resp.body.json.comment.updatedAt exists: $.resp.body.json.comment.author + outputs: + slug: $.resp.body.json.articles[0].slug - name: All Comments for Article - GET: '$.env.APIURL/articles/{{slug}}/comments' + GET: '$.env.APIURL/articles/$.stages[-1].outputs.slug/comments' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -438,12 +450,14 @@ exists: $.resp.body.json.comments[0].id exists: $.resp.body.json.comments[0].body exists: $.resp.body.json.comments[0].createdAt - date: $.resp.body.json.comments[0].createdAt + string: $.resp.body.json.comments[0].createdAt exists: $.resp.body.json.comments[0].updatedAt - date: $.resp.body.json.comments[0].updatedAt + string: $.resp.body.json.comments[0].updatedAt exists: $.resp.body.json.comments[0].author + outputs: + slug: $.resp.body.json.articles[0].slug - name: All Comments for Article without login - GET: '$.env.APIURL/articles/{{slug}}/comments' + GET: '$.env.APIURL/articles/$.stages[-1].outputs.slug/comments' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -453,12 +467,14 @@ exists: $.resp.body.json.comments[0].id exists: $.resp.body.json.comments[0].body exists: $.resp.body.json.comments[0].createdAt - date: $.resp.body.json.comments[0].createdAt + string: $.resp.body.json.comments[0].createdAt exists: $.resp.body.json.comments[0].updatedAt - date: $.resp.body.json.comments[0].updatedAt + string: $.resp.body.json.comments[0].updatedAt exists: $.resp.body.json.comments[0].author + outputs: + slug: $.resp.body.json.articles[0].slug - name: Delete Comment for Article - DELETE: '$.env.APIURL/articles/{{slug}}/comments/{{commentId}}' + DELETE: '$.env.APIURL/articles/$.stages[-1].outputs.slug/comments/{{commentId}}' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -469,12 +485,14 @@ exists: $.resp.body.json.comment.id exists: $.resp.body.json.comment.body exists: $.resp.body.json.comment.createdAt - date: $.resp.body.json.comment.createdAt + string: $.resp.body.json.comment.createdAt exists: $.resp.body.json.comment.updatedAt - date: $.resp.body.json.comment.updatedAt + string: $.resp.body.json.comment.updatedAt exists: $.resp.body.json.comment.author + outputs: + slug: $.resp.body.json.articles[0].slug - name: Delete Article - DELETE: '$.env.APIURL/articles/{{slug}}' + DELETE: '$.env.APIURL/articles/$.stages[-1].outputs.slug' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -482,7 +500,7 @@ asserts: ok: $.resp.status == 200 - name: Profile - GET: '$.env.APIURL/profiles/celeb_{{USERNAME}}' + GET: '$.env.APIURL/profiles/celeb_$.env.USERNAME' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -495,7 +513,7 @@ exists: $.resp.body.json.profile.image exists: $.resp.body.json.profile.following - name: Follow Profile - POST: '$.env.APIURL/profiles/celeb_{{USERNAME}}/follow' + POST: '$.env.APIURL/profiles/celeb_$.env.USERNAME/follow' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest @@ -510,7 +528,7 @@ exists: $.resp.body.json.profile.following ok: $.resp.body.json.profile.following == true - name: Unfollow Profile - DELETE: '$.env.APIURL/profiles/celeb_{{USERNAME}}/follow' + DELETE: '$.env.APIURL/profiles/celeb_$.env.USERNAME/follow' headers: Content-Type: application/json X-Requested-With: XMLHttpRequest