AzureTRE/api_http_requests
Ross Smith 8a2f799882
4. API works with authInformation in properties (#1705)
* Missing Api Id returns 500

* Make app_id mandatory

* Moving authInformation into workspace properties

* Create AAD when the private endpoint is finished

* tflint

* Adding outputs back in

* Default outputs

* Pass auth variables into TF

* TF Lint

* Fix Unit Tests

* app_id => client_id

* Linting

* E2E working locally

* Put tests around truthy method

* Bump the API Version

* Activate the DB migration

* Change return type and hope porter deals with it!

Co-authored-by: David Moore <35696285+damoodamoo@users.noreply.github.com>
2022-05-05 23:38:19 +01: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 4. API works with authInformation in properties (#1705) 2022-05-05 23:38:19 +01: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 Rename workspaceType, workspaceServiceType and userResourceType to templateName (#1031) 2021-10-12 14:45:27 +01:00
README.md add http request files (#769) 2021-09-06 14:56:56 +02:00
http-client.env.json 4. API works with authInformation in properties (#1705) 2022-05-05 23:38:19 +01: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