AzureTRE/api_http_requests
Tess Ferrandez 06b3a1a6e2
Delete Workspace Service (#801)
* implement delete

* add api tests

* add delete workspace service to user journey
2021-09-09 15:34:51 +02:00
..
API Other Endpoints.http add http request files (#769) 2021-09-06 14:56:56 +02:00
API Resource GET Endpoints.http Tessferrandez/longer urls (#799) 2021-09-09 11:52:32 +02:00
API Resource Modifying Endpoints.http Automated Tests for API Access Checks (#786) 2021-09-07 22:51:31 +03:00
API Template GET Endpoints.http Automated Tests for API Access Checks (#786) 2021-09-07 22:51:31 +03:00
API Template Modifying Endpoints.http add http request files (#769) 2021-09-06 14:56:56 +02:00
API User Journey.http Delete Workspace Service (#801) 2021-09-09 15:34:51 +02:00
README.md add http request files (#769) 2021-09-06 14:56:56 +02:00
http-client.env.json add http request files (#769) 2021-09-06 14:56:56 +02:00

README.md

Collection of API HTTP request samples

This folder contains a set of .http files that can be used to test the API

Running the requests in VS Code

  1. Install the Rest Client Extension

  2. In settings.json - add a section with environment variables that will be used for the requests

        "rest-client.environmentVariables": {
            "$shared": {
                "baseUrl": "http://localhost:8000/api",
                "contentType": "application/json",
                "workspaceTemplate": "my-tre-workspace",
                "workspaceServiceTemplate": "my-tre-workspace-service",
                "userResourceTemplate": "my-tre-user-resource",
                "workspaceId": "49ab7315-49bb-48ed-b9ca-c37369f15e7a",
                "workspaceServiceId": "2a3165e7-5b5c-40e5-b3b6-94f528e9fcf0",
                "userResourceId": "726e00b5-9408-4d81-a913-d890b4851307",
                "appId": "9d52b04f-89cf-47b4-868a-e12be7133b36",
                "token": "[TOKEN FROM SWAGGER UI]"
            },
        },
    

    Note: If you prefer, you can add environment specific variables (instead of adding all to $shared, but then you have to change environment in the bottom right bar in VS code when running the HTTP requests)

  3. Start the API locally - or modify the baseURL to point to an API running on Azure

  4. Authenticate with the API in Swagger and make a GET request to retrieve the authentication token (Bearer) - and modify the token variable in settings

  5. Run the requests in the HTTP files by clicking on send request above each request

Running the requests using PyCharms Rest-client

PyCharm has a built in rest client that allows us to run all requests in a .http file.

  1. Modify the variables defined in the http-client.env.json file to suit your needs

  2. Add a file called http-client.private.env.json to the API requests folder with the following contents

    {
        "dev": {
            "token": "[TOKEN FROM SWAGGER UI]"
        }
    }
    
  3. Start the API locally or modify the baseUrl in http-client.env.json to reflect the address of the API you are testing against

  4. Make a GET request in Swagger and update the token to your authentication token (Bearer)

  5. Run the requests