From 690e0b9e2f52bc2e446bc0cb15bd9c78a4c6dfc6 Mon Sep 17 00:00:00 2001 From: abdulla-ashurov <99400260+abdulla-ashurov@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:12:03 +0500 Subject: [PATCH 1/3] feat: Support date only format with versionTime, resourceTime query parameters [DEV-2807] (#165) * Add implementation for supporting different formats of date in versionTime and resourceVersionTime queries. * Add positive integration tests for versionTime query parameter. * Remove unused date formats. * Refactor code. * Update positive version time integration tests. * Update integration test. * Add positive integration tests for testing resourceVersionTime query. * Update Makefile. * Add implementation for supporting more date types: - Layout - ANSIC - UnixDate - RubyDate - RFC822 - RFC822Z - RFC850 - RFC1123 - RFC1123Z * Add more positive integration test for testing different date formats. * Refactor code. * Add positive integration tests for testing resourceVersionTime query with different date formats. * Add negative integration tests for testing versionTime and resourceVersionTime queries with an invalid date format. * Use constants variables instead of magic strings. * Update golang version in Dockerfile. * Bump golang version from v1.18 to v1.20 in go.mod. --- Makefile | 4 +- docker/Dockerfile | 2 +- go.mod | 2 +- .../query/version_time/negative_test.go | 28 +++ .../query/version_time/positive_test.go | 187 +++++++++++++++++- .../resource_version_time/negative_test.go | 36 +++- .../resource_version_time/positive_test.go | 183 ++++++++++++++++- .../diddoc_version_time_date_did.json | 60 ++++++ utils/parse_time.go | 40 +++- 9 files changed, 512 insertions(+), 30 deletions(-) create mode 100644 tests/integration/rest/testdata/query/version_time/diddoc_version_time_date_did.json diff --git a/Makefile b/Makefile index e6236db3..48aed952 100644 --- a/Makefile +++ b/Makefile @@ -130,10 +130,10 @@ tidy: ############################################################################### unit-tests: - cd tests/unit && ginkgo -r --tags unit --race + cd tests/unit && ginkgo -r --tags unit --race --keep-going integration-tests: - cd tests/integration/rest && ginkgo -r --tags integration --race + cd tests/integration/rest && ginkgo -r --tags integration --race --keep-going lint: golangci-lint run --config .github/linters/.golangci.yaml diff --git a/docker/Dockerfile b/docker/Dockerfile index 1b7e1ecf..93afb0d9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,7 +2,7 @@ ### STAGE 1: Build cheqd did-resolver binary pre-requisites ### ##################################################################### -FROM golang:1.18-alpine AS builder +FROM golang:1.20-alpine AS builder # Install minimum necessary dependencies ENV PACKAGES make git bash linux-headers findutils diff --git a/go.mod b/go.mod index f8aca37d..1df490b0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cheqd/did-resolver -go 1.18 +go 1.20 require ( github.com/cheqd/cheqd-node/api/v2 v2.1.0 diff --git a/tests/integration/rest/diddoc/query/version_time/negative_test.go b/tests/integration/rest/diddoc/query/version_time/negative_test.go index a20bb3a8..d5fb032f 100644 --- a/tests/integration/rest/diddoc/query/version_time/negative_test.go +++ b/tests/integration/rest/diddoc/query/version_time/negative_test.go @@ -5,6 +5,7 @@ package versionTime import ( "encoding/json" "fmt" + "net/url" testconstants "github.com/cheqd/did-resolver/tests/constants" utils "github.com/cheqd/did-resolver/tests/integration/rest" @@ -57,6 +58,33 @@ var _ = DescribeTable("Negative: Get DIDDoc with versionTime query", func(testCa }, ), + Entry( + "cannot get DIDDoc with not supported format of versionTime query parameter (not supported format)", + utils.NegativeTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("06/03/2023 09:36:54"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedResult: types.DidResolution{ + Context: "", + ResolutionMetadata: types.ResolutionMetadata{ + ContentType: types.DIDJSONLD, + ResolutionError: "invalidDidUrl", + DidProperties: types.DidProperties{ + DidString: testconstants.SeveralVersionsDID, + MethodSpecificId: testconstants.SeveralVersionsDIDIdentifier, + Method: testconstants.ValidMethod, + }, + }, + Did: nil, + Metadata: types.ResolutionDidDocMetadata{}, + }, + ExpectedStatusCode: types.InvalidDidUrlHttpCode, + }, + ), + Entry( "cannot get DIDDoc with an invalid versionTime query parameter", utils.NegativeTestCase{ diff --git a/tests/integration/rest/diddoc/query/version_time/positive_test.go b/tests/integration/rest/diddoc/query/version_time/positive_test.go index ff890ce8..c59e1b25 100644 --- a/tests/integration/rest/diddoc/query/version_time/positive_test.go +++ b/tests/integration/rest/diddoc/query/version_time/positive_test.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "net/http" + "net/url" testconstants "github.com/cheqd/did-resolver/tests/constants" utils "github.com/cheqd/did-resolver/tests/integration/rest" @@ -34,7 +35,175 @@ var _ = DescribeTable("Positive: Get DIDDoc with versionTime query", func(testCa }, Entry( - "can get DIDDoc with versionTime query parameter", + "can get DIDDoc with an old 16 characters INDY style DID and versionTime query parameter", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.OldIndy16CharStyleTestnetDid, + "2022-10-13T06:09:04Z", + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_16_old_indy_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with an old 32 characters INDY style DID and versionTime query parameter", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.OldIndy32CharStyleTestnetDid, + "2022-10-12T08:57:25Z", + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_32_old_indy_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (Layout format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("03/06 09:39:50AM '23 +0000"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (ANSIC format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("Mon Mar 06 09:39:50 2023"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (UnixDate format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("Mon Mar 06 09:39:50 UTC 2023"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (RubyDate format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("Mon Mar 06 09:39:50 +0000 2023"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (RFC822 format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("06 Mar 23 09:40 UTC"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (RFC822Z format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("06 Mar 23 09:40 +0000"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (RFC850 format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("Monday, 06-Mar-23 09:39:50 UTC"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (RFC1123 format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("Mon, 06 Mar 2023 09:39:50 UTC"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (RFC1123Z format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + url.QueryEscape("Mon, 06 Mar 2023 09:39:50 +0000"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (RFC3339 format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", + testconstants.SeveralVersionsDID, + "2023-03-06T09:39:50Z", + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get DIDDoc with versionTime query parameter (RFC3339Nano format)", utils.PositiveTestCase{ DidURL: fmt.Sprintf( "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", @@ -48,29 +217,29 @@ var _ = DescribeTable("Positive: Get DIDDoc with versionTime query", func(testCa ), Entry( - "can get DIDDoc with an old 16 characters INDY style DID and versionTime query parameter", + "can get DIDDoc with versionTime query parameter (DateTime format)", utils.PositiveTestCase{ DidURL: fmt.Sprintf( "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", - testconstants.OldIndy16CharStyleTestnetDid, - "2022-10-13T06:09:04Z", + testconstants.SeveralVersionsDID, + url.QueryEscape("2023-03-06 09:39:50"), ), ResolutionType: testconstants.DefaultResolutionType, - ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_16_old_indy_did.json", + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_did.json", ExpectedStatusCode: http.StatusOK, }, ), Entry( - "can get DIDDoc with an old 32 characters INDY style DID and versionTime query parameter", + "can get DIDDoc with versionTime query parameter (DateOnly format)", utils.PositiveTestCase{ DidURL: fmt.Sprintf( "http://localhost:8080/1.0/identifiers/%s?versionTime=%s", - testconstants.OldIndy32CharStyleTestnetDid, - "2022-10-12T08:57:25Z", + testconstants.SeveralVersionsDID, + "2023-03-07", ), ResolutionType: testconstants.DefaultResolutionType, - ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_32_old_indy_did.json", + ExpectedJSONPath: "../../../testdata/query/version_time/diddoc_version_time_date_did.json", ExpectedStatusCode: http.StatusOK, }, ), diff --git a/tests/integration/rest/resource/query/resource_version_time/negative_test.go b/tests/integration/rest/resource/query/resource_version_time/negative_test.go index 793ea8af..56650e61 100644 --- a/tests/integration/rest/resource/query/resource_version_time/negative_test.go +++ b/tests/integration/rest/resource/query/resource_version_time/negative_test.go @@ -5,6 +5,7 @@ package resource_version_time_test import ( "encoding/json" "fmt" + "net/url" testconstants "github.com/cheqd/did-resolver/tests/constants" utils "github.com/cheqd/did-resolver/tests/integration/rest" @@ -36,16 +37,16 @@ var _ = DescribeTable("Negative: Get Collection of Resources with resourceVersio "cannot get collection of resources with not existent resourceVersionTime query parameter", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s", + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", testconstants.UUIDStyleTestnetDid, - "2023-03-06T09:36:56.56204903Z", + "2023-01-25T12:04:51Z", ), ResolutionType: string(types.DIDJSONLD), ExpectedResult: utils.DereferencingResult{ Context: "", DereferencingMetadata: types.DereferencingMetadata{ ContentType: types.DIDJSONLD, - ResolutionError: "representationNotSupported", + ResolutionError: "notFound", DidProperties: types.DidProperties{ DidString: testconstants.UUIDStyleTestnetDid, MethodSpecificId: testconstants.UUIDStyleTestnetId, @@ -55,7 +56,34 @@ var _ = DescribeTable("Negative: Get Collection of Resources with resourceVersio ContentStream: nil, Metadata: types.ResolutionDidDocMetadata{}, }, - ExpectedStatusCode: errors.RepresentationNotSupportedHttpCode, // it should be notFound + ExpectedStatusCode: errors.NotFoundHttpCode, // it should be notFound + }, + ), + + Entry( + "cannot get collection of resources with not supported format of resourceVersionTime query parameter", + utils.NegativeTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("06/03/2023 09:36:56"), + ), + ResolutionType: string(types.DIDJSONLD), + ExpectedResult: utils.DereferencingResult{ + Context: "", + DereferencingMetadata: types.DereferencingMetadata{ + ContentType: types.DIDJSONLD, + ResolutionError: "invalidDidUrl", + DidProperties: types.DidProperties{ + DidString: testconstants.UUIDStyleTestnetDid, + MethodSpecificId: testconstants.UUIDStyleTestnetId, + Method: testconstants.ValidMethod, + }, + }, + ContentStream: nil, + Metadata: types.ResolutionDidDocMetadata{}, + }, + ExpectedStatusCode: errors.InvalidDidUrlHttpCode, }, ), diff --git a/tests/integration/rest/resource/query/resource_version_time/positive_test.go b/tests/integration/rest/resource/query/resource_version_time/positive_test.go index 157c1829..ab895a4c 100644 --- a/tests/integration/rest/resource/query/resource_version_time/positive_test.go +++ b/tests/integration/rest/resource/query/resource_version_time/positive_test.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "net/http" + "net/url" testconstants "github.com/cheqd/did-resolver/tests/constants" utils "github.com/cheqd/did-resolver/tests/integration/rest" @@ -33,8 +34,151 @@ var _ = DescribeTable("Positive: Get Collection of Resources with resourceVersio utils.AssertDidDereferencing(expectedDidDereferencing, receivedDidDereferencing) }, + // TODO: add unit test for testing get resource with an old 16 characters INDY style DID + // and resourceVersionTime query parameter. + + Entry( + "can get resource with an old 32 characters INDY style DID and resourceVersionTime query parameter", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.OldIndy32CharStyleTestnetDid, + "2022-10-12T08:57:31Z", + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource_32_indy_did.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (Layout format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("01/25 00:08:40PM '23 +0000"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (ANSIC format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("Wed Jan 25 12:08:40 2023"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (UnixDate format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("Wed Jan 25 12:08:40 UTC 2023"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (RubyDate format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("Wed Jan 25 12:08:40 +0000 2023"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (RFC822 format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("25 Jan 23 12:09 UTC"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (RFC822Z format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("25 Jan 23 12:09 +0000"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (RFC850 format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("Wednesday, 25-Jan-23 12:08:40 UTC"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (RFC1123 format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("Wed, 25 Jan 2023 12:08:40 UTC"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (RFC1123Z format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("Wed, 25 Jan 2023 12:08:40 +0000"), + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + Entry( - "can get collection of resources with an existent resourceVersionTime query parameter", + "can get collection of resources with an existent resourceVersionTime query parameter (RFC3339 format)", utils.PositiveTestCase{ DidURL: fmt.Sprintf( "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", @@ -47,19 +191,44 @@ var _ = DescribeTable("Positive: Get Collection of Resources with resourceVersio }, ), - // TODO: add unit test for testing get resource with an old 16 characters INDY style DID - // and resourceVersionTime query parameter. + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (RFC3339Nano format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + "2023-01-25T12:08:40.0Z", + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), Entry( - "can get resource with an old 32 characters INDY style DID and resourceVersionTime query parameter", + "can get collection of resources with an existent resourceVersionTime query parameter (DateTime format)", utils.PositiveTestCase{ DidURL: fmt.Sprintf( "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", - testconstants.OldIndy32CharStyleTestnetDid, - "2022-10-12T08:57:31Z", + testconstants.UUIDStyleTestnetDid, + url.QueryEscape("2023-01-25 12:08:40"), ), ResolutionType: testconstants.DefaultResolutionType, - ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource_32_indy_did.json", + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", + ExpectedStatusCode: http.StatusOK, + }, + ), + + Entry( + "can get collection of resources with an existent resourceVersionTime query parameter (DateOnly format)", + utils.PositiveTestCase{ + DidURL: fmt.Sprintf( + "http://localhost:8080/1.0/identifiers/%s?resourceVersionTime=%s&resourceMetadata=true", + testconstants.UUIDStyleTestnetDid, + "2023-01-26", + ), + ResolutionType: testconstants.DefaultResolutionType, + ExpectedJSONPath: "../../../testdata/query/resource_version_time/resource.json", ExpectedStatusCode: http.StatusOK, }, ), diff --git a/tests/integration/rest/testdata/query/version_time/diddoc_version_time_date_did.json b/tests/integration/rest/testdata/query/version_time/diddoc_version_time_date_did.json new file mode 100644 index 00000000..70c1112d --- /dev/null +++ b/tests/integration/rest/testdata/query/version_time/diddoc_version_time_date_did.json @@ -0,0 +1,60 @@ +{ + "@context": "https://w3id.org/did-resolution/v1", + "didResolutionMetadata": { + "contentType": "application/did+ld+json", + "retrieved": "2023-04-24T10:48:50Z", + "did": { + "didString": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", + "methodSpecificId": "b5d70adf-31ca-4662-aa10-d3a54cd8f06c", + "method": "cheqd" + } + }, + "didDocument": { + "@context": [ + "https://www.w3.org/ns/did/v1", + "https://w3id.org/security/suites/ed25519-2018/v1" + ], + "id": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", + "verificationMethod": [ + { + "id": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c#key-1", + "type": "Ed25519VerificationKey2018", + "controller": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", + "publicKeyBase58": "BpVGbTeT26LipAdk26DBZrmJx2939i9gZS5VxGt1zZQ6" + } + ], + "authentication": [ + "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c#key-1" + ], + "service": [ + { + "id": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c#bar", + "type": "LinkedDomains", + "serviceEndpoint": [ + "https://bar.example.com" + ] + } + ] + }, + "didDocumentMetadata": { + "created": "2023-03-06T09:36:55Z", + "updated": "2023-03-06T09:59:22Z", + "deactivated": true, + "versionId": "f790c9b9-4817-4b31-be43-b198e6e18071", + "linkedResourceMetadata": [ + { + "resourceURI": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c/resources/5e16a3f9-7c6e-4b6b-8e28-20f56780ee25", + "resourceCollectionId": "b5d70adf-31ca-4662-aa10-d3a54cd8f06c", + "resourceId": "5e16a3f9-7c6e-4b6b-8e28-20f56780ee25", + "resourceName": "TestResource", + "resourceType": "TestType", + "mediaType": "text/plain; charset=utf-8", + "resourceVersion": "1.0", + "created": "2023-03-06T09:53:44Z", + "checksum": "64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c", + "previousVersionId": null, + "nextVersionId": null + } + ] + } +} diff --git a/utils/parse_time.go b/utils/parse_time.go index 4497421c..a344a8f6 100644 --- a/utils/parse_time.go +++ b/utils/parse_time.go @@ -1,6 +1,9 @@ package utils -import "time" +import ( + "fmt" + "time" +) func ParseFromStringTimeToGoTime(timeString string) (time.Time, error) { // If timeString is empty return default nullable time value (0001-01-01 00:00:00 +0000 UTC) @@ -8,13 +11,38 @@ func ParseFromStringTimeToGoTime(timeString string) (time.Time, error) { return time.Time{}, nil } - t, err := time.Parse(time.RFC3339, timeString) - if err == nil { - return t, nil - } - t, err = time.Parse(time.RFC3339Nano, timeString) + t, err := parseTimeString(timeString) if err == nil { return t, nil } + return time.Time{}, err } + +func parseTimeString(timeString string) (time.Time, error) { + formats := []string{ + time.Layout, + time.ANSIC, + time.UnixDate, + time.RubyDate, + time.RFC822, + time.RFC822Z, + time.RFC850, + time.RFC1123, + time.RFC1123Z, + time.RFC3339, + time.RFC3339Nano, + time.DateTime, + time.DateOnly, + } + + // Try parsing the date using different formats + for _, format := range formats { + parsedTime, err := time.Parse(format, timeString) + if err == nil { + return parsedTime.UTC(), nil + } + } + + return time.Time{}, fmt.Errorf("unable to parse date string") +} From 5228523bb229217b31842806126e6e0e91422057 Mon Sep 17 00:00:00 2001 From: abdulla-ashurov <99400260+abdulla-ashurov@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:13:19 +0500 Subject: [PATCH 2/3] fix: Minor fix of "transformKey" to "transformKeys" [DEV-2813] (#164) * Rename "transformKey" to "transformKeys". * Update swagger OpenAPI. --- docs/docs.go | 4 +- docs/swagger.json | 4 +- docs/swagger.yaml | 4 +- services/diddoc/diddoc_query.go | 12 ++-- services/diddoc/echo_handlers.go | 4 +- .../diddoc/did_query_transform_key_handler.go | 14 ++-- services/diddoc/queries/diddoc/utils.go | 36 +++++----- .../rest/diddoc/query/common_positive_test.go | 8 +-- .../query/transform_key/negative_test.go | 45 ++++++------ .../query/transform_key/positive_test.go | 72 +++++++++---------- .../diddoc/query/transform_key/suite_test.go | 4 +- .../diddoc/query/version_id/negative_test.go | 4 +- .../request/diddoc_transform_key_test.go | 54 +++++++------- types/constants.go | 14 ++-- types/supported_queries.go | 12 ++-- 15 files changed, 145 insertions(+), 146 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 02d4d5ea..fadc0f67 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -69,7 +69,7 @@ const docTemplate = `{ { "type": "string", "description": "Can transform Verification Method into another type", - "name": "transformKey", + "name": "transformKeys", "in": "query" }, { @@ -141,7 +141,7 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "versionId, versionTime, transformKey returns Full DID Document", + "description": "versionId, versionTime, transformKeys returns Full DID Document", "schema": { "$ref": "#/definitions/types.DidResolution" } diff --git a/docs/swagger.json b/docs/swagger.json index b04dbd96..3f8ab66b 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -66,7 +66,7 @@ { "type": "string", "description": "Can transform Verification Method into another type", - "name": "transformKey", + "name": "transformKeys", "in": "query" }, { @@ -138,7 +138,7 @@ ], "responses": { "200": { - "description": "versionId, versionTime, transformKey returns Full DID Document", + "description": "versionId, versionTime, transformKeys returns Full DID Document", "schema": { "$ref": "#/definitions/types.DidResolution" } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index db6a1095..48ad3dab 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -288,7 +288,7 @@ paths: type: string - description: Can transform Verification Method into another type in: query - name: transformKey + name: transformKeys type: string - description: Redirects to Service Endpoint in: query @@ -340,7 +340,7 @@ paths: - application/did+json responses: "200": - description: versionId, versionTime, transformKey returns Full DID Document + description: versionId, versionTime, transformKeys returns Full DID Document schema: $ref: '#/definitions/types.DidResolution' "400": diff --git a/services/diddoc/diddoc_query.go b/services/diddoc/diddoc_query.go index 0fc5fecf..1ea68203 100644 --- a/services/diddoc/diddoc_query.go +++ b/services/diddoc/diddoc_query.go @@ -49,7 +49,7 @@ func (dd *QueryDIDDocRequestService) SpecificValidation(c services.ResolverConte versionId := dd.GetQueryParam(types.VersionId) versionTime := dd.GetQueryParam(types.VersionTime) - transformKey := types.TransformKeyType(dd.GetQueryParam(types.TransformKey)) + transformKeys := types.TransformKeysType(dd.GetQueryParam(types.TransformKeys)) service := dd.GetQueryParam(types.ServiceQ) relativeRef := dd.GetQueryParam(types.RelativeRef) resourceId := dd.GetQueryParam(types.ResourceId) @@ -57,7 +57,7 @@ func (dd *QueryDIDDocRequestService) SpecificValidation(c services.ResolverConte metadata := dd.GetQueryParam(types.Metadata) resourceMetadata := dd.GetQueryParam(types.ResourceMetadata) - if string(transformKey) != "" && (!transformKey.IsSupported() || !types.IsSupportedWithCombinationTransformKeyQuery(dd.Queries)) { + if string(transformKeys) != "" && (!transformKeys.IsSupported() || !types.IsSupportedWithCombinationTransformKeysQuery(dd.Queries)) { return types.NewRepresentationNotSupportedError(dd.GetDid(), dd.GetContentType(), nil, dd.IsDereferencing) } @@ -179,13 +179,13 @@ func (dd *QueryDIDDocRequestService) RegisterDidDocQueryHandlers(startHandler qu // or // - versionIdHandler // After that we can find for service field if it's set. - // VersionIdHandler -> VersionTimeHandler -> DidDocResolveHandler -> TransformKeyHandler -> DidDocMetadataHandler -> ServiceHandler -> RelativeRefHandler + // VersionIdHandler -> VersionTimeHandler -> DidDocResolveHandler -> TransformKeysHandler -> DidDocMetadataHandler -> ServiceHandler -> RelativeRefHandler relativeRefHandler := diddocQueries.RelativeRefHandler{} serviceHandler := diddocQueries.ServiceHandler{} versionIdHandler := diddocQueries.VersionIdHandler{} versionTimeHandler := diddocQueries.VersionTimeHandler{} didDocResolveHandler := diddocQueries.DidDocResolveHandler{} - transformKeyHandler := diddocQueries.TransformKeyHandler{} + transformKeysHandler := diddocQueries.TransformKeysHandler{} didDocMetadataHandler := diddocQueries.DidDocMetadataHandler{} err := startHandler.SetNext(c, &versionIdHandler) @@ -203,12 +203,12 @@ func (dd *QueryDIDDocRequestService) RegisterDidDocQueryHandlers(startHandler qu return nil, err } - err = didDocResolveHandler.SetNext(c, &transformKeyHandler) + err = didDocResolveHandler.SetNext(c, &transformKeysHandler) if err != nil { return nil, err } - err = transformKeyHandler.SetNext(c, &didDocMetadataHandler) + err = transformKeysHandler.SetNext(c, &didDocMetadataHandler) if err != nil { return nil, err } diff --git a/services/diddoc/echo_handlers.go b/services/diddoc/echo_handlers.go index cb5d1574..818cca10 100644 --- a/services/diddoc/echo_handlers.go +++ b/services/diddoc/echo_handlers.go @@ -20,7 +20,7 @@ import ( // @Param fragmentId query string false "#Fragment" // @Param versionId query string false "Version" // @Param versionTime query string false "Created of Updated time of DID Document" -// @Param transformKey query string false "Can transform Verification Method into another type" +// @Param transformKeys query string false "Can transform Verification Method into another type" // @Param service query string false "Redirects to Service Endpoint" // @Param relativeRef query string false "Addition to Service Endpoint" // @Param metadata query string false "Show only metadata of DID Document" @@ -32,7 +32,7 @@ import ( // @Param resourceVersionTime query string false "Get the nearest resource by creation time" // @Param resourceMetadata query string false "Show only metadata of resources" // @Param checksum query string false "Sanity check that Checksum of resource is the same as expected" -// @success 200 {object} types.DidResolution "versionId, versionTime, transformKey returns Full DID Document" +// @success 200 {object} types.DidResolution "versionId, versionTime, transformKeys returns Full DID Document" // @Failure 400 {object} types.IdentityError // @Failure 404 {object} types.IdentityError // @Failure 406 {object} types.IdentityError diff --git a/services/diddoc/queries/diddoc/did_query_transform_key_handler.go b/services/diddoc/queries/diddoc/did_query_transform_key_handler.go index 0de65d5c..518f9283 100644 --- a/services/diddoc/queries/diddoc/did_query_transform_key_handler.go +++ b/services/diddoc/queries/diddoc/did_query_transform_key_handler.go @@ -6,20 +6,20 @@ import ( "github.com/cheqd/did-resolver/types" ) -type TransformKeyHandler struct { +type TransformKeysHandler struct { queries.BaseQueryHandler } -func (t *TransformKeyHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { +func (t *TransformKeysHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { // Get Params - transformKey := types.TransformKeyType(service.GetQueryParam(types.TransformKey)) + transformKeys := types.TransformKeysType(service.GetQueryParam(types.TransformKeys)) - // If transformKey is empty, call the next handler. We don't need to handle it here - if transformKey == "" { + // If transformKeys is empty, call the next handler. We don't need to handle it here + if transformKeys == "" { return t.Continue(c, service, response) } - if !transformKey.IsSupported() { + if !transformKeys.IsSupported() { return nil, types.NewRepresentationNotSupportedError(service.GetDid(), types.DIDJSONLD, nil, t.IsDereferencing) } @@ -30,7 +30,7 @@ func (t *TransformKeyHandler) Handle(c services.ResolverContext, service service } for i, vMethod := range didResolution.Did.VerificationMethod { - result, err := transformVerificationMethodKey(vMethod, transformKey) + result, err := transformVerificationMethodKey(vMethod, transformKeys) if err != nil { return nil, err } diff --git a/services/diddoc/queries/diddoc/utils.go b/services/diddoc/queries/diddoc/utils.go index 3fa9df67..c26a9032 100644 --- a/services/diddoc/queries/diddoc/utils.go +++ b/services/diddoc/queries/diddoc/utils.go @@ -7,7 +7,7 @@ import ( "github.com/cheqd/did-resolver/utils" ) -func transformKeyEd25519VerificationKey2018ToEd25519VerificationKey2020( +func transformKeysEd25519VerificationKey2018ToEd25519VerificationKey2020( verificationMethod types.VerificationMethod, ) (types.VerificationMethod, error) { publicKeyMultibase, err := utils.Ed25519VerificationKey2018ToEd25519VerificationKey2020(verificationMethod.PublicKeyBase58) @@ -22,7 +22,7 @@ func transformKeyEd25519VerificationKey2018ToEd25519VerificationKey2020( return verificationMethod, nil } -func transformKeyEd25519VerificationKey2018ToJSONWebKey2020( +func transformKeysEd25519VerificationKey2018ToJSONWebKey2020( verificationMethod types.VerificationMethod, ) (types.VerificationMethod, error) { publicKeyJwk, err := utils.Ed25519VerificationKey2018ToJSONWebKey2020(verificationMethod.PublicKeyBase58) @@ -37,7 +37,7 @@ func transformKeyEd25519VerificationKey2018ToJSONWebKey2020( return verificationMethod, nil } -func transformKeyEd25519VerificationKey2020ToEd25519VerificationKey2018( +func transformKeysEd25519VerificationKey2020ToEd25519VerificationKey2018( verificationMethod types.VerificationMethod, ) (types.VerificationMethod, error) { publicKeyBase58, err := utils.Ed25519VerificationKey2020ToEd25519VerificationKey2018(verificationMethod.PublicKeyMultibase) @@ -52,7 +52,7 @@ func transformKeyEd25519VerificationKey2020ToEd25519VerificationKey2018( return verificationMethod, nil } -func transformKeyEd25519VerificationKey2020ToJSONWebKey2020( +func transformKeysEd25519VerificationKey2020ToJSONWebKey2020( verificationMethod types.VerificationMethod, ) (types.VerificationMethod, error) { publicKeyJwk, err := utils.Ed25519VerificationKey2020ToJSONWebKey2020(verificationMethod.PublicKeyMultibase) @@ -67,7 +67,7 @@ func transformKeyEd25519VerificationKey2020ToJSONWebKey2020( return verificationMethod, nil } -func transformKeyJSONWebKey2020ToEd25519VerificationKey2018( +func transformKeysJSONWebKey2020ToEd25519VerificationKey2018( verificationMethod types.VerificationMethod, ) (types.VerificationMethod, error) { publicKeyBase58, err := utils.JSONWebKey2020ToEd25519VerificationKey2018(verificationMethod.PublicKeyJwk) @@ -82,7 +82,7 @@ func transformKeyJSONWebKey2020ToEd25519VerificationKey2018( return verificationMethod, nil } -func transformKeyJSONWebKey2020ToEd25519VerificationKey2020( +func transformKeysJSONWebKey2020ToEd25519VerificationKey2020( verificationMethod types.VerificationMethod, ) (types.VerificationMethod, error) { publicKeyMultibase, err := utils.JSONWebKey2020ToEd25519VerificationKey2020(verificationMethod.PublicKeyJwk) @@ -98,37 +98,37 @@ func transformKeyJSONWebKey2020ToEd25519VerificationKey2020( } func transformVerificationMethodKey( - verificationMethod types.VerificationMethod, transformKeyType types.TransformKeyType, + verificationMethod types.VerificationMethod, transformKeysType types.TransformKeysType, ) (types.VerificationMethod, error) { - verificationMethodType := types.TransformKeyType(verificationMethod.Type) - if verificationMethodType == transformKeyType { + verificationMethodType := types.TransformKeysType(verificationMethod.Type) + if verificationMethodType == transformKeysType { return verificationMethod, nil } switch verificationMethodType { case types.Ed25519VerificationKey2018: - switch transformKeyType { + switch transformKeysType { case types.Ed25519VerificationKey2020: - return transformKeyEd25519VerificationKey2018ToEd25519VerificationKey2020(verificationMethod) + return transformKeysEd25519VerificationKey2018ToEd25519VerificationKey2020(verificationMethod) case types.JsonWebKey2020: - return transformKeyEd25519VerificationKey2018ToJSONWebKey2020(verificationMethod) + return transformKeysEd25519VerificationKey2018ToJSONWebKey2020(verificationMethod) } case types.Ed25519VerificationKey2020: - switch transformKeyType { + switch transformKeysType { case types.Ed25519VerificationKey2018: - return transformKeyEd25519VerificationKey2020ToEd25519VerificationKey2018(verificationMethod) + return transformKeysEd25519VerificationKey2020ToEd25519VerificationKey2018(verificationMethod) case types.JsonWebKey2020: - return transformKeyEd25519VerificationKey2020ToJSONWebKey2020(verificationMethod) + return transformKeysEd25519VerificationKey2020ToJSONWebKey2020(verificationMethod) } case types.JsonWebKey2020: - switch transformKeyType { + switch transformKeysType { case types.Ed25519VerificationKey2018: - return transformKeyJSONWebKey2020ToEd25519VerificationKey2018(verificationMethod) + return transformKeysJSONWebKey2020ToEd25519VerificationKey2018(verificationMethod) case types.Ed25519VerificationKey2020: - return transformKeyJSONWebKey2020ToEd25519VerificationKey2020(verificationMethod) + return transformKeysJSONWebKey2020ToEd25519VerificationKey2020(verificationMethod) } } diff --git a/tests/integration/rest/diddoc/query/common_positive_test.go b/tests/integration/rest/diddoc/query/common_positive_test.go index 0f109af4..150ff6ea 100644 --- a/tests/integration/rest/diddoc/query/common_positive_test.go +++ b/tests/integration/rest/diddoc/query/common_positive_test.go @@ -49,10 +49,10 @@ var _ = DescribeTable("Positive: request with common query parameters", func(tes ), Entry( - "can get DIDDoc with an existent versionId and transformKey query parameters", + "can get DIDDoc with an existent versionId and transformKeys query parameters", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?versionId=%s&transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?versionId=%s&transformKeys=%s", testconstants.SeveralVersionsDID, "ce298b6f-594b-426e-b431-370d6bc5d3ad", types.JsonWebKey2020, @@ -64,10 +64,10 @@ var _ = DescribeTable("Positive: request with common query parameters", func(tes ), Entry( - "can get DIDDoc with an existent versionId, versionTime, transformKey", + "can get DIDDoc with an existent versionId, versionTime, transformKeys", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?versionId=%s&versionTime=%s&transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?versionId=%s&versionTime=%s&transformKeys=%s", testconstants.SeveralVersionsDID, "ce298b6f-594b-426e-b431-370d6bc5d3ad", "2023-03-06T09:39:49Z", diff --git a/tests/integration/rest/diddoc/query/transform_key/negative_test.go b/tests/integration/rest/diddoc/query/transform_key/negative_test.go index 0bedc6dd..403dbba7 100644 --- a/tests/integration/rest/diddoc/query/transform_key/negative_test.go +++ b/tests/integration/rest/diddoc/query/transform_key/negative_test.go @@ -1,6 +1,6 @@ //go:build integration -package transformKey +package transformKeys import ( "encoding/json" @@ -17,7 +17,7 @@ import ( var identifierDidWithEd25519VerificationKey2018Key = "d8ac0372-0d4b-413e-8ef5-8e8f07822b2c" -var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", func(testCase utils.NegativeTestCase) { +var _ = DescribeTable("Negative: Get DIDDoc with transformKeys query parameter", func(testCase utils.NegativeTestCase) { client := resty.New() resp, err := client.R(). @@ -25,7 +25,6 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", Get(testCase.DidURL) Expect(err).To(BeNil()) - Expect(testCase.ExpectedStatusCode).To(Equal(resp.StatusCode())) expectedDidResolution, ok := testCase.ExpectedResult.(types.DidResolution) if ok { @@ -41,10 +40,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", }, Entry( - "cannot get DIDDoc with not existent DID and not supported transformKey query parameter", + "cannot get DIDDoc with not existent DID and not supported transformKeys query parameter", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=EDDSA", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=EDDSA", testconstants.NotExistentTestnetDid, ), ResolutionType: testconstants.DefaultResolutionType, @@ -67,10 +66,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", ), Entry( - "cannot get DIDDoc with not supported transformKey query parameter", + "cannot get DIDDoc with not supported transformKeys query parameter", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=EDDSA", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=EDDSA", didWithEd25519VerificationKey2018Key, ), ResolutionType: testconstants.DefaultResolutionType, @@ -93,10 +92,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", ), Entry( - "cannot get DIDDoc with combination of transformKey and metadata query parameters", + "cannot get DIDDoc with combination of transformKeys and metadata query parameters", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&metadata=true", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&metadata=true", didWithEd25519VerificationKey2018Key, types.Ed25519VerificationKey2020, ), @@ -120,10 +119,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceId query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceId query parameters", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&resourceId=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&resourceId=%s", didWithEd25519VerificationKey2018Key, types.Ed25519VerificationKey2020, testconstants.ValidIdentifier, @@ -148,10 +147,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceName query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceName query parameters", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&resourceName=someName", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&resourceName=someName", didWithEd25519VerificationKey2018Key, types.Ed25519VerificationKey2020, ), @@ -175,10 +174,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceType query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceType query parameters", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&resourceType=someType", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&resourceType=someType", didWithEd25519VerificationKey2018Key, types.Ed25519VerificationKey2020, ), @@ -202,10 +201,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceVersionTime query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceVersionTime query parameters", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&resourceVersionTime=2006-01-02", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&resourceVersionTime=2006-01-02", didWithEd25519VerificationKey2018Key, types.Ed25519VerificationKey2020, ), @@ -229,10 +228,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceMetadata query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceMetadata query parameters", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&resourceMetadata=true", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&resourceMetadata=true", didWithEd25519VerificationKey2018Key, types.Ed25519VerificationKey2020, ), @@ -256,10 +255,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceCollectionId query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceCollectionId query parameters", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&resourceCollectionId=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&resourceCollectionId=%s", didWithEd25519VerificationKey2018Key, types.Ed25519VerificationKey2020, testconstants.ValidIdentifier, @@ -284,10 +283,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with transformKey query parameter", ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceVersion query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceVersion query parameters", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&resourceVersion=someVersion", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&resourceVersion=someVersion", didWithEd25519VerificationKey2018Key, types.Ed25519VerificationKey2020, ), diff --git a/tests/integration/rest/diddoc/query/transform_key/positive_test.go b/tests/integration/rest/diddoc/query/transform_key/positive_test.go index 721b6798..4b2b2cd0 100644 --- a/tests/integration/rest/diddoc/query/transform_key/positive_test.go +++ b/tests/integration/rest/diddoc/query/transform_key/positive_test.go @@ -1,6 +1,6 @@ //go:build integration -package transformKey +package transformKeys import ( "encoding/json" @@ -20,7 +20,7 @@ var ( didWithJsonWebKey2020Key = "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291" ) -var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", func(testCase utils.PositiveTestCase) { +var _ = DescribeTable("Positive: Get DIDDoc with transformKeys query parameter", func(testCase utils.PositiveTestCase) { client := resty.New() resp, err := client.R(). @@ -38,10 +38,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", utils.AssertDidResolution(expectedDidResolution, receivedDidResolution) }, Entry( - "can get DIDDoc (Ed25519VerificationKey2018) with supported Ed25519VerificationKey2018 transformKey query parameter", + "can get DIDDoc (Ed25519VerificationKey2018) with supported Ed25519VerificationKey2018 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", didWithEd25519VerificationKey2018Key, string(types.Ed25519VerificationKey2018), ), @@ -52,10 +52,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2018) with supported Ed25519VerificationKey2020 transformKey query parameter", + "can get DIDDoc (Ed25519VerificationKey2018) with supported Ed25519VerificationKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", didWithEd25519VerificationKey2018Key, string(types.Ed25519VerificationKey2020), ), @@ -66,10 +66,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2018) with supported JSONWebKey2020 transformKey query parameter", + "can get DIDDoc (Ed25519VerificationKey2018) with supported JSONWebKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", didWithEd25519VerificationKey2018Key, string(types.JsonWebKey2020), ), @@ -80,10 +80,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2020) with supported Ed25519VerificationKey2018 transformKey query parameter", + "can get DIDDoc (Ed25519VerificationKey2020) with supported Ed25519VerificationKey2018 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", testconstants.UUIDStyleTestnetDid, string(types.Ed25519VerificationKey2018), ), @@ -94,10 +94,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2020) with supported Ed25519VerificationKey2020 transformKey query parameter", + "can get DIDDoc (Ed25519VerificationKey2020) with supported Ed25519VerificationKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", testconstants.UUIDStyleTestnetDid, string(types.Ed25519VerificationKey2020), ), @@ -108,10 +108,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2020) with supported JSONWebKey2020 transformKey query parameter", + "can get DIDDoc (Ed25519VerificationKey2020) with supported JSONWebKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", testconstants.UUIDStyleTestnetDid, string(types.JsonWebKey2020), ), @@ -122,10 +122,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (JSONWebKey2020) with supported Ed25519VerificationKey2018 transformKey query parameter", + "can get DIDDoc (JSONWebKey2020) with supported Ed25519VerificationKey2018 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", didWithJsonWebKey2020Key, string(types.Ed25519VerificationKey2018), ), @@ -136,10 +136,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (JSONWebKey2020) with supported Ed25519VerificationKey2020 transformKey query parameter", + "can get DIDDoc (JSONWebKey2020) with supported Ed25519VerificationKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", didWithJsonWebKey2020Key, string(types.Ed25519VerificationKey2020), ), @@ -150,10 +150,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (JSONWebKey2020) with supported JSONWebKey2020 transformKey query parameter", + "can get DIDDoc (JSONWebKey2020) with supported JSONWebKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", didWithJsonWebKey2020Key, string(types.JsonWebKey2020), ), @@ -164,10 +164,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (JSONWebKey2020) with an existent old 16 characters INDY style DID and supported Ed25519VerificationKey2018 transformKey query parameter", + "can get DIDDoc (JSONWebKey2020) with an existent old 16 characters INDY style DID and supported Ed25519VerificationKey2018 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", testconstants.OldIndy16CharStyleTestnetDid, string(types.Ed25519VerificationKey2018), ), @@ -178,10 +178,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (JSONWebKey2020) with an existent old 16 characters INDY style DID and supported Ed25519VerificationKey2020 transformKey query parameter", + "can get DIDDoc (JSONWebKey2020) with an existent old 16 characters INDY style DID and supported Ed25519VerificationKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", testconstants.OldIndy16CharStyleTestnetDid, string(types.Ed25519VerificationKey2020), ), @@ -192,10 +192,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (JSONWebKey2020) with an existent old 16 characters INDY style DID and supported JSONWebKey2020 transformKey query parameter", + "can get DIDDoc (JSONWebKey2020) with an existent old 16 characters INDY style DID and supported JSONWebKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", testconstants.OldIndy16CharStyleTestnetDid, string(types.JsonWebKey2020), ), @@ -206,10 +206,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2020) with an existent old 32 characters INDY style DID and supported Ed25519VerificationKey2018 transformKey query parameter", + "can get DIDDoc (Ed25519VerificationKey2020) with an existent old 32 characters INDY style DID and supported Ed25519VerificationKey2018 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", testconstants.OldIndy32CharStyleTestnetDid, string(types.Ed25519VerificationKey2018), ), @@ -220,10 +220,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2020) with an existent old 32 characters INDY style DID and supported Ed25519VerificationKey2020 transformKey query parameter", + "can get DIDDoc (Ed25519VerificationKey2020) with an existent old 32 characters INDY style DID and supported Ed25519VerificationKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", testconstants.OldIndy32CharStyleTestnetDid, string(types.Ed25519VerificationKey2020), ), @@ -234,10 +234,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2020) with an existent old 32 characters INDY style DID and supported JSONWebKey2020 transformKey query parameter", + "can get DIDDoc (Ed25519VerificationKey2020) with an existent old 32 characters INDY style DID and supported JSONWebKey2020 transformKeys query parameter", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s", testconstants.OldIndy32CharStyleTestnetDid, string(types.JsonWebKey2020), ), @@ -248,10 +248,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2018) with supported Ed25519VerificationKey2020 transformKey and DIDDoc versionId queries", + "can get DIDDoc (Ed25519VerificationKey2018) with supported Ed25519VerificationKey2020 transformKeys and DIDDoc versionId queries", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&versionId=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&versionId=%s", didWithEd25519VerificationKey2018Key, string(types.Ed25519VerificationKey2020), "44f49254-8106-40ee-99ad-e50ac9517346", @@ -263,10 +263,10 @@ var _ = DescribeTable("Positive: Get DIDDoc with transformKey query parameter", ), Entry( - "can get DIDDoc (Ed25519VerificationKey2018) with supported Ed25519VerificationKey2020 transformKey and DIDDoc versionTime queries", + "can get DIDDoc (Ed25519VerificationKey2018) with supported Ed25519VerificationKey2020 transformKeys and DIDDoc versionTime queries", utils.PositiveTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?transformKey=%s&versionTime=%s", + "http://localhost:8080/1.0/identifiers/%s?transformKeys=%s&versionTime=%s", didWithEd25519VerificationKey2018Key, string(types.Ed25519VerificationKey2020), "2023-02-21T14:28:48.406713879Z", diff --git a/tests/integration/rest/diddoc/query/transform_key/suite_test.go b/tests/integration/rest/diddoc/query/transform_key/suite_test.go index 6c9ac2b4..accaea44 100644 --- a/tests/integration/rest/diddoc/query/transform_key/suite_test.go +++ b/tests/integration/rest/diddoc/query/transform_key/suite_test.go @@ -1,6 +1,6 @@ //go:build integration -package transformKey +package transformKeys import ( "testing" @@ -11,5 +11,5 @@ import ( func TestTransformKey(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "[Integration Test]: Transform Key Query") + RunSpecs(t, "[Integration Test]: Transform Keys Query") } diff --git a/tests/integration/rest/diddoc/query/version_id/negative_test.go b/tests/integration/rest/diddoc/query/version_id/negative_test.go index 0e60359b..6ffdbc72 100644 --- a/tests/integration/rest/diddoc/query/version_id/negative_test.go +++ b/tests/integration/rest/diddoc/query/version_id/negative_test.go @@ -114,10 +114,10 @@ var _ = DescribeTable("Negative: Get DIDDoc with versionId query", func(testCase ), Entry( - "cannot get DIDDoc with an existent versionId, but not supported transformKey value query parameters", + "cannot get DIDDoc with an existent versionId, but not supported transformKeys value query parameters", utils.NegativeTestCase{ DidURL: fmt.Sprintf( - "http://localhost:8080/1.0/identifiers/%s?versionId=%s&transformKey=EDDSA", + "http://localhost:8080/1.0/identifiers/%s?versionId=%s&transformKeys=EDDSA", testconstants.SeveralVersionsDID, testconstants.SeveralVersionsDIDVersionId, ), diff --git a/tests/unit/diddoc/request/diddoc_transform_key_test.go b/tests/unit/diddoc/request/diddoc_transform_key_test.go index 0c4a9b74..eddbb84e 100644 --- a/tests/unit/diddoc/request/diddoc_transform_key_test.go +++ b/tests/unit/diddoc/request/diddoc_transform_key_test.go @@ -17,7 +17,7 @@ import ( . "github.com/onsi/gomega" ) -var _ = DescribeTable("Test Query handler with transformKey params", func(testCase QueriesDIDDocTestCase) { +var _ = DescribeTable("Test Query handler with transformKeys params", func(testCase QueriesDIDDocTestCase) { request := httptest.NewRequest(http.MethodGet, testCase.didURL, nil) context, rec := utils.SetupEmptyContext(request, testCase.resolutionType, utils.MockLedger) expectedDIDResolution := testCase.expectedResolution.(*types.DidResolution) @@ -46,10 +46,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa }, Entry( - "can get DIDDoc (JSONWebKey2020) with supported Ed25519VerificationKey2018 transformKey query parameter", + "can get DIDDoc (JSONWebKey2020) with supported Ed25519VerificationKey2018 transformKeys query parameter", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s", + "/1.0/identifiers/%s?transformKeys=%s", testconstants.ValidDid, types.Ed25519VerificationKey2018, ), @@ -83,10 +83,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "can get DIDDoc (JSONWebKey2020) with supported Ed25519VerificationKey2020 transformKey query parameter", + "can get DIDDoc (JSONWebKey2020) with supported Ed25519VerificationKey2020 transformKeys query parameter", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s", + "/1.0/identifiers/%s?transformKeys=%s", testconstants.ValidDid, types.Ed25519VerificationKey2020, ), @@ -120,10 +120,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with not existent DID and supported transformKey query parameter", + "cannot get DIDDoc with not existent DID and supported transformKeys query parameter", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s", + "/1.0/identifiers/%s?transformKeys=%s", testconstants.NotExistentTestnetDid, types.Ed25519VerificationKey2018, ), @@ -136,10 +136,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc (JSONWebKey2020) with not supported transformKey query parameter", + "cannot get DIDDoc (JSONWebKey2020) with not supported transformKeys query parameter", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=notSupportedTransformKey", + "/1.0/identifiers/%s?transformKeys=notSupportedTransformKeys", testconstants.ValidDid, ), resolutionType: types.DIDJSONLD, @@ -151,10 +151,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with combination of transformKey and metadata query parameters", + "cannot get DIDDoc with combination of transformKeys and metadata query parameters", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s&metadata=true", + "/1.0/identifiers/%s?transformKeys=%s&metadata=true", testconstants.ValidDid, types.Ed25519VerificationKey2018, ), @@ -167,10 +167,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with combination of transformKey and metadata query parameters", + "cannot get DIDDoc with combination of transformKeys and metadata query parameters", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s&metadata=true", + "/1.0/identifiers/%s?transformKeys=%s&metadata=true", testconstants.ValidDid, types.Ed25519VerificationKey2018, ), @@ -183,10 +183,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceId query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceId query parameters", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s&resourceId=%s", + "/1.0/identifiers/%s?transformKeys=%s&resourceId=%s", testconstants.ValidDid, types.Ed25519VerificationKey2018, testconstants.ValidIdentifier, @@ -200,10 +200,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceName query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceName query parameters", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s&resourceName=someName", + "/1.0/identifiers/%s?transformKeys=%s&resourceName=someName", testconstants.ValidDid, types.Ed25519VerificationKey2018, ), @@ -216,10 +216,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceType query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceType query parameters", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s&resourceType=someType", + "/1.0/identifiers/%s?transformKeys=%s&resourceType=someType", testconstants.ValidDid, types.Ed25519VerificationKey2018, ), @@ -232,10 +232,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceVersionTime query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceVersionTime query parameters", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s&resourceVersionTime=2006-01-02", + "/1.0/identifiers/%s?transformKeys=%s&resourceVersionTime=2006-01-02", testconstants.ValidDid, types.Ed25519VerificationKey2018, ), @@ -248,10 +248,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceMetadata query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceMetadata query parameters", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s&resourceMetadata=true", + "/1.0/identifiers/%s?transformKeys=%s&resourceMetadata=true", testconstants.ValidDid, types.Ed25519VerificationKey2018, ), @@ -264,10 +264,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceCollectionId query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceCollectionId query parameters", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s&resourceCollectionId=%s", + "/1.0/identifiers/%s?transformKeys=%s&resourceCollectionId=%s", testconstants.ValidDid, types.Ed25519VerificationKey2018, testconstants.ValidIdentifier, @@ -281,10 +281,10 @@ var _ = DescribeTable("Test Query handler with transformKey params", func(testCa ), Entry( - "cannot get DIDDoc with combination of transformKey and resourceVersion query parameters", + "cannot get DIDDoc with combination of transformKeys and resourceVersion query parameters", QueriesDIDDocTestCase{ didURL: fmt.Sprintf( - "/1.0/identifiers/%s?transformKey=%s&resourceVersion=someVersion", + "/1.0/identifiers/%s?transformKeys=%s&resourceVersion=someVersion", testconstants.ValidDid, types.Ed25519VerificationKey2018, ), diff --git a/types/constants.go b/types/constants.go index 2371e2c2..6120d904 100644 --- a/types/constants.go +++ b/types/constants.go @@ -18,16 +18,16 @@ func (cType ContentType) IsSupported() bool { return supportedTypes[cType] } -type TransformKeyType string +type TransformKeysType string const ( - Ed25519VerificationKey2018 TransformKeyType = "Ed25519VerificationKey2018" - Ed25519VerificationKey2020 TransformKeyType = "Ed25519VerificationKey2020" - JsonWebKey2020 TransformKeyType = "JsonWebKey2020" + Ed25519VerificationKey2018 TransformKeysType = "Ed25519VerificationKey2018" + Ed25519VerificationKey2020 TransformKeysType = "Ed25519VerificationKey2020" + JsonWebKey2020 TransformKeysType = "JsonWebKey2020" ) -func (tKType TransformKeyType) IsSupported() bool { - supportedTypes := map[TransformKeyType]bool{ +func (tKType TransformKeysType) IsSupported() bool { + supportedTypes := map[TransformKeysType]bool{ Ed25519VerificationKey2018: true, Ed25519VerificationKey2020: true, JsonWebKey2020: true, @@ -56,7 +56,7 @@ const ( const ( VersionId string = "versionId" VersionTime string = "versionTime" - TransformKey string = "transformKey" + TransformKeys string = "transformKeys" Metadata string = "metadata" ServiceQ string = "service" RelativeRef string = "relativeRef" diff --git a/types/supported_queries.go b/types/supported_queries.go index ba400074..1b6dc39d 100644 --- a/types/supported_queries.go +++ b/types/supported_queries.go @@ -39,7 +39,7 @@ func (s *SupportedQueriesT) Plus(s2 SupportedQueriesT) SupportedQueriesT { var DidSupportedQueries = SupportedQueriesT{ VersionId, VersionTime, - TransformKey, + TransformKeys, ServiceQ, RelativeRef, Metadata, @@ -48,7 +48,7 @@ var DidSupportedQueries = SupportedQueriesT{ var DidResolutionQueries = SupportedQueriesT{ VersionId, VersionTime, - TransformKey, + TransformKeys, ServiceQ, RelativeRef, } @@ -66,20 +66,20 @@ var ResourceSupportedQueries = SupportedQueriesT{ var AllSupportedQueries = DidSupportedQueries.Plus(ResourceSupportedQueries) -var SupportedQueriesWithTransformKey = []string{ +var SupportedQueriesWithTransformKeys = []string{ VersionId, VersionTime, ServiceQ, RelativeRef, } -func IsSupportedWithCombinationTransformKeyQuery(values url.Values) bool { +func IsSupportedWithCombinationTransformKeysQuery(values url.Values) bool { for query := range values { - if query == TransformKey { + if query == TransformKeys { continue } - if !utils.Contains(SupportedQueriesWithTransformKey, query) { + if !utils.Contains(SupportedQueriesWithTransformKeys, query) { return false } } From dbf3d376f9aea2d895be65033e48a2b5ca6f4724 Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Tue, 20 Jun 2023 16:25:48 +0400 Subject: [PATCH 3/3] fix: Fix codeql (#170) fix: Move codeql to using go.mod file also --- .github/workflows/codeql.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6e5caa8e..524e4a2c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,7 +29,8 @@ jobs: - uses: actions/setup-go@v4 with: - go-version: 1.18 + go-version-file: ./go.mod + cache: true - name: Setup CodeQL uses: github/codeql-action/init@v2