diff --git a/packages/validations/features/jpath.feature b/packages/validations/features/jpath.feature index c9c4fe1..c449ccd 100644 --- a/packages/validations/features/jpath.feature +++ b/packages/validations/features/jpath.feature @@ -1,6 +1,6 @@ Feature: Validations: Json Path Testing - Background: - When set "directory" to "./test" + Background: + When set "directory" to "./test" Scenario: When set array value it is able to validate in the area @@ -13,39 +13,42 @@ Feature: Validations: Json Path Testing Then it matches the set from file "expected.json" Then it matches the set "expected" Then item "item" is equal to: - """ - ["jeff","joe"] - """ + """ + [ + "jeff", + "joe" + ] + """ And it is written to file "hello.txt" And item "item" is written to file "hello2.txt" Scenario: Apply json path to item Given set "meh" to - """ -{ - "url": "http://google.com", - "arrayTest": [ - "Testing1", - "Testing2", - "Testing3" - ] -} - """ - And set "expected" to -""" -{ - "url": null, - "arrayTest": [ - "Testing1", - "Testing2", - "Testing3" - ] -} -""" - When set "meh.url" to "null" - Then item "expected" is equal to item "meh" - + """ + { + "url": "http://google.com", + "arrayTest": [ + "Testing1", + "Testing2", + "Testing3" + ] + } + """ + And set "expected" to + """ + { + "url": null, + "arrayTest": [ + "Testing1", + "Testing2", + "Testing3" + ] + } + """ + When set "meh.url" to "null" + Then item "expected" is equal to item "meh" + Scenario: Change JSON value in file - When "SomethingElse" is written to file "newconfig.json" on JSON path "$.meh" + When "SomethingElse" is written to file "newconfig.json" on JSON path "$.meh" And set config from json file "newconfig.json" Then "${meh}" is equal to "SomethingElse" When "Test" is written to file "newconfig.json" on JSON path "$.meh" @@ -53,15 +56,15 @@ Feature: Validations: Json Path Testing Then "${meh}" is equal to "Test" Scenario: Compare two items for equality Given set "a" to - """ - { - "a":5 - } - """ + """ + { + "a": 5 + } + """ And set "b" to - """ - { - "a":5 - } - """ - Then item "a" is equal to item "b" + """ + { + "a": 5 + } + """ + Then item "a" is equal to item "b" diff --git a/packages/validations/features/json.feature b/packages/validations/features/json.feature index 8a16713..013d997 100644 --- a/packages/validations/features/json.feature +++ b/packages/validations/features/json.feature @@ -1,44 +1,44 @@ Feature: Validations: JSON manipulation - Testing JSON object key deletion and extraction - Background: - When set "directory" to "./test" + Testing JSON object key deletion, extraction and general manipulation + Background: + When set "directory" to "./test" Scenario: Readme simple extract Example - When set "response" to - """ + When set "response" to + """ { - "error": { - "subErrorCodes": [ - { - "subErrorCode": 1101, - "subErrorMessage": "Phone Number is required" - } - ] - }, - "doesnotexist": null + "error": { + "subErrorCodes": [ + { + "subErrorCode": 1101, + "subErrorMessage": "Phone Number is required" + } + ] + }, + "doesnotexist": null + } + """ + When JSON key "subErrorCodes" is extracted from "response.error" + When JSON key "doesnotexist" is extracted from "response.error" + When set "Data" to + """ + { + "a": "apple", + "b": "banana" } - """ - When JSON key "subErrorCodes" is extracted from "response.error" - When JSON key "doesnotexist" is extracted from "response.error" - When set "Data" to - """ - { - "a":"apple", - "b":"banana" - } - """ - Then element "a" exists in item "Data" - When JSON key "a" is extracted from "Data" - Then it is equal to "apple" + """ + Then element "a" exists in item "Data" + When JSON key "a" is extracted from "Data" + Then it is equal to "apple" - Scenario: Readme simple removal Example + Scenario: Readme simple removal Example When set "Data" to - """ - { - "a":"apple", - "b":"banana" - } - """ + """ + { + "a": "apple", + "b": "banana" + } + """ And elements '["a", "b"]' exist in item "Data" And elements 'a, b' exist in item "Data" When JSON key "a" is removed from "Data" @@ -47,52 +47,52 @@ Feature: Validations: JSON manipulation And elements '[c,d]' do not exist in item "Data" Scenario: JSON Key Deletion - When set "TestJSON" to - """ - { - "url": "http://google.com", - "meh": "Test", - "meh2": "Another Test", - "deepMeh": { - "deep1": "Testing1", - "deep2": "Testing2" - }, - "deepMeh2": { - "deep3": "Testing3", - "deep4": "Testing4" - }, - "arrayTest": [ - "Testing1", - "Testing2", - "Testing3" - ] - } - """ + When set "TestJSON" to + """ + { + "url": "http://google.com", + "meh": "Test", + "meh2": "Another Test", + "deepMeh": { + "deep1": "Testing1", + "deep2": "Testing2" + }, + "deepMeh2": { + "deep3": "Testing3", + "deep4": "Testing4" + }, + "arrayTest": [ + "Testing1", + "Testing2", + "Testing3" + ] + } + """ And JSON key "meh" is removed from item "TestJSON" And set "lastRun" to item "TestJSON" And JSON key "deepMeh.deep1" is removed from it Scenario: JSON Key Extraction - When set "TestJSON" to - """ - { - "url": "http://google.com", - "meh": "Test", - "meh2": "Another Test", - "deepMeh": { - "deep1": "Testing1", - "deep2": "Testing2" - }, - "deepMeh2": { - "deep3": "Testing3", - "deep4": "Testing4" - }, - "arrayTest": [ - "Testing1", - "Testing2", - "Testing3" - ] - } - """ + When set "TestJSON" to + """ + { + "url": "http://google.com", + "meh": "Test", + "meh2": "Another Test", + "deepMeh": { + "deep1": "Testing1", + "deep2": "Testing2" + }, + "deepMeh2": { + "deep3": "Testing3", + "deep4": "Testing4" + }, + "arrayTest": [ + "Testing1", + "Testing2", + "Testing3" + ] + } + """ When set "newJSON" to item "TestJSON" When JSON key "arrayTest[0]" is extracted from item "newJSON" When JSON key "deepMeh" is extracted from item "TestJSON" @@ -100,43 +100,47 @@ Feature: Validations: JSON manipulation And JSON key "deep2" is extracted from it And JSON keys 'meh,deepMeh,deepMeh2.deep3, arrayTest]' are extracted from item "TestJSON" And set "expected" to - """ - { - "meh": "Test", - "deepMeh": { - "deep1": "Testing1", - "deep2": "Testing2" - }, - "deepMeh2": { - "deep3": "Testing3" - }, - "arrayTest": [ - "Testing1", - "Testing2", - "Testing3" - ] - } - """ + """ + { + "meh": "Test", + "deepMeh": { + "deep1": "Testing1", + "deep2": "Testing2" + }, + "deepMeh2": { + "deep3": "Testing3" + }, + "arrayTest": [ + "Testing1", + "Testing2", + "Testing3" + ] + } + """ Then item "expected" is equal to item "lastRun" Scenario: JSON Key Lowercase When set "data" to: """ { - "alreadylower": "lower", - "Alpha": "apple", - "BETA": "Banana", - "Charley": { "Coconut": "Hierarchy"} + "alreadylower": "lower", + "Alpha": "apple", + "BETA": "Banana", + "Charley": { + "Coconut": "Hierarchy" + } } """ When make json keys for item "data" lower case Then item "data" is equal to: """ { - "alreadylower": "lower", - "alpha": "apple", - "beta": "Banana", - "charley": { "coconut": "Hierarchy" } + "alreadylower": "lower", + "alpha": "apple", + "beta": "Banana", + "charley": { + "coconut": "Hierarchy" + } } """ @@ -144,65 +148,65 @@ Feature: Validations: JSON manipulation When set "data" to: """ { - "Alpha": "apple", - "BETA": "Banana", - "Charley": "coconut" + "Alpha": "apple", + "BETA": "Banana", + "Charley": "coconut" } """ When make json keys for item "data" lower case Then item "data" is equal to: """ { - "alpha": "apple", - "beta": "Banana", - "charley": "coconut" + "alpha": "apple", + "beta": "Banana", + "charley": "coconut" } """ Scenario: JSON Numberify When set "data" to: """ { - "Alpha": "123", - "Beta": { - "Beta_21": "456", - "Beta_22": "some_word" + "Alpha": "123", + "Beta": { + "Beta_21": "456", + "Beta_22": "some_word" }, - "Charley": { - "Charley_21": "45.6", - "Charley_22": 24.9 + "Charley": { + "Charley_21": "45.6", + "Charley_22": 24.9 }, - "Delta": "1.2.3" + "Delta": "1.2.3" } """ When json item "data" is numberifyed Then item "data" is equal to: """ { - "Alpha": 123, - "Beta": { - "Beta_21": 456, - "Beta_22": "some_word" + "Alpha": 123, + "Beta": { + "Beta_21": 456, + "Beta_22": "some_word" }, - "Charley": { - "Charley_21": 45.6, - "Charley_22": 24.9 + "Charley": { + "Charley_21": 45.6, + "Charley_22": 24.9 }, - "Delta": "1.2.3" + "Delta": "1.2.3" } """ Scenario: JSON Trim When set "data" to: """ { - "Alpha": { - "Alpha_2": "Apple " + "Alpha": { + "Alpha_2": "Apple " }, "John": 5, - "Beta": "_Banana_", - "Charley": "Spaces are kept in between words", - "Delta": { - "Delta_21" : " But spaces at the beginning and end are removed ", - "Delta_22" : "\nSo are new lines\n" + "Beta": "_Banana_", + "Charley": "Spaces are kept in between words", + "Delta": { + "Delta_21": " But spaces at the beginning and end are removed ", + "Delta_22": "\nSo are new lines\n" } } """ @@ -210,34 +214,34 @@ Feature: Validations: JSON manipulation Then item "data" is equal to: """ { - "Alpha": { - "Alpha_2": "Apple" - }, - "John": 5, - "Beta": "_Banana_", - "Charley": "Spaces are kept in between words", - "Delta": { - "Delta_21": "But spaces at the beginning and end are removed", - "Delta_22": "So are new lines" + "Alpha": { + "Alpha_2": "Apple" + }, + "John": 5, + "Beta": "_Banana_", + "Charley": "Spaces are kept in between words", + "Delta": { + "Delta_21": "But spaces at the beginning and end are removed", + "Delta_22": "So are new lines" } } """ - Scenario: JSON Flatten + Scenario: JSON Flatten When set "data" to: """ { - "Alpha": { - "Alpha_2": "Apple" + "Alpha": { + "Alpha_2": "Apple" }, - "Beta": "Banana", - "Charley": { - "Charley_2": { - "Charley_3": "Coconut" + "Beta": "Banana", + "Charley": { + "Charley_2": { + "Charley_3": "Coconut" } }, - "Delta": { - "Delta_21" : "Durian1", - "Delta_22" : "Durian2" + "Delta": { + "Delta_21": "Durian1", + "Delta_22": "Durian2" } } """ @@ -245,37 +249,74 @@ Feature: Validations: JSON manipulation Then item "data" is equal to: """ { - "Alpha_2": "Apple", - "Beta": "Banana", - "Charley_3": "Coconut", - "Delta_21": "Durian1", - "Delta_22": "Durian2" + "Alpha_2": "Apple", + "Beta": "Banana", + "Charley_3": "Coconut", + "Delta_21": "Durian1", + "Delta_22": "Durian2" + } + """ + Scenario: Example for json path + Given set "meh" to: + """ + { + "url": "http://google.com", + "arrayTest": [ + "Testing1", + "Testing2", + "Testing3" + ] } """ -Scenario: Example for json path -Given set "meh" to: -""" -{ - "url": "http://google.com", - "arrayTest": [ - "Testing1", - "Testing2", - "Testing3" - ] -} -""" -And set "expected" to: -""" -{ - "url": null, - "arrayTest": [ - "Testing1", - "Testing2", - "Testing3" - ] -} -""" -When "null" is applied to item "meh" on JSON path "$.url" -Then item "expected" is equal to item "meh" -When "" is applied to item "meh" on JSON path "$.url" + And set "expected" to: + """ + { + "url": null, + "arrayTest": [ + "Testing1", + "Testing2", + "Testing3" + ] + } + """ + When "null" is applied to item "meh" on JSON path "$.url" + Then item "expected" is equal to item "meh" + When "" is applied to item "meh" on JSON path "$.url" + + Scenario: JSON Array Inline Map Example + Given set "myJSON" to: + """ + [ + { + "abc": "string", + "def": 123, + "convertToBoolean": 1, + "jkl": null, + "mno": { + "pqr": "string", + "convertToString": 123, + "vwx": 0, + "yza": null + } + }, + { + "abc": "string", + "def": 123, + "convertToBoolean": 0, + "jkl": null, + "mno": { + "pqr": "string", + "convertToString": 456, + "vwx": 0, + "yza": null + } + } + ] + """ + When set "myJSON" to "${myJSON.map(item => ({ ...item, convertToBoolean: item.convertToBoolean === 1 }))}" + Then "${myJSON[0].convertToBoolean}" is equal to "true" + And "${myJSON[1].convertToBoolean}" is equal to "false" + When set "myJSON" to "${myJSON.map(item => ({ ...item, mno: { ...item.mno, convertToString: item.mno.convertToString.toString() } }))}" + Then "${myJSON[0].mno.convertToString}" is equal to "123" + And "${myJSON[1].mno.convertToString}" is equal to "456" diff --git a/packages/validations/features/testJSONObject.feature b/packages/validations/features/jsonObject.feature similarity index 70% rename from packages/validations/features/testJSONObject.feature rename to packages/validations/features/jsonObject.feature index 48d6bf0..3b17b4e 100644 --- a/packages/validations/features/testJSONObject.feature +++ b/packages/validations/features/jsonObject.feature @@ -1,10 +1,10 @@ Feature: Core: Test the core json object - Background: - When set "directory" to "./test" + Background: + Given set "directory" to "./test" Scenario: Test using file - Given set "a" to 5 - And item "a" is written to file "testItem.txt" + And set "a" to 5 + When item "a" is written to file "testItem.txt" Then file "testItem.txt" is equal to "5" When set result to "17" And set "bla" to it diff --git a/packages/validations/features/jwt.feature b/packages/validations/features/jwt.feature index c776dd8..d4b0048 100644 --- a/packages/validations/features/jwt.feature +++ b/packages/validations/features/jwt.feature @@ -1,32 +1,32 @@ Feature: Validations: JWT - Background: - When set "directory" to "./test" + Background: + When set "directory" to "./test" Scenario: Sign using JWT - When generate rsa key - And set "privateKey" to it - And set "header" to - """ -{ - "alg": "RS256", - "ver": "GTP-1.0", - "keyId": 1 -} - """ - Then "${header.alg}" is equal to "RS256" - When wait 5 milliseconds - And sign item "header" using jwt - And sign using jwt: -""" -{ - "number": null, - "id": null, - "exp": 1590176139, - "iat": 1590176019, - "jti": "fd867c6d-fcd5-4e5c-9bbf-95479a424f8f", - "realm": "INT", - "type": "access", - "username": "LNMAF" -} -""" + When generate rsa key + And set "privateKey" to it + And set "header" to + """ + { + "alg": "RS256", + "ver": "GTP-1.0", + "keyId": 1 + } + """ + Then "${header.alg}" is equal to "RS256" + When wait 5 milliseconds + And sign item "header" using jwt + And sign using jwt: + """ + { + "number": null, + "id": null, + "exp": 1590176139, + "iat": 1590176019, + "jti": "fd867c6d-fcd5-4e5c-9bbf-95479a424f8f", + "realm": "INT", + "type": "access", + "username": "LNMAF" + } + """ diff --git a/packages/validations/features/setExamplesWithBackground.feature b/packages/validations/features/setExamplesWithBackground.feature index 9277d4e..9450f19 100644 --- a/packages/validations/features/setExamplesWithBackground.feature +++ b/packages/validations/features/setExamplesWithBackground.feature @@ -7,17 +7,17 @@ Feature: Validations: Set Examples from the scenario outline to be visible with Then item "" is equal to "" Examples: | Phone | Expected | ExpectedResult | - | 1 | Phone | 1 | + | 1 | Phone | 1 | Examples: | Next | Expected | ExpectedResult | - | 2 | Next | 2 | - | 3 | Next | 3 | - + | 2 | Next | 2 | + | 3 | Next | 3 | + Examples: | Next | Expected | ExpectedResult | Bla | - | 2 | Next | 2 | 5 | - | 3 | Next | 3 | 6 | + | 2 | Next | 2 | 5 | + | 3 | Next | 3 | 6 | Scenario Outline: Testing @@ -26,5 +26,5 @@ Feature: Validations: Set Examples from the scenario outline to be visible with Then item "" is equal to "" Examples: | Phone | Expected | ExpectedResult | - | 1 | Phone | 1 | + | 1 | Phone | 1 | diff --git a/packages/validations/features/setting.feature b/packages/validations/features/setting.feature index ac60561..ffe24cf 100644 --- a/packages/validations/features/setting.feature +++ b/packages/validations/features/setting.feature @@ -1,104 +1,104 @@ Feature: Validations: Setting variables - Background: - When set "directory" to "./test" + Background: + When set "directory" to "./test" -Scenario: Check that we can identify a null or undefined element - When set result to "15" - Then it is equal to "15" - When set "a" to 3 - Then item "a" is not null - And item "b" is null + Scenario: Check that we can identify a null or undefined element + When set result to "15" + Then it is equal to "15" + When set "a" to 3 + Then item "a" is not null + And item "b" is null -Scenario: Set config as the first step - When set config from json file "newConfig2.json" - And set "hello" to "${environment}" + Scenario: Set config as the first step + When set config from json file "newConfig2.json" + And set "hello" to "${environment}" -Scenario: Set an empty string - When set "hi" to "" - Then "${hi}" is equal to "" + Scenario: Set an empty string + When set "hi" to "" + Then "${hi}" is equal to "" -Scenario: Setting. - Then "5" is not equal to: - """ - 17 - """ - Then "5" is equal to: - """ - 5 - """ - When set "hi" to "{}" - When set "hi.there" to "yo" - And set "hi.yo" to "yo" - And set "hi.arr" to "[]" - And set "hi.arr[0]" to "hello" - And set "hello" to item "hi" - When set "hi" to 3 - Then item "hi" is equal to "3" - When set "hi" to "{}" - And item "hi" is not equal to item "hello" -Scenario: Setting to item - When set: - |username|pass| - |User|Pass| - |User2|2Pass| - Then "${username[0]}" is equal to "User" - Then "${username[1]}" is equal to "User2" - And set: - |username|pass| - |User|Pass| - Then "${username}" is equal to "User" - When set "hi" to "hello" - And set "item2" to item "hi" - Then "${item2}" is equal to "hello" -Scenario: Setting item from file - When set "param" to "meh" - When set config from json file "config.json" - When set config from json item "deepMeh2" - Then "${deep3}" is equal to "Testing3" - Then "${meh}" is equal to "Test" -Scenario: Set json with number varaible - When set "num" to "5" - When set "hi" to -""" -{ - "num": ${num} -} -""" + Scenario: Setting. + Then "5" is not equal to: + """ + 17 + """ + Then "5" is equal to: + """ + 5 + """ + When set "hi" to "{}" + When set "hi.there" to "yo" + And set "hi.yo" to "yo" + And set "hi.arr" to "[]" + And set "hi.arr[0]" to "hello" + And set "hello" to item "hi" + When set "hi" to 3 + Then item "hi" is equal to "3" + When set "hi" to "{}" + And item "hi" is not equal to item "hello" + Scenario: Setting to item + When set: + | username | pass | + | User | Pass | + | User2 | 2Pass | + Then "${username[0]}" is equal to "User" + Then "${username[1]}" is equal to "User2" + And set: + | username | pass | + | User | Pass | + Then "${username}" is equal to "User" + When set "hi" to "hello" + And set "item2" to item "hi" + Then "${item2}" is equal to "hello" + Scenario: Setting item from file + When set "param" to "meh" + When set config from json file "config.json" + When set config from json item "deepMeh2" + Then "${deep3}" is equal to "Testing3" + Then "${meh}" is equal to "Test" + Scenario: Set json with number varaible + When set "num" to "5" + When set "hi" to + """ + { + "num": ${num} + } + """ -Scenario: Check two json objects - When set "a" to "3" - And set "item" to: - """ - { - "a": ${a} - } - """ - Then item "item" is equal to: - """ - { - "a":3 - } - """ - And set "a" to '"hi"' - And set "item" to: - """ - { - "a": "${a}" - } - """ - Then item "item" is equal to: - """ - { - "a": "\"hi\"" - } - """ + Scenario: Check two json objects + When set "a" to "3" + And set "item" to: + """ + { + "a": ${a} + } + """ + Then item "item" is equal to: + """ + { + "a": 3 + } + """ + And set "a" to '"hi"' + And set "item" to: + """ + { + "a": "${a}" + } + """ + Then item "item" is equal to: + """ + { + "a": "\"hi\"" + } + """ -Scenario Outline: Set the examples - Given parameters are: - """ - { - "hello": "world" - } - """ - When apply parameters - Then 5 = 5 + Scenario Outline: Set the examples + Given parameters are: + """ + { + "hello": "world" + } + """ + When apply parameters + Then 5 = 5