From 42ba88c01a51a354dd459de4e4f584af1fa988f0 Mon Sep 17 00:00:00 2001 From: Rafa Date: Thu, 23 Mar 2023 11:21:16 +0000 Subject: [PATCH 1/2] Add component tests for GET version endpoint --- features/versions.feature | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/features/versions.feature b/features/versions.feature index 1d11d97f..6b2e34ee 100644 --- a/features/versions.feature +++ b/features/versions.feature @@ -320,6 +320,51 @@ Feature: Dataset API version not found """ + Scenario: GET /datasets/{id}/editions/{edition}/versions/{version} in public mode returns the version + When I GET "/datasets/population-estimates/editions/hello/versions/4" + Then I should receive the following JSON response with status "200": + """ + { + "id": "test-item-4", + "version": 4, + "state": "published", + "links": { + "dataset": { + "id": "population-estimates" + }, + "self": { + "href": "someurl" + } + }, + "edition": "hello", + "lowest_geography": "ltla" + } + """ + + Scenario: GET /datasets/{id}/editions/{edition}/versions/{version} in private mode returns the version + Given private endpoints are enabled + And I am identified as "user@ons.gov.uk" + And I am authorised + When I GET "/datasets/population-estimates/editions/hello/versions/4" + Then I should receive the following JSON response with status "200": + """ + { + "id": "test-item-4", + "version": 4, + "state": "published", + "links": { + "dataset": { + "id": "population-estimates" + }, + "self": { + "href": "someurl" + } + }, + "edition": "hello", + "lowest_geography": "ltla" + } + """ + Scenario: PUT versions for CMD dataset produces Kafka event and returns OK Given private endpoints are enabled And I am identified as "user@ons.gov.uk" From a8e0f4f0334b743eb396d642b914206746542c16 Mon Sep 17 00:00:00 2001 From: Rafa Date: Fri, 24 Mar 2023 11:38:52 +0000 Subject: [PATCH 2/2] Add checks for etags --- features/steps/steps.go | 2 ++ features/versions.feature | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/features/steps/steps.go b/features/steps/steps.go index 0488cc12..373f5e30 100644 --- a/features/steps/steps.go +++ b/features/steps/steps.go @@ -314,6 +314,8 @@ func (c *DatasetComponent) iHaveTheseVersions(versionsJson *godog.DocString) err HRef: version.Links.Self.HRef, } } + // Set the etag (json omitted) + version.ETag = "etag-" + version.ID instanceCollection := c.MongoClient.ActualCollectionName(config.InstanceCollection) if err := c.putDocumentInDatabase(version, versionID, instanceCollection, timeOffset); err != nil { diff --git a/features/versions.feature b/features/versions.feature index 6b2e34ee..d3dc11f0 100644 --- a/features/versions.feature +++ b/features/versions.feature @@ -340,18 +340,19 @@ Feature: Dataset API "lowest_geography": "ltla" } """ + And the response header "ETag" should be "etag-test-item-4" Scenario: GET /datasets/{id}/editions/{edition}/versions/{version} in private mode returns the version Given private endpoints are enabled And I am identified as "user@ons.gov.uk" And I am authorised - When I GET "/datasets/population-estimates/editions/hello/versions/4" + When I GET "/datasets/population-estimates/editions/hello/versions/2" Then I should receive the following JSON response with status "200": """ { - "id": "test-item-4", - "version": 4, - "state": "published", + "id": "test-item-2", + "version": 2, + "state": "associated", "links": { "dataset": { "id": "population-estimates" @@ -360,10 +361,10 @@ Feature: Dataset API "href": "someurl" } }, - "edition": "hello", - "lowest_geography": "ltla" + "edition": "hello" } """ + And the response header "ETag" should be "etag-test-item-2" Scenario: PUT versions for CMD dataset produces Kafka event and returns OK Given private endpoints are enabled