From 50428b4d26bece2e58a4d5bccfaa0d886c1b52f4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 18 Apr 2020 13:25:08 +0200 Subject: [PATCH] beautified bookshop/requests.http --- bookshop/srv/admin-service.cds | 2 +- bookshop/test/requests.http | 69 ++++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/bookshop/srv/admin-service.cds b/bookshop/srv/admin-service.cds index 28c1c3a1..8939262f 100644 --- a/bookshop/srv/admin-service.cds +++ b/bookshop/srv/admin-service.cds @@ -1,5 +1,5 @@ using { sap.capire.bookshop as my } from '../db/schema'; -service AdminService @(_requires:'authenticated-user') { +service AdminService @(requires_:'admin') { entity Books as projection on my.Books; entity Authors as projection on my.Authors; } diff --git a/bookshop/test/requests.http b/bookshop/test/requests.http index e8790f54..038dbef8 100644 --- a/bookshop/test/requests.http +++ b/bookshop/test/requests.http @@ -1,40 +1,51 @@ -GET http://localhost:4004/browse -### - -GET http://localhost:4004/browse/$metadata -### +@server = http://localhost:4004 +@me = Authorization: Basic {{$processEnv USER}}: -GET http://localhost:4004/browse/Books? -&$select=title,stock -&$expand=currency -#> add @capire/common to see data for currencies -# &sap-language=de -### +### ------------------------------------------------------------------------ +# Get service info +GET {{server}}/browse +{{me}} -GET http://localhost:4004/admin/Authors? -# &$select=name,dateOfBirth,placeOfBirth -&$expand=books($select=title;$expand=currency) -#> add @capire/common to see data for currencies -# &$filter=ID eq 101 -&sap-language=de -### +### ------------------------------------------------------------------------ +# Get $metadata document +GET {{server}}/browse/$metadata +{{me}} -POST http://localhost:4004/browse/submitOrder -# Run that three times to get out-of-stock message +### ------------------------------------------------------------------------ +# Browse Books as any user +GET {{server}}/browse/Books? + # &$select=title,stock + # &$expand=currency + # &sap-language=de +{{me}} + + +### ------------------------------------------------------------------------ +# Fetch Authors as admin +GET {{server}}/admin/Authors? + # &$select=name,dateOfBirth,placeOfBirth + # &$expand=books($select=title;$expand=currency) + # &$filter=ID eq 101 + # &sap-language=de +Authorization: Basic alice: + + +### ------------------------------------------------------------------------ +# Submit Order as authenticated user +# (send that three times to get out-of-stock message) +POST {{server}}/browse/submitOrder Content-Type: application/json +{{me}} { "book":201, "amount":5 } -### - -GET http://localhost:4004/browse/Genres? -### - -GET http://localhost:4004/browse/Genres? -&$filter=parent_ID eq null&$select=name -&$expand=children($select=name) -### +### ------------------------------------------------------------------------ +# Browse Genres +GET {{server}}/browse/Genres? +# &$filter=parent_ID eq null&$select=name +# &$expand=children($select=name) +{{me}}