diff --git a/bruno/recipe-backend/AuthPoint/folder.bru b/bruno/recipe-backend/AuthPoint/folder.bru new file mode 100644 index 0000000..1f467e3 --- /dev/null +++ b/bruno/recipe-backend/AuthPoint/folder.bru @@ -0,0 +1,8 @@ +meta { + name: AuthPoint + seq: 2 +} + +auth { + mode: inherit +} diff --git a/bruno/recipe-backend/AuthPoint/login.bru b/bruno/recipe-backend/AuthPoint/login.bru new file mode 100644 index 0000000..fa0b200 --- /dev/null +++ b/bruno/recipe-backend/AuthPoint/login.bru @@ -0,0 +1,28 @@ +meta { + name: login + type: http + seq: 2 +} + +post { + url: {{url}}/auth/login + body: json + auth: inherit +} + +body:json { + { + "userName": "{{username}}", + "password": "{{password}}" + } +} + +script:post-response { + const body = res.getBody() + bru.setEnvVar("token", body.token) + bru.setEnvVar("tokenExpireDate", new Date().valueOf() + (body.expiryDate)) +} + +settings { + encodeUrl: true +} diff --git a/bruno/recipe-backend/CompactRecipePoint/folder.bru b/bruno/recipe-backend/CompactRecipePoint/folder.bru new file mode 100644 index 0000000..91c7c34 --- /dev/null +++ b/bruno/recipe-backend/CompactRecipePoint/folder.bru @@ -0,0 +1,8 @@ +meta { + name: CompactRecipePoint + seq: 4 +} + +auth { + mode: inherit +} diff --git a/bruno/recipe-backend/CompactRecipePoint/getCompactRecipes.bru b/bruno/recipe-backend/CompactRecipePoint/getCompactRecipes.bru new file mode 100644 index 0000000..b896439 --- /dev/null +++ b/bruno/recipe-backend/CompactRecipePoint/getCompactRecipes.bru @@ -0,0 +1,19 @@ +meta { + name: getCompactRecipes + type: http + seq: 2 +} + +get { + url: {{url}}/compact-recipe?search=kuchen + body: none + auth: inherit +} + +params:query { + search: kuchen +} + +settings { + encodeUrl: true +} diff --git a/bruno/recipe-backend/createRecipe.bru b/bruno/recipe-backend/RecipePoint/createRecipe.bru similarity index 82% rename from bruno/recipe-backend/createRecipe.bru rename to bruno/recipe-backend/RecipePoint/createRecipe.bru index 5a24bab..61aa1c8 100644 --- a/bruno/recipe-backend/createRecipe.bru +++ b/bruno/recipe-backend/RecipePoint/createRecipe.bru @@ -1,17 +1,13 @@ meta { name: createRecipe type: http - seq: 4 + seq: 2 } post { - url: http://localhost:4000/recipe/create-or-update + url: {{url}}/recipe/create-or-update body: json - auth: bearer -} - -auth:bearer { - token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE0NDdlNDM0LTQyMWYtNDJiYS04MGRlLTM0ZDE1YzJmNWE2YyIsImlhdCI6MTc2MDExNzA3MywiZXhwIjoxNzYwMjAzNDczfQ.NEfrUuzFcxocgN52uhptku5QVUbg03nmrN1E6A6XycA + auth: inherit } body:json { diff --git a/bruno/recipe-backend/RecipePoint/folder.bru b/bruno/recipe-backend/RecipePoint/folder.bru new file mode 100644 index 0000000..88336f3 --- /dev/null +++ b/bruno/recipe-backend/RecipePoint/folder.bru @@ -0,0 +1,8 @@ +meta { + name: RecipePoint + seq: 3 +} + +auth { + mode: inherit +} diff --git a/bruno/recipe-backend/RecipePoint/getRecipeById.bru b/bruno/recipe-backend/RecipePoint/getRecipeById.bru new file mode 100644 index 0000000..4757cac --- /dev/null +++ b/bruno/recipe-backend/RecipePoint/getRecipeById.bru @@ -0,0 +1,33 @@ +meta { + name: getRecipeById + type: http + seq: 3 +} + +get { + url: {{url}}/recipe/fa608340-d679-4267-8b89-c743bd7fc234 + body: none + auth: inherit +} + +script:pre-request { + try{ + // An dieser Stelle muss überprüft werden, ob diese Funktion gerade aufgerufen wird, ansonsten entsteht eine Endlosschleife. + const blocked = bru.getEnvVar("blocked"); + if(blocked === "false" && new Date().valueOf() > Number(bru.getEnvVar("tokenExpireDate"))){ + console.log('new Session') + + bru.setEnvVar("blocked",true) + // Absoluter Pfad von der Collection-Root + await bru.runRequest('login.bru') + + bru.setEnvVar("blocked",false) + } + } catch (e){ + console.log(e) + } +} + +settings { + encodeUrl: true +} diff --git a/bruno/recipe-backend/updateRecipe.bru b/bruno/recipe-backend/RecipePoint/updateRecipe.bru similarity index 83% rename from bruno/recipe-backend/updateRecipe.bru rename to bruno/recipe-backend/RecipePoint/updateRecipe.bru index a138e2a..ddc8145 100644 --- a/bruno/recipe-backend/updateRecipe.bru +++ b/bruno/recipe-backend/RecipePoint/updateRecipe.bru @@ -1,17 +1,13 @@ meta { name: updateRecipe type: http - seq: 7 + seq: 3 } post { - url: http://localhost:4000/recipe/create-or-update + url: {{url}}/recipe/create-or-update body: json - auth: bearer -} - -auth:bearer { - token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE0NDdlNDM0LTQyMWYtNDJiYS04MGRlLTM0ZDE1YzJmNWE2YyIsImlhdCI6MTc1OTU5MTk1MiwiZXhwIjoxNzU5Njc4MzUyfQ.gkvuBtq8OaC7OqnArPcrV7jd34Ll7jHYXRbvz847aiw + auth: inherit } body:json { @@ -105,6 +101,24 @@ body:json { } } +script:pre-request { + try{ + // An dieser Stelle muss überprüft werden, ob diese Funktion gerade aufgerufen wird, ansonsten entsteht eine Endlosschleife. + const blocked = bru.getEnvVar("blocked"); + if(blocked === "false" && new Date().valueOf() > Number(bru.getEnvVar("tokenExpireDate"))){ + console.log('new Session') + + bru.setEnvVar("blocked",true) + // Absoluter Pfad von der Collection-Root + await bru.runRequest('login.bru') + + bru.setEnvVar("blocked",false) + } + } catch (e){ + console.log(e) + } +} + settings { encodeUrl: true } diff --git a/bruno/recipe-backend/UserPoint/createUser.bru b/bruno/recipe-backend/UserPoint/createUser.bru new file mode 100644 index 0000000..8a4fb12 --- /dev/null +++ b/bruno/recipe-backend/UserPoint/createUser.bru @@ -0,0 +1,25 @@ +meta { + name: createUser + type: http + seq: 2 +} + +post { + url: {{url}}/user/create + body: json + auth: inherit +} + +body:json { + { + "userData": { + "userName": "bruno", + "email": "test@raemer.net" + }, + "password": "bruno" + } +} + +settings { + encodeUrl: true +} diff --git a/bruno/recipe-backend/UserPoint/folder.bru b/bruno/recipe-backend/UserPoint/folder.bru new file mode 100644 index 0000000..3a22d7c --- /dev/null +++ b/bruno/recipe-backend/UserPoint/folder.bru @@ -0,0 +1,8 @@ +meta { + name: UserPoint + seq: 5 +} + +auth { + mode: inherit +} diff --git a/bruno/recipe-backend/getRecipeById.bru b/bruno/recipe-backend/UserPoint/getAllUsers.bru similarity index 57% rename from bruno/recipe-backend/getRecipeById.bru rename to bruno/recipe-backend/UserPoint/getAllUsers.bru index d428c6f..30ac717 100644 --- a/bruno/recipe-backend/getRecipeById.bru +++ b/bruno/recipe-backend/UserPoint/getAllUsers.bru @@ -1,11 +1,11 @@ meta { - name: getRecipeById + name: getAllUsers type: http - seq: 6 + seq: 7 } get { - url: https://localhost:4000/recipe/ + url: {{url}}/user/all body: none auth: inherit } diff --git a/bruno/recipe-backend/UserPoint/me.bru b/bruno/recipe-backend/UserPoint/me.bru new file mode 100644 index 0000000..cfcadef --- /dev/null +++ b/bruno/recipe-backend/UserPoint/me.bru @@ -0,0 +1,15 @@ +meta { + name: me + type: http + seq: 3 +} + +get { + url: {{url}}/user/me + body: none + auth: inherit +} + +settings { + encodeUrl: true +} diff --git a/bruno/recipe-backend/updateUser.bru b/bruno/recipe-backend/UserPoint/updateUser.bru similarity index 53% rename from bruno/recipe-backend/updateUser.bru rename to bruno/recipe-backend/UserPoint/updateUser.bru index 9a08421..b2c7aa7 100644 --- a/bruno/recipe-backend/updateUser.bru +++ b/bruno/recipe-backend/UserPoint/updateUser.bru @@ -1,17 +1,13 @@ meta { name: updateUser type: http - seq: 8 + seq: 7 } post { - url: http://localhost:4000/user/update + url: {{url}}/user/update body: json - auth: bearer -} - -auth:bearer { - token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE0NDdlNDM0LTQyMWYtNDJiYS04MGRlLTM0ZDE1YzJmNWE2YyIsImlhdCI6MTc2MzQ5MDcxMywiZXhwIjoxNzYzNTc3MTEzfQ.h8ta-4tVhR7EskZDBLtcFTQ7QllV-PfC09Y0DLjYJa4 + auth: inherit } body:json { diff --git a/bruno/recipe-backend/changePassword.bru b/bruno/recipe-backend/changePassword.bru deleted file mode 100644 index f35411e..0000000 --- a/bruno/recipe-backend/changePassword.bru +++ /dev/null @@ -1,26 +0,0 @@ -meta { - name: changePassword - type: http - seq: 11 -} - -post { - url: http://localhost:4000/user/change-password - body: json - auth: bearer -} - -auth:bearer { - token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE0NDdlNDM0LTQyMWYtNDJiYS04MGRlLTM0ZDE1YzJmNWE2YyIsImlhdCI6MTc2MzQ5MDcxMywiZXhwIjoxNzYzNTc3MTEzfQ.h8ta-4tVhR7EskZDBLtcFTQ7QllV-PfC09Y0DLjYJa4 -} - -body:json { - { - "userId": "9c913747-ba57-4b12-87d0-3339f4a8117c", - "password": "test" - } -} - -settings { - encodeUrl: true -} diff --git a/bruno/recipe-backend/createUser.bru b/bruno/recipe-backend/createUser.bru deleted file mode 100644 index b0fa5e8..0000000 --- a/bruno/recipe-backend/createUser.bru +++ /dev/null @@ -1,29 +0,0 @@ -meta { - name: createUser - type: http - seq: 1 -} - -post { - url: http://localhost:4000/user/create - body: json - auth: bearer -} - -auth:bearer { - token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE0NDdlNDM0LTQyMWYtNDJiYS04MGRlLTM0ZDE1YzJmNWE2YyIsImlhdCI6MTc2MzQ5MDcxMywiZXhwIjoxNzYzNTc3MTEzfQ.h8ta-4tVhR7EskZDBLtcFTQ7QllV-PfC09Y0DLjYJa4 -} - -body:json { - { - "userData": { - "userName": "test3", - "email": "test@raemer.net" - }, - "password": "test" - } -} - -settings { - encodeUrl: true -} diff --git a/bruno/recipe-backend/environments/dev - admin.bru b/bruno/recipe-backend/environments/dev - admin.bru new file mode 100644 index 0000000..ca5b738 --- /dev/null +++ b/bruno/recipe-backend/environments/dev - admin.bru @@ -0,0 +1,10 @@ +vars { + url: http://localhost:4000 + username: admin + tokenExpireDate: + blocked: false +} +vars:secret [ + token, + password +] diff --git a/bruno/recipe-backend/environments/dev - user.bru b/bruno/recipe-backend/environments/dev - user.bru new file mode 100644 index 0000000..760141d --- /dev/null +++ b/bruno/recipe-backend/environments/dev - user.bru @@ -0,0 +1,10 @@ +vars { + url: http://localhost:4000 + username: bruno + tokenExpireDate: + blocked: false +} +vars:secret [ + password, + token +] diff --git a/bruno/recipe-backend/getAllUsers.bru b/bruno/recipe-backend/getAllUsers.bru deleted file mode 100644 index adc1db8..0000000 --- a/bruno/recipe-backend/getAllUsers.bru +++ /dev/null @@ -1,19 +0,0 @@ -meta { - name: getAllUsers - type: http - seq: 10 -} - -get { - url: http://localhost:4000/user/all - body: none - auth: bearer -} - -auth:bearer { - token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE0NDdlNDM0LTQyMWYtNDJiYS04MGRlLTM0ZDE1YzJmNWE2YyIsImlhdCI6MTc2MzMyMDEzMywiZXhwIjoxNzYzNDA2NTMzfQ.tguHEC4VFZJkbWjnI628VwuIB_p9odtBIPANcabH8q4 -} - -settings { - encodeUrl: true -} diff --git a/bruno/recipe-backend/getCompactRecipes.bru b/bruno/recipe-backend/getCompactRecipes.bru deleted file mode 100644 index d62a677..0000000 --- a/bruno/recipe-backend/getCompactRecipes.bru +++ /dev/null @@ -1,19 +0,0 @@ -meta { - name: getCompactRecipes - type: http - seq: 5 -} - -get { - url: http://localhost:4000/compact-recipe - body: none - auth: bearer -} - -auth:bearer { - token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE0NDdlNDM0LTQyMWYtNDJiYS04MGRlLTM0ZDE1YzJmNWE2YyIsImlhdCI6MTc1OTA3NjA2NCwiZXhwIjoxNzU5MTYyNDY0fQ.exf_3fCrarW0LhUqPuadvp89BOUazEXtdSTkGDIAU_Q -} - -settings { - encodeUrl: true -} diff --git a/bruno/recipe-backend/login.bru b/bruno/recipe-backend/login.bru deleted file mode 100644 index 3fe84be..0000000 --- a/bruno/recipe-backend/login.bru +++ /dev/null @@ -1,22 +0,0 @@ -meta { - name: login - type: http - seq: 2 -} - -post { - url: http://localhost:4000/auth/login - body: json - auth: inherit -} - -body:json { - { - "userName": "admin", - "password": "1J7HgWRZ2OfaiFgrKb1BULIXN" - } -} - -settings { - encodeUrl: true -} diff --git a/bruno/recipe-backend/me.bru b/bruno/recipe-backend/me.bru deleted file mode 100644 index b5fbccf..0000000 --- a/bruno/recipe-backend/me.bru +++ /dev/null @@ -1,19 +0,0 @@ -meta { - name: me - type: http - seq: 3 -} - -get { - url: http://localhost:4000/user/me - body: none - auth: bearer -} - -auth:bearer { - token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE0NDdlNDM0LTQyMWYtNDJiYS04MGRlLTM0ZDE1YzJmNWE2YyIsImlhdCI6MTc2MzQ5MDcxMywiZXhwIjoxNzYzNTc3MTEzfQ.h8ta-4tVhR7EskZDBLtcFTQ7QllV-PfC09Y0DLjYJa4 -} - -settings { - encodeUrl: true -}